:root {
    color-scheme: dark;
    --background: #151618;
    --surface: #1d1e21;
    --border: #424348;
    --text: #f3f3f5;
    --muted: #bcbcc3;
    --accent: #b4aaff;
    --track: #3b3d42;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-size: 15px;
}

a { color: inherit; text-decoration: none; }

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

h1, h2, h3, p { margin: 0; }

[lang="ja"] {
    font-family: "Yu Gothic", "Noto Sans CJK JP", Meiryo, sans-serif;
}

.topbar {
    border-bottom: 1px solid var(--border);
    background: #17181a;
}

.topbar-inner, .page {
    max-width: 1540px;
    margin-inline: auto;
    padding-inline: clamp(16px, 2.5vw, 38px);
}

.topbar-inner {
    display: flex;
    min-height: 68px;
    align-items: center;
    gap: 24px;
}

.brand {
    flex: none;
    border-right: 1px solid var(--border);
    padding-right: 24px;
}

.brand img { display: block; object-fit: contain; }

.navigation {
    display: flex;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
    align-self: stretch;
    align-items: stretch;
    gap: clamp(12px, 1.8vw, 28px);
}

.navigation > * {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    gap: 3px;
    padding-block: 10px;
    white-space: nowrap;
    color: var(--muted);
}

.navigation [lang="ja"] { font-size: 1rem; line-height: 1.25; }
.navigation small { color: var(--muted); font-size: 0.75rem; font-weight: 400; line-height: 1.25; }
.navigation a:focus-visible { outline-offset: -2px; }
.navigation a:hover, .navigation [aria-current] { color: var(--text); }

.navigation [aria-current] {
    font-weight: 650;
}

.navigation [aria-current]::after {
    position: absolute;
    inset: auto 0 0;
    height: 3px;
    background: var(--accent);
    content: "";
}

.study-reminder:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 16px;
    max-width: 1540px;
    margin-inline: auto;
    padding: 10px clamp(16px, 2.5vw, 38px);
    border-top: 1px solid var(--border);
    background: #252237;
}

.study-reminder p { margin: 0; }
.study-reminder a { white-space: nowrap; }

