/* ============================================================
   TIMETABLE PLANNER — Try Swiss Knife
   Follows TSK design system & subsite conventions
   ============================================================ */

:root {
    --color-primary: #003d5c;
    --color-accent: #00a8e8;
    --color-accent-hover: #0096c7;
    --color-white: #ffffff;
    --color-background: #f5f7fa;
    --color-border: #e0e6ed;
    --color-text-dark: #1a1a2e;
    --color-text-medium: #555f6d;
    --color-text-light: #8a95a3;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-danger-light: #fef2f2;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.09);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.13);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background: linear-gradient(160deg, #f0f4f8 0%, #e2e8f0 100%);
    min-height: 100vh;
    color: var(--color-text-dark);
    line-height: 1.6;
    padding: 0;
}

/* ─── Container ─── */
.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 0 1.5rem; }

/* ─── HEADER ─── */
.header {
    width: 100%;
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    transition: opacity 0.2s ease;
}
.header-logo-link:hover { opacity: 0.85; }

.logo-image {
    width: 85px;
    height: 85px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
}

.tool-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
    line-height: 1.2;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tool-name-btn {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
    line-height: 1.2;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s;
}
.tool-name-btn:hover { color: var(--color-accent); }

@media (max-width: 768px) {
    .header-inner { padding: 0.5rem 1rem; }
    .logo-image { width: 70px; height: 70px; }
    .tool-name { font-size: 1.25rem; }
    .header-left { display: flex; align-items: center; gap: 1rem; }
    .tool-name-btn { font-size: 1.25rem; }
    .header-icons { gap: 6px; }
    .header-icon-btn { width: 36px; height: 36px; }
    .header-icon-btn svg { width: 18px; height: 18px; }
    .lang-short { font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .header-inner { padding: 0.4rem 0.75rem; }
    .logo-image { width: 60px; height: 60px; }
    .tool-name { font-size: 1.1rem; }
    .header-left { display: flex; align-items: center; gap: 1rem; }
    .tool-name-btn { font-size: 1.1rem; }
    .setup-actions { flex-direction: column; }
    .setup-actions .btn { width: 100%; justify-content: center; }
}

/* ─── HEADER ICONS (Share + Language) ─── */
.header-icons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
}

.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--color-text-medium);
    font-family: inherit;
}

.header-icon-btn:hover {
    border-color: var(--color-accent);
    background: var(--color-background);
    color: var(--color-accent);
}

.header-icon-btn svg {
    width: 20px;
    height: 20px;
}

.lang-short {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-dark);
    letter-spacing: 0.02em;
}

.header-icon-btn:hover .lang-short { color: var(--color-accent); }

/* Language selector */
.language-selector { position: relative; }

.language-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 140px;
    z-index: 999;
    overflow: hidden;
}
.language-dropdown.active { display: block; animation: aboutSlideDown 0.2s ease; }

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--color-text-dark);
    transition: background 0.15s;
    font-family: inherit;
}
.lang-option:hover { background: var(--color-background); }
.lang-option.active { background: rgba(0,168,232,0.08); color: var(--color-accent); }
.lang-check { font-size: 0.75rem; opacity: 0; transition: opacity 0.15s; }
.lang-option.active .lang-check { opacity: 1; }

/* ─── INFO BANNER ─── */
.info-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #e3f2fd, #e1f5fe);
    border: 1.5px solid #4fc3f7;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 20px 0 24px;
    box-shadow: var(--shadow-sm);
}
.info-icon { font-size: 1.2rem; flex-shrink: 0; }
.info-text { color: #01579b; font-size: 0.875rem; flex: 1; }
.info-text strong { color: #004d7a; }
.info-close {
    background: none;
    border: none;
    color: #01579b;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    line-height: 1;
    transition: background 0.2s;
}
.info-close:hover { background: rgba(1,87,155,0.1); }

/* ─── SCREENS ─── */
.screen { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ─── SETUP SCREEN ─── */
.setup-hero {
    text-align: center;
    padding: 36px 20px 28px;
}
.setup-hero-icon { font-size: 3rem; margin-bottom: 10px; }
.setup-hero-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}
.setup-hero-subtitle { color: var(--color-text-medium); font-size: 1rem; }

.setup-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin: 0 0 40px;
}

.setup-section { margin-bottom: 2rem; }
.setup-section:last-child { margin-bottom: 0; }

.setup-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--color-border);
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--color-accent);
    color: white;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.setup-section-hint { font-size: 0.85rem; color: var(--color-text-medium); margin-bottom: 1rem; }

