:root {
    --accent-primary: #00acc1;
    --accent-deep: #006064;
    --bg-light: #f5f9fa;
    --bg-dark: #122124;
    --glass-light: rgba(255, 255, 255, 0.8);
    --glass-dark: rgba(22, 38, 42, 0.7);
    --border-light: rgba(0, 172, 193, 0.15);
    --border-dark: rgba(255, 255, 255, 0.08);
    --text-light: #1a3a3d;
    --text-dark: #e1f2f3;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    min-height: 100vh;
    color: var(--text-light);
    background-color: var(--bg-light);
    transition: background 0.4s ease;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

/* --- Professional Background v6.0 --- */
#app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, #e0f2f1 0%, #f1f8e9 100%);
}

body.dark-mode #app-background {
    background: linear-gradient(135deg, #0a1719 0%, #122a2e 100%);
}

.light-refraction {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140%;
    height: 140%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    opacity: 0.3;
    pointer-events: none;
}

/* --- Navigation Header --- */
header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 50px;
    padding: 10px 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 2.2rem;
}

.brand-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a5c63;
}

.accent-text {
    color: var(--accent-primary);
}

.version {
    font-size: 0.8rem;
    font-weight: 300;
    opacity: 0.5;
    margin-left: 10px;
}

body.dark-mode .brand-text {
    color: #80deea;
}

/* Theme Control UI */
.theme-control {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-light);
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

body.dark-mode .theme-control {
    background: var(--glass-dark);
    border-color: var(--border-dark);
}

.theme-label {
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.8;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

body.dark-mode .theme-toggle {
    background: #00838f;
    transform: rotate(180deg);
}

/* --- App Container --- */
.app-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 40px 20px;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 35px;
}

main {
    max-width: 100%;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-light);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 35px;
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.04);
    margin-bottom: 25px;
}

body.dark-mode .glass-panel {
    background: var(--glass-dark);
    border-color: var(--border-dark);
}

/* --- Uploader --- */
.drop-zone {
    margin-top: 25px;
    border: 3px dashed var(--accent-primary);
    border-radius: 20px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.3);
    transition: 0.3s ease;
}

.drop-zone:hover {
    background: rgba(0, 188, 212, 0.06);
    border-color: var(--accent-deep);
}

.drop-zone:active {
    transform: scale(0.99);
}

.drop-zone.file-selected {
    border-style: solid;
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.05));
}

/* --- Control Grid --- */
.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 25px;
}

.input-group {
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 8px;
    opacity: 0.7;
}

select,
input,
textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: white;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
}

body.dark-mode select,
body.dark-mode input,
body.dark-mode textarea {
    background: #1a3034;
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Modal and Hints */
.label-with-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.label-with-hint label {
    margin-bottom: 0;
}

.input-example {
    font-size: 0.75rem;
    opacity: 0.5;
    font-weight: 300;
}

.small-link-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 700;
    transition: 0.2s;
    padding: 2px 8px;
    border-radius: 4px;
}

.small-link-btn:hover {
    background: rgba(0, 172, 193, 0.1);
    text-decoration: underline;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 9999;
    /* Ensure it's on top of everything */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* Disable interaction when hidden */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    /* Enable interaction when active */
}

.modal-content {
    width: 90%;
    max-width: 850px;
    margin-bottom: 0;
    /* Override glass-panel margin */
    padding: 35px;
    transform: translateY(30px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    /* Bouncy float-up */
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.3);
    /* Premium floating shadow */
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: 0.2s;
    line-height: 1;
}

.close-btn:hover {
    opacity: 1;
    color: #ff5252;
}

#modal-textarea {
    height: 300px;
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.small-btn {
    width: auto;
    padding: 12px 30px;
    font-size: 0.95rem;
}

/* --- Help Accordion v6.0 (Nested) --- */
.help-category {
    margin-bottom: 20px;
    border-radius: 16px;
    background: rgba(0, 172, 193, 0.03);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

body.dark-mode .help-category {
    background: rgba(0, 0, 0, 0.1);
}

.category-title {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
    user-select: none;
}

body.dark-mode .category-title {
    background: rgba(0, 0, 0, 0.2);
}

.category-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    padding: 0 10px;
}

.help-category.active .category-content {
    max-height: 2000px;
    /* Large enough for nested items */
    padding: 15px 10px;
}

.help-item {
    background: white;
    margin-bottom: 8px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

body.dark-mode .help-item {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.03);
}

.help-title {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    user-select: none;
    /* Only title click shouldn't trigger selection issue */
}

.help-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 20px;
    font-size: 0.85rem;
    line-height: 1.6;
    transition: max-height 0.3s ease-out;
    opacity: 0.85;
}

.help-item.active .help-content {
    max-height: 500px;
    padding-bottom: 20px;
}

/* Status Cards */
.status-card {
    padding: 16px;
    border-radius: 12px;
    margin-top: 12px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

.status-complete {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.status-warning {
    background: #fff8e1;
    color: #f57f17;
    border: 1px solid #ffecb3;
}

/* Action Button */
.ripple-btn {
    width: 100%;
    padding: 22px;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(90deg, #1a5c63, #00838f);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: 0.3s ease;
}

.ripple-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.ripple-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ripple-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hidden {
    display: none;
}

/* Tooltip Icon */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 172, 193, 0.2);
    color: #00acc1;
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
    transition: all 0.2s;
}
.has-tooltip:hover .tooltip-icon {
    background: #00acc1;
    color: #fff;
    transform: scale(1.2);
}

/* Native tooltip styling via title - enhance with custom tooltip */
.has-tooltip {
    position: relative;
}
.has-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    top: 100%;
    z-index: 100;
    background: rgba(30, 30, 50, 0.95);
    color: #e0e0e0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-line;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
}
.has-tooltip:hover::after {
    opacity: 1;
    transform: translateY(8px);
}

@media (max-width: 1100px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}