.topbar-account {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.avatar {
    display: grid;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    overflow: hidden;
    background: #2e2f33;
    font-size: 12px;
    font-weight: 650;
}

.avatar-image {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: cover;
}

.avatar span {
    max-width: 100%;
    overflow: hidden;
    font-family: "Yu Gothic", Meiryo, "Noto Sans CJK JP", sans-serif;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.avatar:hover, .avatar[aria-current="page"] {
    border-color: #74689c;
    background: #2e2546;
    color: #e2d9ff;
}

.notification-button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}

.notification-button:hover { border-color: var(--border); color: var(--text); }
.notification-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.notifications-dialog {
    width: min(405px, calc(100% - 32px));
    max-height: calc(100% - 92px);
    inset: 62px max(16px, calc((100vw - 1540px) / 2 + 38px)) auto auto;
    margin: 0;
    padding: 12px 16px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 12px 32px #0007;
}

.notifications-dialog::backdrop { background: #0a0a0c66; }
.notifications-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.notifications-heading h2 { font-size: 1.1rem; }
.notifications-heading .notification-button { font-size: 1.35rem; line-height: 1; }
.notifications-list { margin: 4px 0 0; padding: 0; list-style: none; }
.notifications-list li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 3px 10px;
    align-items: center;
    padding-block: 10px;
    border-top: 1px solid var(--border);
    overflow-wrap: anywhere;
}
.notifications-list a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.notifications-list .icon { color: var(--accent); }
.notifications-list time { grid-column: 2; color: var(--muted); font-size: 0.8rem; }
.notifications-status { padding-block: 10px 3px; color: var(--muted); }

.page { padding-block: 42px 64px; }
.dashboard > section + section { margin-top: 44px; }

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.section-heading h2, .inner-page h1 {
    font-size: clamp(20px, 2.05vw, 30px);
    font-weight: 670;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.text-link {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    color: var(--accent);
    font-weight: 550;
    white-space: nowrap;
}

.text-link:hover { text-decoration: underline; }

.card-grid { display: grid; gap: 12px; }
.six-columns { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.four-columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

a.card:hover {
    border-color: #777580;
    background: #232428;
}

.recent-empty {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 112px;
    align-items: center;
    gap: 12px 16px;
    padding: 20px;
}

.recent-empty p + p { margin-top: 5px; }
.recent-empty .text-link { justify-self: start; }
.recent-empty-icon {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 8px;
    background: #302b42;
    color: var(--accent);
}

.participant-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
    gap: 10px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.participant-link { display: flex; align-items: center; gap: 10px; height: 100%; padding: 10px; }
.participant-link strong { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.participant-link small { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.participant-avatar {
    display: grid;
    flex: 0 0 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    overflow: hidden;
    background: #2e2546;
    color: #e2d9ff;
    font-family: "Yu Gothic", Meiryo, "Noto Sans CJK JP", sans-serif;
}
.participant-avatar span { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.assignment-card {
    display: flex;
    flex-direction: column;
    padding: 4px;
}

.paper {
    color-scheme: light;
    background: #e5e5e7;
    color: #141517;
}

.document-preview {
    height: clamp(145px, 13.4vw, 206px);
    overflow: hidden;
    padding: 11px 9px;
    border: 1px solid #b9b9bf;
    border-radius: 6px;
    font-size: clamp(10px, 0.87vw, 13px);
    line-height: 1.5;
}

.document-title {
    margin-bottom: 8px;
    font-size: 1.18em;
    line-height: 1.35;
}

.instructions { margin-bottom: 0.55em; }
.assignment-word-bank { margin-bottom: 0.55em; font-weight: 650; overflow-wrap: anywhere; }

.reading {
    padding: 0.55em;
    border: 1px solid #c1c1c5;
    border-radius: 4px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.exercise { margin: 0; padding-left: 1.5em; }
.exercise li + li { margin-top: 0.42em; }

.assignment-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px 13px;
}

.assignment-info h3, .achievement-card h2, .achievement-card h3 {
    font-size: clamp(13px, 1.05vw, 16px);
    font-weight: 610;
    line-height: 1.25;
}

.progress-row {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

progress {
    appearance: none;
    display: block;
    width: 100%;
    min-width: 0;
    height: 7px;
    overflow: hidden;
    border: 0;
    border-radius: 99px;
    background: var(--track);
}

progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.achievement-card {
    display: flex;
    flex-direction: column;
    padding: 14px 16px 16px;
}

.achievement-card h2, .achievement-card h3 { display: flex; align-items: center; gap: 8px; }
.achievement-card h2, .achievement-card h3, .achievement-card p { overflow-wrap: anywhere; }
.achievement-card p { margin: 16px 0 7px; color: var(--muted); font-size: 13px; }
.achievement-group + .achievement-group { margin-top: 28px; }
.achievement-group > h2 { margin-bottom: 12px; font-size: 18px; }
.achievement-list { margin: 0; padding: 0; list-style: none; }
.achievement-list > li { display: flex; min-width: 0; }
.achievement-list .achievement-card { flex: 1; }
.achievement-list p + p { margin-top: 0; }
.achievement-condition-preview {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.achievement-status { margin-top: 8px; }

.icon-library { display: none; }

.icon {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topic-card {
    display: flex;
    min-height: 145px;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 18px clamp(14px, 1.65vw, 26px);
    font-size: clamp(14px, 1.22vw, 18px);
}

.topic-symbol {
    display: block;
    font-size: clamp(29px, 3.2vw, 49px);
    font-weight: 550;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.inner-page { max-width: 1060px; }
.inner-page h1 { margin-bottom: 22px; }
.back-link { margin-bottom: 16px; }
.detail-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.muted, .empty-state { color: var(--muted); }
.empty-state { grid-column: 1 / -1; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li + li { margin-top: 10px; }

.list-card {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
}

.list-card .muted { white-space: nowrap; }
.detail-progress { max-width: 360px; margin-bottom: 16px; }
.detail-progress label { white-space: nowrap; }

.achievement-detail h1 { display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.achievement-detail-card {
    display: grid;
    max-width: 720px;
    gap: 12px;
    padding: clamp(16px, 4vw, 28px);
}
.achievement-detail-card + .achievement-detail-card { margin-top: 12px; }
.achievement-detail-card h2 { font-size: 17px; }
.achievement-detail-card progress { max-width: 280px; }
.achievement-condition { line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

.full-document, .topic-note {
    max-width: 720px;
    padding: clamp(16px, 4vw, 32px);
    border-radius: 10px;
    font-size: 16px;
    line-height: 1.65;
}

.full-document .document-title { margin-bottom: 18px; }
.assignment-document { overflow-wrap: anywhere; }
.assignment-questions { margin-block: 16px 20px; }
.assignment-questions li + li { margin-top: 12px; }
.assignment-separate-answer { display: grid; justify-items: start; gap: 4px; }
.assignment-answer {
    width: 11em;
    max-width: 100%;
    min-height: 40px;
    padding: 4px 8px;
    border: 1px solid #76767f;
    border-radius: 4px;
    background: #f8f8fa;
    color: inherit;
    font-size: 1em;
}
.assignment-separate-answer .assignment-answer { width: 23em; }
.assignment-button {
    display: inline-block;
    min-height: 40px;
    padding: 7px 13px;
    border: 1px solid #414047;
    border-radius: 6px;
    background: #2e2f33;
    color: #f3f3f5;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}
.assignment-button:hover { background: #414047; }
.assignment-answer:focus-visible, .assignment-button:focus-visible { outline: 2px solid #5a4594; outline-offset: 2px; }
.assignment-result { margin-top: 20px; }
.assignment-result h2 { font-size: 1.125em; }
.assignment-feedback.correct { color: #205c42; }
.assignment-feedback.incorrect { color: #822f2f; }
.topic-note > p { margin-top: 12px; white-space: pre-line; }
.topic-note blockquote { margin: 18px 0 0; padding-left: 14px; border-left: 2px solid var(--accent); }

.word-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.word-search input, .word-search select, .word-search button {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.word-search input { flex: 0 1 300px; min-width: 0; }
.word-search select {
    appearance: none;
    max-width: 100%;
    padding-right: 30px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: right 16px center, right 11px center;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}
.word-search button { cursor: pointer; }
.word-search button:hover { background: #232428; }
.word-search :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.word-card { min-height: 120px; justify-content: flex-start; gap: 4px; }
.word-card .topic-symbol { font-size: clamp(22px, 2.3vw, 34px); }
.word-card-reading, .word-card-translation { font-size: 0.875rem; overflow-wrap: anywhere; }
.word-card-translation { margin-top: 4px; }
.word-card-status { margin-top: auto; padding-top: 6px; font-size: 0.875rem; }

.word-pagination { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; }

.word-detail { overflow-wrap: anywhere; }
.word-detail h1 { font-size: clamp(30px, 4vw, 46px); }
.word-meaning, .word-quotes { max-width: 720px; }
.word-meaning, .word-quote { padding: clamp(16px, 3vw, 24px); line-height: 1.6; }
.word-meaning dl { margin: 0; }
.word-meaning dt { font-weight: 650; }
.word-meaning dd { margin: 4px 0 0; }
.word-meaning dd + dt { margin-top: 14px; }
.word-meaning dd ul { margin: 0; padding-left: 20px; }

.study-status { margin-top: 18px; max-width: 28rem; }
.study-status fieldset { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.study-status legend { margin-bottom: 8px; padding: 0; font-weight: 650; }

.study-status-switch {
    --switch-columns: 3;
    --switch-inset: 4px;
    --switch-offset: 0%;
    --switch-fill: #373840;
    --switch-edge: #54565f;
    --switch-text: var(--text);
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: repeat(var(--switch-columns), minmax(0, 1fr));
    padding: var(--switch-inset);
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.study-status-switch[data-options="2"] { --switch-columns: 2; }
.study-status-switch[data-options="4"] { --switch-columns: 4; }

.study-status-switch[data-status="learning"] {
    --switch-offset: 100%;
    --switch-fill: #463961;
    --switch-edge: #6c5b90;
    --switch-text: #f1eaff;
}

.study-status-switch:is([data-status="known"], [data-status="mastered"]) {
    --switch-offset: calc((var(--switch-columns) - 1) * 100%);
    --switch-fill: #253e34;
    --switch-edge: #436b57;
    --switch-text: #c7efda;
}

.study-status-switch[data-options="4"][data-status="known"] { --switch-offset: 200%; }

.study-status-switch::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: var(--switch-inset) auto var(--switch-inset) var(--switch-inset);
    width: calc((100% - 2 * var(--switch-inset)) / var(--switch-columns));
    border-radius: inherit;
    background: var(--switch-fill);
    box-shadow: inset 0 0 0 1px var(--switch-edge);
    transform: translateX(var(--switch-offset));
    transition: transform 280ms cubic-bezier(.22, .75, .25, 1), background-color 220ms, box-shadow 220ms;
}

.study-status-switch button {
    min-height: 44px;
    padding: 6px 8px;
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 650;
    line-height: 1.2;
    cursor: pointer;
    transition: color 180ms;
}

.study-status-switch button:hover { color: var(--text); }
.study-status-switch button[aria-pressed="true"] { color: var(--switch-text); }
.study-status-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.study-status-feedback { margin: 0; color: #f4b6ab; font-size: 0.875rem; }
.study-status-feedback:not(:empty) { margin-top: 8px; }

@media (max-width: 420px) {
    .study-status-switch[data-options="4"] { --switch-columns: 2; border-radius: 12px; }
    .study-status-switch[data-options="4"]::before { display: none; }
    .study-status-switch[data-options="4"] button { border-radius: 8px; }
    .study-status-switch[data-options="4"] button[aria-pressed="true"] {
        background: var(--switch-fill);
        box-shadow: inset 0 0 0 1px var(--switch-edge);
    }
}

@media (prefers-reduced-motion: reduce) {
    .study-status-switch::before, .study-status-switch button { transition: none; }
}

@media (forced-colors: active) {
    .study-status-switch button[aria-pressed="true"] { border: 1px solid Highlight; }
}

.word-quotes { margin-top: 26px; }
.word-quotes h2 { margin-bottom: 12px; font-size: 1.125rem; }
.word-quote { margin: 0 0 12px; }
.word-quote blockquote {
    margin: 0 0 12px;
    padding-left: 12px;
    border-left: 2px solid var(--accent);
    font-size: 1.125rem;
    white-space: pre-wrap;
}

.word-quote mark {
    padding: 0.08em 0.15em;
    border-radius: 3px;
    background: #3d3461;
    color: #eee8ff;
    font-weight: 700;
}

.word-quote cite { display: block; font-style: normal; }

.topic-studied-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #9cd7b0;
    font-size: 0.875rem;
    font-weight: 600;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .six-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .document-preview { height: 160px; font-size: 12px; }
}

@media (max-width: 940px) {
    .topbar-inner { flex-wrap: wrap; gap: 0; padding-top: 10px; }
    .brand { border: 0; padding: 0; }
    .navigation {
        order: 1;
        width: 100%;
        overflow-x: auto;
        gap: 16px;
    }
    .avatar { flex-basis: 30px; width: 30px; height: 30px; }
    .notifications-dialog { top: 48px; }
}

@media (max-width: 640px) {
    .page { padding-block: 28px 44px; }
    .dashboard > section + section { margin-top: 30px; }
    .six-columns, .four-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section-heading { align-items: flex-start; gap: 8px; margin-bottom: 14px; }
    .section-heading .text-link { font-size: 13px; }
    .recent-empty { grid-template-columns: auto minmax(0, 1fr); }
    .recent-empty .text-link { grid-column: 2; }
    .document-preview { height: 145px; padding: 8px 6px; font-size: 10px; }
    .achievement-card { padding: 12px; }
    .topic-card { min-height: 110px; }
    .word-search input { flex: 1 1 160px; }
}