.user-type-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.user-type-label {
    font-size: 0.875rem;
    color: var(--color-text-medium);
    white-space: nowrap;
}

.user-type-btns {
    display: flex;
    gap: 0.4rem;
}

.user-type-btn {
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    border: 1.5px solid var(--color-border);
    background: transparent;
    color: var(--color-text-medium);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-type-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.user-type-btn.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
    font-weight: 600;
}

/* ─── FORM ─── */
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; flex: 1; min-width: 200px; }
.form-group label { font-size: 0.875rem; font-weight: 600; color: var(--color-text-dark); }

.form-input {
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: var(--font);
    color: var(--color-text-dark);
    background: var(--color-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0,168,232,0.12);
}
.form-input::placeholder { color: var(--color-text-light); }

.mt-md { margin-top: 1rem; }

/* ─── SUBJECTS ─── */
.subjects-input-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}
.subjects-input-row .form-input { flex: 1; }

.subjects-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 40px;
    padding: 0.5rem;
    border: 1.5px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: #fafbfc;
    margin-bottom: 0.75rem;
}

.subject-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full, 9999px);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: default;
    animation: popIn 0.15s ease;
}
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.subject-chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.subject-chip-remove:hover { opacity: 1; }

.subjects-presets {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}
.presets-label { color: var(--color-text-light); font-size: 0.8rem; }
.preset-btn {
    padding: 0.25rem 0.7rem;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full, 9999px);
    font-size: 0.78rem;
    cursor: pointer;
    color: var(--color-text-medium);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.preset-btn:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

/* ─── DAYS GRID ─── */
.days-grid {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.day-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-dark);
    background: var(--color-white);
    transition: all 0.15s;
    user-select: none;
}
.day-checkbox-label input { display: none; }
.day-checkbox-label.checked {
    border-color: var(--color-accent);
    background: rgba(0,168,232,0.08);
    color: var(--color-primary);
}
.day-tick {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.65rem;
    line-height: 14px;
    text-align: center;
    color: var(--color-accent);
    transition: all 0.15s;
}
.day-checkbox-label.checked .day-tick {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

/* ─── SLOT TYPE TOGGLE ─── */
.slot-type-toggle {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.slot-type-btn {
    flex: 1;
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.25rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-white);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}
.slot-type-btn:hover { border-color: var(--color-accent); }
.slot-type-btn.active {
    border-color: var(--color-accent);
    background: rgba(0,168,232,0.06);
}
.slot-type-icon { font-size: 1.5rem; flex-shrink: 0; }
.slot-type-btn strong { display: block; font-size: 0.95rem; color: var(--color-text-dark); }
.slot-type-btn small { display: block; font-size: 0.78rem; color: var(--color-text-medium); }

/* ─── SLOTS PANEL ─── */
.slots-panel { }

.slots-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--color-text-medium);
}

.slots-list { display: flex; flex-direction: column; gap: 0.5rem; }

.slot-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: #f9fafb;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    animation: popIn 0.15s ease;
}

.slot-row-label { font-size: 0.8rem; color: var(--color-text-light); width: 48px; flex-shrink: 0; }

.slot-row input[type="time"] {
    padding: 0.35rem 0.6rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.875rem;
    cursor: pointer;
    background: white;
    color: var(--color-text-dark);
    transition: border-color 0.2s;
}
.slot-row input[type="time"]:focus {
    outline: none;
    border-color: var(--color-accent);
}

.slot-separator { color: var(--color-text-light); font-size: 0.8rem; }

.slot-name-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.slot-remove {
    background: none;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    transition: color 0.15s;
}
.slot-remove:hover { color: var(--color-error); }

