:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #4b5563;
  --paper: #f9fafb;
  --surface: #fff;
  --line: #e5e7eb;
  --green: #2563eb;
  --green-deep: #1d4ed8;
  --mint: #eff6ff;
  --amber: #fbbf24;
  --red: #b91c1c;
  --shadow: 0 8px 20px rgba(15, 23, 42, .08);
  font-family: 'Inter', sans-serif;
}
* { box-sizing: border-box; }
[hidden], .hidden { display: none !important; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
body.dark { color-scheme: dark; --ink: #f3f4f6; --muted: #d1d5db; --paper: #18181b; --surface: #27272a; --line: #52525b; --green: #60a5fa; --green-deep: #93c5fd; --mint: #1e3a8a; --amber: #fbbf24; --red: #f87171; --shadow: 0 2px 16px rgba(0,0,0,.5); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.memos-site-header { font-family: 'Inter', sans-serif; }
.memos-brand { flex: 0 0 auto; color: #fbbf24; text-decoration: none; }
.memos-brand span { font-family: 'Rock Salt', cursive; }
.memos-desktop-nav { display: none; }
.memos-desktop-nav a { color: #dbeafe; text-decoration: none; white-space: nowrap; font-size: 16px; font-weight: 500; transition: color .2s ease; }
.memos-desktop-nav a:hover, .memos-desktop-nav a.active { color: #fbbf24; }
.memos-auth-controls { flex: 0 0 auto; }
.memos-mobile-menu { position: fixed; top: 4.5rem; left: 0; right: 0; z-index: 40; padding: 10px; border-top: 1px solid rgba(96,165,250,.5); background: rgba(37,99,235,.96); box-shadow: 0 10px 20px rgba(0,0,0,.18); backdrop-filter: blur(8px); }
.memos-mobile-menu > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 auto; max-width: 920px; }
.memos-mobile-menu a { padding: 7px 10px; border-radius: 6px; background: rgba(29,78,216,.55); color: #dbeafe; text-decoration: none; font-size: 12px; white-space: nowrap; }
.memos-mobile-menu a:hover, .memos-mobile-menu a.active { background: rgba(251,191,36,.35); color: #fef3c7; }
.page-shell { width: min(1280px, calc(100% - 40px)); flex-grow: 1; margin: 0 auto; padding: 46px 0 70px; }
.page-summary { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 0 0 20px; padding: 0 0 16px; border-bottom: 1px solid var(--line); }
.page-summary h1 { margin: 0; font-size: 30px; letter-spacing: -.025em; }
.summary-metrics { display: flex; align-items: center; gap: 14px; }
.summary-metric { display: flex; align-items: baseline; gap: 8px; }
.summary-metric strong { color: var(--green); font-size: 23px; }
.summary-metric span { color: var(--muted); font-size: 12px; }
.eyebrow { margin: 0 0 10px; color: #2563eb; text-transform: uppercase; letter-spacing: .13em; font-size: 10px; font-weight: 700; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font: 700 clamp(34px, 5vw, 56px)/1.04 'Inter', sans-serif; letter-spacing: -.035em; }
h1 em { color: var(--green); font-weight: 600; }
h2 { margin-bottom: 10px; font: 600 26px/1.15 'Inter', sans-serif; letter-spacing: -.02em; }
.streak-badge { padding: 5px 9px; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 700; white-space: nowrap; }
body.dark .streak-badge { background: #78350f; color: #fde68a; }
.signed-out { margin: 28px auto 70px; max-width: 500px; padding: 44px 30px; text-align: center; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.signed-out-icon { width: 54px; height: 54px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 18px; background: var(--mint); color: var(--green); font-size: 25px; }
.signed-out p { margin: 0 auto 24px; max-width: 350px; color: var(--muted); line-height: 1.55; }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 20px; }
.view-tabs { display: flex; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.view-tab { padding: 10px 17px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }
.view-tab.active { background: var(--green); color: #fff; }
.total-count { margin: 0; color: var(--muted); font-size: 13px; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }
.study-layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 14px; }
.study-side { display: grid; grid-template-columns: minmax(145px, 1.2fr) minmax(125px, 1fr) minmax(125px, 1fr) auto; align-items: center; gap: 12px; padding: 16px; box-shadow: none; }
.study-toggles { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.study-panel-heading .eyebrow { margin: 0 0 4px; }
.study-panel-heading h2 { margin: 0; font-size: 17px; }
.session-setting { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.session-setting select { padding: 8px 10px; font-size: 12px; }
.study-side .toggle-row { justify-content: flex-start; gap: 8px; margin: 0; font-size: 11px; }
.study-side #start-session { white-space: nowrap; }
.study-setup-actions { display: flex; gap: 7px; align-self: end; }
.study-setup-actions .button { min-height: 38px; padding: 8px 11px; font-size: 11px; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.study-side #study-status { grid-column: 1 / -1; margin: 0; }
.study-side #study-status:empty { display: none; }
.field-label { display: block; margin: 9px 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--ink); background: var(--surface); outline: none; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 17%, transparent); }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 8px 0; color: var(--muted); font-size: 13px; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--green); }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 11px; font-size: 13px; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-deep); }
.button.secondary { border-color: var(--line); background: var(--surface); color: var(--green-deep); }
.button.subtle { border-color: var(--line); background: transparent; color: var(--ink); }
.button.danger-quiet { border-color: color-mix(in srgb, var(--red) 30%, var(--line)); background: transparent; color: var(--red); }
.button.small { min-height: 33px; padding: 7px 10px; font-size: 11px; }
.full-width { width: 100%; }
.study-main { min-width: 0; }
.study-card { min-height: 420px; padding: clamp(22px, 4vw, 44px); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.card-topline { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
#card-content { flex: 1; display: grid; align-content: center; justify-items: center; padding: 28px 0; text-align: center; }
#card-term { margin: 0; font: 600 clamp(30px, 5vw, 48px)/1.1 'Inter', sans-serif; overflow-wrap: anywhere; }
.card-answer { width: min(440px, 100%); margin-top: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); text-align: left; }
.card-answer p { margin: 0; line-height: 1.45; }
.card-answer .example { margin-top: 5px; color: var(--muted); font-style: italic; }
.card-hint { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.card-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 20px; }
.rating-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.rating-again { background: #fae8e4; color: #9e4539; }
.rating-hard { background: #fbf0dc; color: #846025; }
.rating-easy { background: #e6f1e9; color: #326448; }
.rating-mastered { background: #e9ebf8; color: #4b5289; }
body.dark .rating-again { background: #4a2c28; color: #ffb4a8; }
body.dark .rating-hard { background: #4a3c25; color: #f3d28d; }
body.dark .rating-easy { background: #293d31; color: #a8d3b5; }
body.dark .rating-mastered { background: #2e3048; color: #c2c6fa; }
.scramble-area { width: min(620px, 100%); }
.scramble-slots, .scramble-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; min-height: 52px; margin: 13px 0; }
.scramble-slot, .scramble-tile { width: 40px; height: 44px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); font-size: 18px; font-weight: 700; }
.scramble-slot.filled, .scramble-tile { border-style: solid; border-color: #c8d8cd; background: var(--mint); cursor: pointer; }
.scramble-tile { box-shadow: 0 2px 4px rgba(0,0,0,.06); }
.scramble-controls { text-align: center; }
.scramble-feedback { margin: 8px 0; font-weight: 700; }
.scramble-feedback.success { color: var(--green); }
.scramble-feedback.error { color: var(--red); }
.empty-state { min-height: 420px; display: grid; justify-items: center; align-content: center; padding: 30px; border: 1px dashed var(--line); border-radius: 24px; text-align: center; background: color-mix(in srgb, var(--surface) 80%, transparent); }
.empty-state h2 { margin-bottom: 5px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 15px; border-radius: 50%; background: var(--mint); color: var(--green); font-size: 22px; }
.loader { width: 26px; height: 26px; margin-bottom: 13px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.library-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(400px, 1.2fr); gap: 20px; align-items: start; }
.panel-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.panel-title-row h2 { margin-bottom: 5px; }
.format-example { color: var(--green-deep); font-weight: 600; }
.add-panel form { display: grid; gap: 9px; }
.add-panel .muted { margin-bottom: 12px; }
.count-pill { padding: 7px 11px; border-radius: 99px; background: var(--mint); color: var(--green-deep); font-size: 11px; font-weight: 700; white-space: nowrap; }
.manage-alphabet { display: flex; flex-wrap: wrap; gap: 4px; margin: 14px 0 10px; }
.alphabet-filter-button { min-width: 30px; min-height: 30px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.alphabet-filter-button:hover:not(:disabled) { border-color: var(--green); color: var(--green-deep); }
.alphabet-filter-button.active { border-color: var(--green); background: var(--green); color: #fff; }
.alphabet-filter-button:disabled { opacity: .35; cursor: not-allowed; }
.filter-row { display: grid; grid-template-columns: 1fr minmax(135px, .6fr); gap: 9px; margin: 16px 0 10px; }
.group-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; padding: 10px; border-radius: 10px; background: var(--paper); }
.group-actions span { flex: 1; font-size: 12px; font-weight: 700; }
.words-list { display: grid; gap: 9px; max-height: 610px; overflow: auto; padding-right: 3px; }
.word-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.word-main { min-width: 0; }
.word-term { display: block; margin-bottom: 3px; font-weight: 700; overflow-wrap: anywhere; }
.word-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.word-meta { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.word-tag { padding: 3px 7px; border-radius: 99px; background: var(--paper); color: var(--muted); font-size: 10px; }
.word-actions { display: flex; gap: 5px; }
.word-actions button { border: 0; padding: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.word-actions button:hover { color: var(--green-deep); }
.edit-form { grid-column: 1/-1; display: grid; gap: 8px; padding-top: 8px; }
.edit-form .edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit-actions { display: flex; gap: 7px; }
.status { min-height: 18px; margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.status.error { color: var(--red); }
.status.success { color: var(--green-deep); }
.links-words { display: flex; flex-wrap: wrap; gap: 8px; margin: 15px 0 25px; }
.link-word { padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--paper); color: var(--ink); cursor: pointer; }
.link-word.linked { border-width: 2px; border-color: var(--link-border); background: var(--link-bg); color: var(--link-text); font-weight: 700; }
.link-word.link-group-0 { --link-bg: #dbeafe; --link-border: #2563eb; --link-text: #1e3a8a; }
.link-word.link-group-1 { --link-bg: #dcfce7; --link-border: #16a34a; --link-text: #14532d; }
.link-word.link-group-2 { --link-bg: #fef3c7; --link-border: #d97706; --link-text: #78350f; }
.link-word.link-group-3 { --link-bg: #fce7f3; --link-border: #db2777; --link-text: #831843; }
.link-word.link-group-4 { --link-bg: #ede9fe; --link-border: #7c3aed; --link-text: #4c1d95; }
.link-word.link-group-5 { --link-bg: #cffafe; --link-border: #0891b2; --link-text: #164e63; }
body.dark .link-word.link-group-0 { --link-bg: #1e3a8a; --link-border: #60a5fa; --link-text: #dbeafe; }
body.dark .link-word.link-group-1 { --link-bg: #14532d; --link-border: #4ade80; --link-text: #dcfce7; }
body.dark .link-word.link-group-2 { --link-bg: #78350f; --link-border: #fbbf24; --link-text: #fef3c7; }
body.dark .link-word.link-group-3 { --link-bg: #831843; --link-border: #f472b6; --link-text: #fce7f3; }
body.dark .link-word.link-group-4 { --link-bg: #4c1d95; --link-border: #a78bfa; --link-text: #ede9fe; }
body.dark .link-word.link-group-5 { --link-bg: #164e63; --link-border: #22d3ee; --link-text: #cffafe; }
.link-word.selected { outline: 3px solid #111827; outline-offset: 2px; }
body.dark .link-word.selected { outline-color: #f9fafb; }
.link-legend { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; color: var(--muted); font-size: 12px; }
.link-legend-dot { width: 12px; height: 12px; border: 2px solid #2563eb; border-radius: 50%; background: #dbeafe; }
body.dark .link-legend-dot { border-color: #60a5fa; background: #1e3a8a; }
.links-list { display: grid; gap: 8px; }
.link-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.link-row button { border: 0; background: transparent; color: var(--red); cursor: pointer; }
.stats-strip { display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)) minmax(140px, .8fr); gap: 8px; margin: 18px 0 0; }
.stats-strip article, .range-select { min-height: 67px; display: grid; align-content: center; gap: 4px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: none; }
.stats-strip article span, .range-select { color: var(--muted); font-size: 11px; }
.stats-strip article strong { font-size: 19px; }
.range-select { grid-template-columns: auto minmax(85px, 1fr); align-items: center; gap: 8px; }
.range-select select { min-width: 0; padding: 6px 8px; font-size: 12px; }
.page-footer { min-height: 60px; display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 14px clamp(18px, 5vw, 72px); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.page-footer a { text-decoration: none; font-weight: 700; }
.focus-mode-exit { display: none; }
body.memos-focus-mode { overflow: hidden; }
body.memos-focus-mode .memos-site-header,
body.memos-focus-mode .page-summary,
body.memos-focus-mode .workspace-heading,
body.memos-focus-mode .stats-strip,
body.memos-focus-mode .study-side,
body.memos-focus-mode .page-footer { display: none !important; }
body.memos-focus-mode .page-shell { width: 100%; max-width: none; min-height: 100vh; margin: 0; padding: 16px; }
body.memos-focus-mode #memos-workspace { display: block !important; }
body.memos-focus-mode #view-study { display: grid !important; min-height: calc(100vh - 32px); margin: 0; gap: 0; }
body.memos-focus-mode .study-main { display: flex; min-height: calc(100vh - 32px); }
body.memos-focus-mode .study-card { flex: 1; min-height: calc(100vh - 32px); border-radius: 16px; }
body.memos-focus-mode .focus-mode-exit { position: fixed; top: 12px; right: 16px; z-index: 1000; display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-size: 12px; font-weight: 700; cursor: pointer; }
.focus-mode-exit span { font-size: 17px; line-height: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 850px) {
  .study-side { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .library-grid { grid-template-columns: 1fr; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .range-select { grid-column: 1/-1; grid-template-columns: auto minmax(130px, 1fr); align-items: center; }
}
@media (max-width: 560px) {
  .page-shell { width: min(100% - 24px, 1180px); padding: 24px 0 48px; }
  .page-summary { align-items: flex-start; }
  .page-summary h1 { font-size: 25px; }
  .summary-metrics { align-items: flex-end; flex-direction: column; gap: 5px; }
  .summary-metric { gap: 5px; }
  .summary-metric strong { font-size: 19px; }
  .summary-metric span { font-size: 10px; }
  .workspace-heading { align-items: flex-start; flex-direction: column; }
  .view-tabs { width: 100%; }
  .view-tab { flex: 1; padding: 9px 6px; font-size: 11px; }
  .panel { padding: 19px; }
  .study-side { grid-template-columns: 1fr 1fr; gap: 10px; }
  .study-panel-heading, .study-side #start-session, .study-side #study-status { grid-column: 1/-1; }
  .study-setup-actions { grid-column: 1/-1; }
  .study-setup-actions .button { flex: 1; }
  .study-card, .empty-state { min-height: 370px; padding: 22px 16px; }
  .card-actions { flex-direction: column; }
  .card-actions > button, .rating-actions .button { flex: 1; }
  .rating-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-row { grid-template-columns: 1fr; }
  .word-row { grid-template-columns: minmax(0,1fr) auto; padding: 11px; }
  .edit-form .edit-grid { grid-template-columns: 1fr; }
  .panel-title-row { flex-direction: column; gap: 4px; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .page-footer { padding: 14px 16px; }
}
@media (max-width: 560px) {
  body.memos-focus-mode .page-shell { padding: 8px; }
  body.memos-focus-mode #view-study,
  body.memos-focus-mode .study-main,
  body.memos-focus-mode .study-card { min-height: calc(100vh - 16px); }
  body.memos-focus-mode .study-card { padding: 55px 16px 20px; }
  body.memos-focus-mode .focus-mode-exit { top: 10px; right: 12px; }
}
@media (min-width: 768px) {
  .memos-desktop-nav { display: flex !important; }
}
@media (max-width: 767px) {
  .memos-desktop-nav { display: none !important; }
  .memos-brand img { height: 2.25rem; }
  .memos-brand span { font-size: 16px; }
  .memos-auth-controls { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
