:root {
  color-scheme: light;
  --ink: #18231f;
  --muted: #75817c;
  --line: #dfe7e2;
  --paper: #fffefa;
  --mist: #f3f7f2;
  --green: #0b7966;
  --green-dark: #075a4d;
  --green-soft: #ddefe9;
  --amber: #efb15f;
  --shadow: 0 22px 60px rgba(38, 66, 56, 0.12);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: radial-gradient(circle at 82% 12%, #e5f1ed 0, transparent 28rem), var(--mist); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar { position: relative; z-index: 60; height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 4vw; border-bottom: 1px solid rgba(24, 35, 31, .08); background: rgba(255, 254, 250, .78); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; color: white; background: var(--green); font-family: "Hiragino Mincho ProN", serif; font-size: 23px; box-shadow: 0 8px 18px rgba(11,121,102,.24); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: .02em; }
.brand small { color: var(--muted); margin-top: 2px; }
.api-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a4aca8; box-shadow: 0 0 0 4px rgba(164,172,168,.12); }
.api-status.online .status-dot { background: #25a886; box-shadow: 0 0 0 4px rgba(37,168,134,.13); }
.api-status.offline .status-dot { background: #d36b5f; }
.topbar-actions { position: relative; display: flex; align-items: center; gap: 16px; }
.auth-control { position: relative; }
.auth-trigger { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--green-dark); background: rgba(255,255,255,.86); font-size: 12px; font-weight: 750; }
.auth-trigger:hover, .auth-trigger[aria-expanded="true"] { border-color: #b8d9cd; background: white; }
.auth-avatar, .auth-profile-avatar { width: 28px; height: 28px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: white; background: var(--green); font-size: 11px; }
.auth-avatar img, .auth-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.auth-popover { position: absolute; z-index: 50; top: calc(100% + 10px); right: 0; width: 290px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 20px 55px rgba(24,35,31,.2); }
.auth-popover strong { font-size: 14px; }
.auth-popover > div > p { margin: 8px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }
#google-signin-slot { min-height: 40px; }
.auth-error { color: #b64e44 !important; }
.auth-profile { display: flex; align-items: center; gap: 10px; }
.auth-profile-avatar { width: 38px; height: 38px; flex: 0 0 auto; }
.auth-profile p { min-width: 0; margin: 0; }
.auth-profile strong, .auth-profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-profile small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.auth-sync-note { padding: 9px 10px; border-radius: 10px; color: var(--green-dark) !important; background: var(--green-soft); }
.auth-signout { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: white; font-size: 12px; font-weight: 700; }

.workspace { min-height: calc(100vh - 82px); display: grid; grid-template-columns: minmax(290px, 340px) 1fr; transition: grid-template-columns .22s ease; }
.workspace.sidebar-collapsed { grid-template-columns: 64px 1fr; }
.sidebar { padding: 16px 24px 20px 4vw; border-right: 1px solid var(--line); background: rgba(247,250,247,.72); }
.sidebar-toggle { align-self: flex-end; display: flex; align-items: center; gap: 6px; min-height: 32px; margin: 0 0 10px auto; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--green-dark); background: rgba(255,255,255,.82); font-size: 12px; font-weight: 700; }
.sidebar-toggle > span:first-child { font-size: 20px; line-height: 1; }
.sidebar.collapsed { padding: 16px 12px; }
.sidebar.collapsed > :not(.sidebar-toggle) { display: none; }
.sidebar.collapsed .sidebar-toggle { align-self: center; width: 40px; justify-content: center; margin-bottom: 0; padding: 0; }
.sidebar.collapsed .sidebar-toggle-label { display: none; }
.book-card { width: 100%; display: flex; gap: 14px; align-items: center; padding: 17px; border: 1px solid var(--line); border-radius: 20px; color: inherit; background: rgba(255,255,255,.72); text-align: left; transition: border-color .18s ease, background-color .18s ease, transform .18s ease; }
.book-card:hover { border-color: #b8d9cd; background: white; transform: translateY(-1px); }
.book-card > div:nth-child(2) { min-width: 0; }
.book-card-chevron { margin-left: auto; color: var(--green); font-size: 18px; }
.book-icon { flex: 0 0 54px; width: 54px; height: 64px; display: grid; place-items: center; border-radius: 8px 13px 13px 8px; color: #fff; background: linear-gradient(145deg, #127b67, #064f43); font-weight: 800; letter-spacing: .04em; box-shadow: inset 6px 0 rgba(255,255,255,.12), 0 8px 20px rgba(11,121,102,.2); }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.book-card h1 { margin: 0; font-size: 17px; }
.book-card p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.session-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.session-summary div { display: grid; gap: 2px; text-align: center; }
.session-summary div + div { border-left: 1px solid var(--line); }
.session-summary strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.session-summary span { color: var(--muted); font-size: 11px; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 13px; height: 42px; border: 1px solid transparent; border-radius: 13px; background: #e9efeb; color: var(--muted); }
.search-box:focus-within { border-color: rgba(11,121,102,.35); background: white; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.word-list { margin-top: 12px; height: calc(100vh - 395px); min-height: 260px; overflow: auto; scrollbar-width: thin; }
.word-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 13px; border: 0; border-radius: 13px; text-align: left; background: transparent; color: var(--ink); }
.word-item:hover { background: rgba(255,255,255,.72); }
.word-item.active { background: white; box-shadow: 0 8px 22px rgba(38,66,56,.08); }
.word-item .main { display: grid; gap: 3px; }
.word-item strong { font-size: 16px; }
.word-item small { color: var(--muted); }
.word-item .arrow { color: #a0aaa5; }
.word-item.rated::after { content: "✓"; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--green); background: var(--green-soft); font-size: 11px; }
.skeleton-list { display: grid; gap: 9px; }
.skeleton-list i, .skeleton-shape { background: linear-gradient(90deg,#e8eeea 25%,#f7f9f7 50%,#e8eeea 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton-list i { height: 52px; border-radius: 13px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.pagination { display: flex; align-items: center; justify-content: flex-start; gap: 7px; padding-top: 14px; color: var(--muted); font-size: 12px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); }
.icon-button:disabled, .page-go:disabled { opacity: .4; cursor: default; }
.page-jump { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.page-jump input { width: 48px; height: 34px; padding: 0 5px; border: 1px solid var(--line); border-radius: 9px; outline: 0; color: var(--ink); background: white; text-align: center; font-variant-numeric: tabular-nums; }
.page-jump input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,121,102,.1); }
.page-go { height: 34px; padding: 0 9px; border: 1px solid #b8d9cd; border-radius: 9px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 700; }

.study-stage { display: flex; flex-direction: column; min-width: 0; padding: 30px clamp(20px,3vw,48px) 112px; }
.stage-meta { display: flex; align-items: center; justify-content: space-between; max-width: 1200px; width: 100%; margin: 0 auto 14px; color: var(--muted); font-size: 12px; }
.mode-selector { display: flex; align-items: center; gap: 9px; }
.stage-meta, .mode-selector { flex-wrap: wrap; gap: 9px; }
.mode-switch { flex-shrink: 0; }
.mode-chip { padding: 6px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.mode-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.66); }
.mode-switch button { padding: 5px 10px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 11px; }
.mode-switch button.active { color: white; background: var(--green); box-shadow: 0 4px 10px rgba(11,121,102,.18); }
.autoplay-toggle { display: flex; align-items: center; gap: 7px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.66); font-size: 11px; }
.toggle-track { width: 27px; height: 16px; padding: 2px; border-radius: 999px; background: #c8d0cc; transition: .2s ease; }
.toggle-track i { display: block; width: 12px; height: 12px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(24,35,31,.2); transition: .2s ease; }
.autoplay-toggle.active { color: var(--green-dark); border-color: #b8d9cd; }
.autoplay-toggle.active .toggle-track { background: var(--green); }
.autoplay-toggle.active .toggle-track i { transform: translateX(11px); }
.study-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; align-items: start; gap: 20px; max-width: 1200px; width: 100%; margin: 0 auto; }
.word-card { min-width: 0; width: 100%; min-height: 590px; padding: clamp(28px,4vw,54px); border: 1px solid rgba(255,255,255,.9); border-radius: 30px; background: rgba(255,254,250,.88); box-shadow: var(--shadow); }
.skeleton-shape { display: block; height: 14px; border-radius: 999px; }
.word-loading { min-height: 480px; }
.word-loading-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.word-loading-title { width: 38%; max-width: 220px; height: 68px; border-radius: 14px; }
.word-loading-audio { width: 112px; height: 38px; }
.word-loading-reading { width: 118px; height: 16px; margin-top: 14px; }
.word-loading-divider { height: 1px; margin: 28px 0 26px; background: var(--line); }
.word-loading-meaning { display: flex; align-items: center; gap: 12px; }
.word-loading-meaning i:first-child { width: 48px; height: 27px; border-radius: 7px; }
.word-loading-meaning i:last-child { width: 42%; height: 24px; }
.word-loading-line { width: 82%; margin-top: 22px; }
.word-loading-line.short { width: 58%; margin-top: 12px; }
.word-loading-line.medium { width: 70%; margin-top: 12px; }
.word-loading-sentence { margin-top: 32px; padding: 24px; border-radius: 20px; background: #f1f6f2; }
.word-loading-label { width: 92px; height: 18px; }
.word-loading-sentence .word-loading-line { margin-top: 24px; }
.association-panel { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; padding: 22px 18px; border: 1px solid rgba(255,255,255,.9); border-radius: 24px; background: rgba(255,254,250,.82); box-shadow: 0 16px 42px rgba(38,66,56,.09); scrollbar-width: thin; }
.association-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.association-heading h2 { margin: 0; font-size: 17px; }
.association-heading > span { max-width: 92px; overflow: hidden; padding: 4px 8px; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.association-loading { margin: 20px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.association-skeleton { display: grid; gap: 11px; padding-top: 20px; }
.association-skeleton-title { width: 82px; height: 16px; margin-bottom: 2px; }
.association-skeleton-title.short { width: 58px; margin-top: 12px; }
.association-skeleton > div:not(.association-skeleton-grid) { padding: 12px; border: 1px solid #e5ece8; border-radius: 12px; }
.association-skeleton > div:not(.association-skeleton-grid) i:first-child { width: 78%; }
.association-skeleton > div:not(.association-skeleton-grid) i:last-child { width: 55%; height: 10px; margin-top: 8px; }
.association-skeleton-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.association-skeleton-grid i { height: 52px; border-radius: 11px; }
.association-content { display: grid; gap: 24px; padding-top: 18px; }
.association-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.association-title h3 { margin: 0; font-size: 13px; }
.association-title span { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 10px; }
.phrase-list, .related-list { display: grid; gap: 8px; }
.phrase-item { padding: 10px; border: 1px solid #e2eae5; border-radius: 12px; background: rgba(255,255,255,.65); }
.phrase-item strong, .phrase-item span { display: block; }
.phrase-item strong { font-size: 14px; line-height: 1.45; }
.phrase-item span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.related-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.related-item { min-width: 0; padding: 9px; border-radius: 11px; background: #f0f5f1; }
.related-item strong, .related-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.related-item strong { color: var(--green-dark); font-size: 13px; }
.related-item span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.association-empty { color: var(--muted); font-size: 11px; line-height: 1.6; }
.word-list:focus-visible, .study-stage:focus-visible, .association-panel:focus-visible { outline: 2px solid rgba(11,121,102,.32); outline-offset: -2px; }
.empty-state { min-height: 470px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); }
.empty-state h2 { margin: 20px 0 7px; color: var(--ink); }
.empty-state p { margin: 0; }
.empty-kanji { width: 96px; height: 96px; display: grid; place-items: center; border: 1px solid #d3e3dc; border-radius: 50%; color: var(--green); background: var(--green-soft); font: 42px/1 "Hiragino Mincho ProN", serif; }
.word-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.word-line { display: flex; align-items: flex-start; gap: 10px; }
.word-line h2 { margin: 0; font: 700 clamp(42px,6vw,72px)/1.05 "Hiragino Mincho ProN", "Yu Mincho", serif; letter-spacing: .04em; }
.pitch { color: var(--green); font-size: 18px; }
.reading { margin: 12px 0 0; color: var(--muted); font-size: 16px; letter-spacing: .06em; }
.reveal-panel { min-height: 340px; display: grid; place-content: center; justify-items: center; gap: 16px; }
.prompt { color: var(--muted); }
.primary-button, .secondary-button { min-height: 48px; padding: 0 24px; border-radius: 999px; font-weight: 750; }
.primary-button { border: 0; background: var(--green); color: white; box-shadow: 0 10px 24px rgba(11,121,102,.2); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: white; }
.meaning-panel { padding-top: 26px; }
.meaning-row { display: flex; align-items: center; gap: 12px; font-size: 21px; }
.part-of-speech { flex: 0 0 auto; padding: 5px 9px; border-radius: 7px; color: var(--green-dark); background: var(--green-soft); font-size: 12px; font-weight: 700; }
.notes { margin: 22px 0 0; display: grid; gap: 12px; }
.notes div { display: grid; grid-template-columns: 56px 1fr; gap: 10px; }
.notes dt { color: var(--green); font-size: 12px; font-weight: 800; }
.notes dd { margin: 0; line-height: 1.65; }
.sentence-section { margin-top: 30px; padding: 24px; border-radius: 20px; background: #f1f6f2; }
.section-title { display: flex; justify-content: space-between; align-items: start; }
.section-title h3 { margin: 0; font-size: 17px; }
.section-title > span { padding: 4px 8px; border: 1px solid #b8dccd; border-radius: 99px; color: var(--green); font-size: 11px; }
.sentence-loading { padding: 30px 0; color: var(--muted); }
.sentence-skeleton { margin-top: 18px; padding: 15px; border: 1px solid #dce9e2; border-radius: 15px; background: rgba(255,255,255,.6); }
.sentence-skeleton-head { display: flex; justify-content: space-between; }
.sentence-skeleton-head i:first-child { width: 76px; height: 12px; }
.sentence-skeleton-head i:last-child { width: 32px; height: 12px; }
.sentence-skeleton-tokens { display: flex; align-items: end; gap: 8px; margin-top: 18px; }
.sentence-skeleton-tokens i { width: 15%; min-width: 46px; height: 34px; border-radius: 7px; }
.sentence-skeleton-tokens i:nth-child(2) { width: 22%; }
.sentence-skeleton-tokens i:nth-child(3) { width: 12%; }
.sentence-skeleton-translation { width: 58%; height: 12px; margin-top: 15px; }
#sentence-content { margin: 14px -12px -8px; padding: 8px 12px 10px; border-radius: 14px; transition: background-color .2s ease, box-shadow .2s ease; }
#sentence-content.is-playing { background: rgba(221,239,233,.58); box-shadow: inset 3px 0 rgba(11,121,102,.5); }
.token-line { display: flex; flex-wrap: wrap; align-items: end; gap: 4px 8px; margin-top: 22px; }
.token { display: inline-grid; justify-items: center; min-width: 24px; padding: 4px 2px; border-radius: 6px; }
.token small { min-height: 14px; color: var(--muted); font-size: 9px; }
.token strong { font: 600 20px/1.2 "Hiragino Mincho ProN", serif; }
.token.matched { color: var(--green-dark); background: rgba(221,239,233,.8); }
.sentence-cn { margin: 16px 0 0; color: #48534f; }
.sentence-actions { display: flex; gap: 14px; margin-top: 18px; }
.text-button { padding: 0; border: 0; background: none; color: var(--green); font-weight: 700; }
.sentence-play-button { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; padding: 0 0 0 2px; border: 1px solid #b8dccd; border-radius: 50%; color: white; background: var(--green); box-shadow: 0 5px 12px rgba(11,121,102,.16); font-size: 10px; }
.sentence-play-button:hover { background: var(--green-dark); }
.all-sentences { display: grid; gap: 14px; margin-top: 18px; }
.beginner-sentence { padding: 13px 15px; border: 1px solid #dce9e2; border-radius: 15px; background: rgba(255,255,255,.7); transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease; }
.beginner-sentence.is-playing { border-color: rgba(11,121,102,.28); background: rgba(221,239,233,.58); box-shadow: inset 3px 0 rgba(11,121,102,.5); }
.beginner-sentence header { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.beginner-sentence .sentence-header-actions { display: flex; align-items: center; gap: 9px; }
.beginner-sentence .sentence-number { color: var(--green); font-weight: 800; letter-spacing: .08em; }
.beginner-sentence .token-line { margin-top: 8px; }
.beginner-sentence .sentence-cn { margin-top: 8px; }
.study-actions { position: fixed; z-index: 20; left: var(--study-actions-center, 50vw); bottom: 18px; transform: translateX(-50%); display: flex; justify-content: center; gap: 12px; width: var(--study-actions-width, min(560px, calc(100vw - 28px))); pointer-events: none; }
.study-actions button { min-width: 180px; pointer-events: auto; box-shadow: 0 10px 28px rgba(38,66,56,.16); }
.next-button { min-width: 230px !important; }
.shortcut-hint { margin: 13px auto 0; color: var(--muted); font-size: 11px; text-align: center; }
.shortcut-hint kbd { display: inline-grid; place-items: center; min-width: 22px; height: 20px; margin-right: 4px; border: 1px solid #d6dfda; border-bottom-width: 2px; border-radius: 6px; color: var(--green-dark); background: white; font: 11px/1 inherit; }
.privacy-note { margin: 14px auto 0; color: #8a938f; font-size: 11px; text-align: center; }
.quick-mode .study-actions { display: none !important; }
.quick-study { width: 100%; max-width: 1200px; margin: 0 auto; }
.quick-header { position: sticky; top: -30px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: 0 8px 24px rgba(38,66,56,.06); }
.quick-header h2 { margin: 0; font-size: 22px; }
.quick-header p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.quick-header button { flex-shrink: 0; }
.quick-header button:disabled { opacity: .5; cursor: default; box-shadow: none; }
.quick-header-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.quick-group-button { min-width: 118px; min-height: 44px; padding: 0 18px; }
.quick-history-button { min-height: 44px; display: flex; align-items: center; gap: 7px; padding: 0 15px; border: 1px solid #b8d9cd; border-radius: 999px; color: var(--green-dark); background: white; font-size: 12px; font-weight: 750; }
.quick-history-button span { display: grid; place-items: center; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 999px; color: white; background: var(--green); font-size: 10px; }
.quick-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; margin-top: 16px; }
.quick-word { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,254,250,.9); scroll-margin-top: 124px; }
.quick-word-heading { display: flex; align-items: center; gap: 12px; }
.quick-number { flex-shrink: 0; color: #98a79f; font-size: 11px; font-variant-numeric: tabular-nums; }
.quick-word-copy { flex: 1; min-width: 0; }
.quick-word-copy h3 { margin: 0; overflow-wrap: anywhere; font: 700 25px/1.4 "Hiragino Mincho ProN", "Yu Mincho", serif; }
.quick-word-copy p { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.quick-word-actions { flex-shrink: 0; display: flex; align-items: center; gap: 7px; }
.quick-word-audio:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.quick-reveal { flex-shrink: 0; min-height: 40px; padding: 0 12px; border: 1px solid #b8d9cd; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-size: 12px; font-weight: 700; }
.quick-reveal:hover, .quick-reveal[aria-expanded="true"] { border-color: var(--green); background: #cfe8de; }
.quick-reveal:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.quick-detail { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.quick-meaning-row { display: flex; align-items: center; gap: 10px; font-size: 16px; line-height: 1.7; }
.quick-notes { display: grid; gap: 9px; margin: 14px 0 0; }
.quick-notes div { display: grid; grid-template-columns: 46px 1fr; gap: 8px; }
.quick-notes dt { color: var(--green); font-size: 11px; font-weight: 800; }
.quick-notes dd { margin: 0; font-size: 13px; line-height: 1.7; }
.quick-sentences { display: grid; gap: 10px; margin-top: 18px; }
.quick-sentences-title { display: flex; align-items: center; justify-content: space-between; }
.quick-sentences-title strong { color: var(--muted); font-size: 11px; }
.quick-sentence { margin-top: 12px; padding: 14px; border-radius: 12px; background: #f1f6f2; }
.quick-sentence header { display: flex; align-items: center; justify-content: space-between; color: var(--green); font-size: 11px; font-weight: 800; }
.quick-sentence .token-line { margin-top: 8px; }
.quick-sentence p { margin: 8px 0 0; line-height: 1.7; }
.quick-sentence .sentence-cn, .quick-sentence-status { color: var(--muted); font-size: 12px; }
.quick-empty, .quick-list > .skeleton-list { grid-column: 1 / -1; }
.quick-empty { padding: 30px 16px; color: var(--muted); text-align: center; }
.quick-history-dialog { width: min(680px, calc(100vw - 28px)); height: min(760px, calc(100vh - 36px)); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 28px 90px rgba(24,35,31,.28); }
.quick-history-dialog::backdrop { background: rgba(24,35,31,.34); backdrop-filter: blur(5px); }
.quick-history-panel { height: 100%; display: flex; flex-direction: column; min-height: 0; padding: 24px; }
.quick-history-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.quick-history-header h2 { margin: 0; font-size: 24px; }
.quick-history-header p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.quick-history-list { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 8px; padding: 16px 4px 0 0; scrollbar-width: thin; }
.quick-history-item { width: 100%; display: grid; grid-template-columns: minmax(100px,.7fr) minmax(140px,1.3fr) auto; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; color: inherit; background: white; text-align: left; }
.quick-history-item:hover { border-color: #b8d9cd; background: #f7faf8; }
.quick-history-word strong, .quick-history-word small { display: block; }
.quick-history-word strong { font: 700 19px/1.35 "Hiragino Mincho ProN", serif; }
.quick-history-word small, .quick-history-meaning, .quick-history-meta { color: var(--muted); font-size: 11px; line-height: 1.5; }
.quick-history-word small { margin-top: 3px; }
.quick-history-meaning { color: var(--ink); }
.quick-history-meta { text-align: right; }
.quick-history-empty { margin: auto; color: var(--muted); text-align: center; }
@media (max-width: 1100px) {
  .quick-list { grid-template-columns: minmax(0, 1fr); }
}
.book-dialog { width: min(760px, calc(100vw - 32px)); height: min(760px, calc(100vh - 48px)); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 26px; color: var(--ink); background: var(--paper); box-shadow: 0 28px 90px rgba(24,35,31,.28); }
.book-dialog::backdrop { background: rgba(24,35,31,.34); backdrop-filter: blur(5px); }
.book-dialog-panel { height: 100%; display: flex; flex-direction: column; min-height: 0; padding: 24px; }
.book-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.book-dialog-header h2 { margin: 0; font-size: 24px; }
.dialog-close { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: white; font-size: 22px; line-height: 1; }
.book-tabs { display: flex; gap: 4px; margin-top: 20px; padding: 4px; border-radius: 13px; background: #edf2ee; }
.book-tabs button { flex: 1; height: 38px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700; }
.book-tabs button.active { color: var(--green-dark); background: white; box-shadow: 0 4px 12px rgba(38,66,56,.08); }
.book-search { height: 42px; display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: white; }
.book-search input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.book-picker-content { flex: 1; min-height: 0; overflow-y: auto; margin-top: 16px; padding-right: 5px; scrollbar-width: thin; }
.book-group + .book-group { margin-top: 24px; }
.book-group-title { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 9px; }
.book-group-title h3 { margin: 0; font-size: 13px; }
.book-group-title span { color: var(--muted); font-size: 11px; }
.book-option { width: 100%; display: grid; grid-template-columns: 46px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 11px; border: 1px solid transparent; border-radius: 14px; color: inherit; background: transparent; text-align: left; }
.book-option + .book-option { margin-top: 4px; }
.book-option:hover { border-color: var(--line); background: #f5f8f5; }
.book-option.current { border-color: #c6dfd5; background: rgba(221,239,233,.48); }
.book-option-icon { width: 46px; height: 52px; display: grid; place-items: center; border-radius: 7px 11px 11px 7px; color: white; background: linear-gradient(145deg, #16816d, #075a4d); font-size: 12px; font-weight: 800; box-shadow: inset 4px 0 rgba(255,255,255,.12); }
.book-option-copy { min-width: 0; }
.book-option-copy strong, .book-option-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-option-copy strong { font-size: 14px; }
.book-option-copy small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.book-option-meta { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: 10px; font-style: normal; }
.book-option-meta b { font-weight: 500; }
.book-option-meta i, .book-option-meta em { padding: 2px 6px; border-radius: 99px; font-size: 9px; font-style: normal; }
.book-option-meta i { color: #8b5a16; background: #fbebd3; }
.book-option-meta em { color: var(--green-dark); background: var(--green-soft); }
.book-picker-empty { display: grid; place-items: center; min-height: 180px; margin: 0; color: var(--muted); font-size: 13px; }
.toast { position: fixed; right: 22px; bottom: 22px; transform: translateY(20px); opacity: 0; pointer-events: none; padding: 12px 16px; border-radius: 12px; color: white; background: #24312c; box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (min-width: 841px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100vh; overflow: hidden; }
  .workspace { height: calc(100vh - 82px); min-height: 0; overflow: hidden; }
  .sidebar { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
  .word-list { flex: 1; height: auto; min-height: 0; overscroll-behavior: contain; }
  .study-stage { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
  .association-panel { top: 0; max-height: calc(100vh - 142px); overscroll-behavior: contain; }
}

@media (max-width: 840px) {
  .topbar { height: 70px; padding: 0 18px; }
  .brand small { display: none; }
  .api-status span:last-child { display: none; }
  .topbar-actions { gap: 8px; }
  .auth-trigger { padding-right: 8px; }
  .auth-trigger > span:last-child { display: none; }
  .auth-popover { position: fixed; top: 62px; right: 10px; width: min(310px, calc(100vw - 20px)); }
  .workspace { display: block; }
  .workspace.sidebar-collapsed { display: block; }
  .sidebar { padding: 18px; border-right: 0; }
  .sidebar.collapsed { padding: 10px 18px; }
  .sidebar.collapsed .sidebar-toggle { margin-left: auto; }
  .session-summary { margin: 12px 0; }
  .word-list { height: 210px; min-height: 0; }
  .study-stage { padding: 12px 14px 106px; }
  .stage-meta { align-items: flex-start; gap: 10px; }
  .quick-mode .study-stage { padding-bottom: 28px; }
  .quick-header { top: 0; flex-wrap: wrap; padding: 16px; border-radius: 16px; gap: 10px; }
  .quick-header > div:first-child { width: 100%; }
  .quick-header h2 { font-size: 20px; }
  .quick-header-actions { width: 100%; justify-content: stretch; }
  .quick-header-actions button { flex: 1; min-width: 0; min-height: 42px; padding-inline: 10px; font-size: 12px; }
  .quick-history-button { justify-content: center; }
  .quick-word { padding: 16px 12px; }
  .quick-word-heading { gap: 9px; }
  .quick-word-copy h3 { font-size: 23px; }
  .quick-word-actions { gap: 5px; }
  .quick-reveal { padding-inline: 10px; }
  .quick-history-dialog { height: min(760px, calc(100vh - 20px)); }
  .quick-history-panel { padding: 19px 14px; }
  .quick-history-item { grid-template-columns: minmax(90px,.8fr) minmax(0,1.2fr); }
  .quick-history-meta { grid-column: 1 / -1; text-align: left; }
  .mode-selector { align-items: flex-start; flex-wrap: wrap; gap: 6px; }
  .mode-selector .mode-chip { flex-basis: 100%; width: fit-content; }
  .word-card { min-height: 520px; padding: 28px 22px; border-radius: 22px; }
  .study-layout { display: block; }
  .association-panel { position: static; max-height: none; margin-top: 14px; border-radius: 20px; }
  .word-line h2 { font-size: 48px; }
  .notes div { grid-template-columns: 44px 1fr; }
  .study-actions button { min-width: 0; flex: 1; padding-inline: 14px; }
  .study-actions { bottom: 12px; }
  .next-button { min-width: 0 !important; }
  .book-dialog { height: min(720px, calc(100vh - 20px)); }
  .book-dialog-panel { padding: 19px 15px; }
  .book-option { grid-template-columns: 42px minmax(0,1fr) auto; gap: 9px; padding: 9px 7px; }
  .book-option-icon { width: 42px; height: 48px; }
  .book-option-copy small { max-width: 42vw; }
}