/* Irregular day tabs */
.irregular-day-tabs {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.irregular-tab {
    padding: 0.4rem 0.85rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--color-text-dark);
}
.irregular-tab.active {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: white;
}

/* ─── SETUP ACTIONS ─── */
.setup-actions {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.btn-generate { padding: 0.75rem 2rem; font-size: 1rem; }

/* ─── BUTTONS ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--color-accent); color: white; }
.btn-primary:not(:disabled):hover { background: var(--color-accent-hover); box-shadow: 0 4px 12px rgba(0,168,232,0.3); }

.btn-outline {
    background: white;
    color: var(--color-text-dark);
    border: 1.5px solid var(--color-border);
}
.btn-outline:hover { border-color: var(--color-accent); color: var(--color-accent); }
.btn-danger-outline {
    background: transparent;
    border-color: #fca5a5;
    color: #dc2626;
}
.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.btn-accent { background: var(--color-accent); color: white; }
.btn-accent:hover { background: var(--color-accent-hover); }

.btn-danger-outline {
    background: var(--color-danger-light);
    color: var(--color-error);
    border: 1.5px solid #fecaca;
}
.btn-danger-outline:hover { background: #fee2e2; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }

.badge-soon {
    font-size: 0.65rem;
    background: var(--color-warning);
    color: white;
    padding: 1px 6px;
    border-radius: var(--radius-full, 9999px);
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* ─── TIMETABLE SCREEN ─── */
.timetable-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.toolbar-left { display: flex; align-items: center; gap: 1rem; }
.toolbar-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.timetable-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

/* ─── TIMETABLE GRID ─── */
.timetable-wrapper {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.timetable-grid {
    display: grid;
    min-width: 640px;
}

/* Header row */
.tg-header-row {
    display: contents;
}

.tg-col-header {
    background: var(--color-primary);
    color: white;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.75rem 0.5rem;
    text-align: center;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-right: 1px solid rgba(255,255,255,0.1);
}
.tg-col-header:first-child {
    border-radius: var(--radius-xl) 0 0 0;
}
.tg-col-header:last-child {
    border-right: none;
    border-radius: 0 var(--radius-xl) 0 0;
}

/* Time slot label column */
.tg-time-cell {
    background: #f1f5f9;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 90px;
}

.tg-time-range {
    font-size: 0.68rem;
    color: var(--color-text-light);
    white-space: nowrap;
}

/* Subject cell */
.tg-cell {
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    min-height: 72px;
    padding: 0.5rem;
    cursor: pointer;
    transition: filter 0.15s, transform 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    background: #fafbfc;
}
.tg-cell:last-child { border-right: none; }
.tg-cell:hover { filter: brightness(0.94); transform: scale(0.98); }

.tg-cell.has-subject { background: var(--cell-color, #f0f9ff); }

.tg-cell-blocked {
    background: repeating-linear-gradient(
        135deg,
        #f1f5f9,
        #f1f5f9 4px,
        #e8edf2 4px,
        #e8edf2 8px
    ) !important;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.55;
}

.tg-cell-subject {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.3;
}

.tg-cell-note {
    font-size: 0.68rem;
    color: var(--color-text-medium);
    margin-top: 3px;
    font-style: italic;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tg-cell-empty-hint {
    font-size: 0.72rem;
    color: var(--color-text-light);
    opacity: 0;
    transition: opacity 0.15s;
}
.tg-cell:hover .tg-cell-empty-hint { opacity: 1; }

/* Last row rounded corners */
.tg-last-row .tg-time-cell {
    border-radius: 0 0 0 var(--radius-xl);
    border-bottom: none;
}
.tg-last-row .tg-cell:last-child {
    border-radius: 0 0 var(--radius-xl) 0;
    border-bottom: none;
}
.tg-last-row .tg-cell { border-bottom: none; }
.tg-last-row .tg-time-cell { border-bottom: none; }

/* ─── LEGEND ─── */
.timetable-legend {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.legend-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-dark);
}

.legend-label {
    flex: 1;
}

.legend-count {
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(0,0,0,0.07);
    color: var(--color-text-medium);
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    min-width: 1.3rem;
    text-align: center;
    line-height: 1.6;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

/* ─── SUBJECT GRID (modal) ─── */
.subject-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.subject-select-btn {
    padding: 0.4rem 0.9rem;
    border: 2px solid transparent;
    border-radius: var(--radius-full, 9999px);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.85;
}
.subject-select-btn:hover { opacity: 1; transform: translateY(-1px); }
.subject-select-btn.selected { border-color: var(--color-primary); opacity: 1; box-shadow: 0 2px 8px rgba(0,61,92,0.2); }

/* Special entries */
.subject-select-btn.special {
    background: #f1f5f9;
    color: var(--color-text-medium);
    border-color: var(--color-border);
}
.subject-select-btn.special:hover { background: #e2e8f0; }
.subject-select-btn.special.selected { border-color: var(--color-text-medium); }

/* ─── MODALS ─── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal.open { display: flex; }

/* Cell/PDF modals sit below sticky timetable header */
#modal-cell,
#modal-pdf {
    padding-top: 100px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background: var(--color-white);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    z-index: 1;
    animation: modalIn 0.2s ease;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}
@keyframes modalIn { from { transform: scale(0.94) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-cell-content { max-width: 560px; }

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

/* One-row heading: "Assign Class · Mon — 08:00–08:50" */
.modal-cell-heading-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-width: 0;
}

.modal-cell-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text-dark);
    white-space: nowrap;
}

.modal-cell-info {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--color-text-light);
    white-space: nowrap;
}

.modal-cell-title::after {
    content: " ·";
    color: var(--color-text-light);
    font-weight: 400;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--color-primary); }

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--color-text-dark); }

.modal-cell-info {
    font-size: 0.82rem;
    color: var(--color-text-medium);
    margin-bottom: 0.75rem;
    background: var(--color-background);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* ─── Privacy modal — wider content ─── */
#modal-privacy .modal-content {
    max-width: 680px;
    padding: 2rem;
    max-height: calc(100vh - 3rem);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1.25rem;
    padding-right: 2rem;
}

.modal-body {
    color: var(--color-text-dark);
    line-height: 1.7;
}

.modal-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.modal-body p {
    margin-bottom: 0.875rem;
}

.modal-body ul {
    margin: 0.5rem 0 0.875rem 1.5rem;
}

.modal-body li {
    margin-bottom: 0.35rem;
}

.modal-body a {
    color: var(--color-accent);
    text-decoration: none;
}

.modal-body a:hover {
    text-decoration: underline;
}

/* ─── TOAST ─── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.25s ease;
    pointer-events: auto;
    max-width: 320px;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-error); }
.toast.info { background: var(--color-accent); }
.toast.warning { background: var(--color-warning); }

/* ─── FOOTER ─── */
/* ─── RESPONSIVE ─── */
@media (max-width: 600px) {
    .setup-hero-title { font-size: 1.5rem; }
    .setup-card { padding: 1.25rem; }
    .timetable-toolbar { flex-direction: column; align-items: flex-start; }
    .toolbar-right { width: 100%; justify-content: flex-end; }
    .timetable-title { font-size: 1.1rem; }
    .slot-type-toggle { flex-direction: column; }
    .slot-type-btn { min-width: unset; }
}

/* ─── MODAL CELL — note at top, instant assign ─── */
.modal-note-group {
    margin-bottom: 1rem;
}

.modal-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-light);
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
}

.modal-group-label-special {
    margin-top: 1rem;
}

.modal-actions-cell {
    margin-top: 1.25rem;
    justify-content: flex-start;
}

/* Instant-assign: active state with checkmark */
.subject-select-btn.assigned {
    border-color: var(--color-primary) !important;
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0,61,92,0.2);
    position: relative;
}
.subject-select-btn.assigned::after {
    content: '✓';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 16px;
    text-align: center;
}

/* ─── STICKY BAR ─── */
.sticky-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: var(--color-primary);
    color: white;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 999px;
    flex-wrap: wrap;
    /* Floating — fixed above footer */
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    white-space: nowrap;
    animation: slideUp 0.2s ease;
}
.sticky-bar.active { display: flex; }

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(12px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

.sticky-bar-dot {
    width: 11px; height: 11px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.5);
}

.sticky-bar-subjects {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.sticky-bar-label {
    opacity: 0.85;
    font-weight: 400;
    font-size: 0.72rem;
    margin-right: 2px;
}

.sticky-bar-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(255,255,255,0.2);
    border: 1.5px solid rgba(255,255,255,0.35);
    white-space: nowrap;
}

.sticky-bar-cancel {
    display: flex; align-items: center; gap: 5px;
    border: 1.5px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.12);
    border-radius: 20px; padding: 3px 11px;
    font-family: inherit; font-size: 0.72rem; font-weight: 700;
    cursor: pointer; transition: background 0.15s; color: white;
    white-space: nowrap;
    margin-left: auto;
}
.sticky-bar-cancel:hover { background: rgba(255,255,255,0.22); }

/* ─── STICKY TOGGLE IN MODAL ─── */
.sticky-toggle {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; border-radius: 10px;
    border: 2px solid var(--color-border);
    cursor: pointer; margin-bottom: 8px;
    transition: all 0.2s; user-select: none;
    background: white;
}
.sticky-toggle:hover { border-color: var(--color-accent); background: rgba(0,168,232,0.03); }
.sticky-toggle.on { border-color: var(--color-accent); background: rgba(0,168,232,0.07); }

.sticky-toggle-check {
    width: 22px; height: 22px; border-radius: 6px;
    border: 2px solid var(--color-border); background: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; flex-shrink: 0; transition: all 0.2s;
}
.sticky-toggle.on .sticky-toggle-check {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.sticky-toggle-label { font-size: 0.78rem; font-weight: 700; color: var(--color-text-dark); display: block; }
.sticky-toggle-hint  { font-size: 0.68rem; color: var(--color-text-medium); display: block; margin-top: 1px; }

/* sticky-marked: subject has sticky enabled in modal */
.subject-select-btn.sticky-marked {
    outline: 2px dashed var(--color-accent);
    outline-offset: 2px;
}

.app-footer {
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
    padding: 20px;
    text-align: center;
    margin-top: 40px;
    border-radius: 8px 8px 0 0;
}

.app-footer p {
    margin: 0;
    color: var(--color-text-medium);
    font-size: 0.9rem;
}

.app-footer p + p {
    margin-top: 8px;
}

.footer-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}
.footer-link:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.footer-separator {
    margin: 0 8px;
    color: var(--color-text-light);
}

.version-badge {
    font-size: 0.75rem;
    color: var(--color-text-light);
    font-family: monospace;
    letter-spacing: 0.02em;
    opacity: 0.7;
}
/* ── PDF Export Modal ── */
.modal-pdf-content {
    max-width: 480px;
}

.pdf-school-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-dark);
    cursor: pointer;
    margin-bottom: 1rem;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color 0.15s;
}
.pdf-school-toggle:hover {
    border-color: var(--color-accent);
}
.pdf-school-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent);
    flex-shrink: 0;
}

.pdf-school-fields {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--color-background);
    animation: fadeIn 0.15s ease;
}

/* ── Draft resume section ── */
.draft-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.draft-label {
    font-size: 0.82rem;
    color: var(--color-text-medium);
    font-weight: 500;
    margin-bottom: 0.6rem;
}

.draft-container {
    /* wrapper */
}

.draft-card {
    background: var(--color-background);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    max-width: 520px;
}

.draft-card:hover {
    border-color: var(--color-accent);
    background: #e6f7ff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.draft-info { flex: 1; }

.draft-name {
    font-weight: 600;
    color: var(--color-text-dark);
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.draft-time {
    font-size: 0.78rem;
    color: var(--color-text-light);
}

.draft-delete {
    background: var(--color-danger, #dc2626);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.draft-card:hover .draft-delete { opacity: 1; }
.draft-delete:hover { background: #a02020; transform: scale(1.1); }

/* ── Cache refresh hint ── */
.cache-refresh-hint {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: #fff8e1;
    border: 1px solid #ffa726;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: #e65100;
    line-height: 1.6;
    text-align: center;
}

.cache-refresh-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    margin: 0 2px;
}

@media (max-width: 768px) {
    .cache-refresh-hint { font-size: 0.8rem; padding: 0.6rem 0.75rem; }
    .cache-refresh-hint kbd { font-size: 0.75rem; padding: 1px 4px; }
}

/* ── Sample hint ── */
.sample-hint {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--color-text-light);
    margin: 0.5rem 0 1rem;
}

.sample-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.15s;
}
.sample-link:hover { opacity: 0.75; text-decoration: underline; }

.sample-sep {
    color: var(--color-border);
}

/* ── SEO H1 — visible to crawlers, hidden from UI ── */
.seo-h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ════════════════════════════════════════
   ABOUT / HELP SECTION
════════════════════════════════════════ */
.about-section {
    margin-bottom: 1.75rem;
}

.about-toggle {
    width: 100%;
    background: linear-gradient(135deg, #e3f2fd 0%, #e1f5fe 100%);
    border: 1.5px solid #4fc3f7;
    border-radius: var(--radius-lg, 10px);
    padding: 1rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 600;
    color: #01579b;
    text-align: left;
    font-family: inherit;
}

.about-toggle:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #b3e5fc 100%);
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 168, 232, 0.15);
}

.about-icon { font-size: 1.2rem; flex-shrink: 0; }
.about-title { flex: 1; }

.toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}
.about-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.about-content {
    background: #fff;
    border: 1.5px solid #e3f2fd;
    border-top: none;
    border-radius: 0 0 var(--radius-lg, 10px) var(--radius-lg, 10px);
    padding: 1.75rem;
    margin-top: -8px;
    animation: aboutSlideDown 0.3s ease;
}

@keyframes aboutSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.about-content h2 {
    color: var(--color-primary);
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.about-content h3 {
    color: var(--color-primary);
    font-size: 1.05rem;
    margin-top: 1.5rem;
    margin-bottom: 0.875rem;
    font-weight: 600;
}

.about-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.75rem;
    margin-bottom: 1.75rem;
}

.about-column ul,
.about-column ol {
    margin: 0.875rem 0;
    padding-left: 1.5rem;
}

.about-column li {
    margin-bottom: 0.6rem;
    line-height: 1.6;
    color: var(--color-text-dark);
}

.about-column li strong { color: var(--color-primary); }

.how-to-steps {
    counter-reset: step-counter;
    list-style: none;
    padding-left: 0;
}

.how-to-steps li {
    counter-increment: step-counter;
    margin-bottom: 1.25rem;
    padding-left: 2.75rem;
    position: relative;
}

.how-to-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0; top: 0;
    background: var(--color-accent);
    color: white;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.how-to-steps li strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--color-primary);
}

.how-to-steps li p {
    margin: 0;
    line-height: 1.6;
    color: var(--color-text-medium);
}

.features-section {
    background: var(--color-background);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 0.875rem;
}

.feature-item {
    background: #fff;
    padding: 0.875rem;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--color-accent);
}

.feature-item strong {
    display: block;
    color: var(--color-primary);
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.feature-item p {
    margin: 0;
    font-size: 0.83rem;
    line-height: 1.5;
    color: var(--color-text-medium);
}

.use-cases-section { margin-top: 1.5rem; }

.use-cases-section ul {
    margin-top: 0.875rem;
    padding-left: 1.5rem;
}

.use-cases-section li {
    margin-bottom: 0.6rem;
    line-height: 1.6;
}

.use-cases-section li strong { color: var(--color-primary); }

.keywords-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-light);
}

.keywords-section p { margin: 0; line-height: 1.6; }

@media (max-width: 768px) {
    .about-grid { grid-template-columns: 1fr; gap: 1.25rem; }
    .about-content { padding: 1.25rem; }
    .features-grid { grid-template-columns: 1fr; }
    .about-toggle { font-size: 0.9rem; padding: 0.875rem 1rem; }
}
