:root {
  --ink: #1d2b26;
  --muted: #66736d;
  --paper: #f6f7f1;
  --surface: #ffffff;
  --line: #dfe4dc;
  --green: #245c45;
  --green-2: #2f7556;
  --green-soft: #e7f0e9;
  --lime: #ddefa5;
  --orange: #e07c3e;
  --orange-soft: #fff0e4;
  --red: #b84d42;
  --shadow: 0 18px 55px rgba(31, 57, 45, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --sidebar: 252px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); color: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Noto Sans SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 78% 3%, rgba(221, 239, 165, 0.24), transparent 24rem),
    var(--paper);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  padding: 28px 18px 22px;
  display: flex;
  flex-direction: column;
  background: #eef1e9;
  border-right: 1px solid rgba(75, 94, 82, 0.12);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--green); box-shadow: 0 8px 20px rgba(36, 92, 69, .2); }
.brand-mark svg { width: 25px; height: 25px; }
.brand strong { display: block; font-family: Georgia, serif; font-size: 22px; line-height: 1; letter-spacing: -.4px; }
.brand span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }

.primary-nav { display: grid; gap: 7px; }
.nav-item { width: 100%; min-height: 46px; padding: 0 12px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px; border: 0; border-radius: 13px; background: transparent; color: #4d5c55; text-align: left; cursor: pointer; transition: .18s ease; }
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.6); }
.nav-item.is-active { color: #fff; background: var(--green); box-shadow: 0 8px 20px rgba(36, 92, 69, .16); }
.nav-item svg { width: 20px; }
.nav-item span:nth-child(2) { font-size: 14px; font-weight: 650; }
.nav-count { min-width: 23px; height: 23px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; font-size: 11px; font-weight: 750; background: rgba(255,255,255,.17); }
.nav-item:not(.is-active) .nav-count { background: #dde3da; }

.sidebar-section { margin-top: 28px; min-height: 0; }
.sidebar-section-title { padding: 0 8px 10px; display: flex; align-items: center; justify-content: space-between; color: #7a857f; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; transition: .18s ease; }
.icon-button:hover { border-color: #b8c3ba; transform: translateY(-1px); }
.icon-button.small { width: 26px; height: 26px; border: 0; background: transparent; }
.icon-button.small svg { width: 16px; height: 16px; }

.folder-list { display: grid; gap: 4px; max-height: 32vh; overflow: auto; scrollbar-width: thin; }
.folder-item { width: 100%; padding: 9px 10px; display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; border: 0; border-radius: 10px; color: #5b6862; background: transparent; text-align: left; cursor: pointer; }
.folder-item:hover, .folder-item.is-active { background: rgba(255,255,255,.72); color: var(--ink); }
.folder-icon { width: 25px; height: 22px; display: grid; place-items: center; color: var(--green-2); }
.folder-icon svg { width: 19px; height: 19px; }
.folder-item span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.folder-item small { color: #8b958f; font-size: 10px; }

.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.google-auth { min-height: 42px; display: grid; place-items: center; }
#google-signin { width: 100%; min-height: 40px; overflow: hidden; }
#google-signin > div { margin: 0 auto; }
.google-profile { width: 100%; min-height: 48px; padding: 7px 8px; display: grid; grid-template-columns: 34px minmax(0,1fr) 30px; align-items: center; gap: 8px; border: 1px solid rgba(75,94,82,.1); border-radius: 11px; background: rgba(255,255,255,.66); }
.google-profile img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #dfe7de; }
.google-profile strong, .google-profile span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.google-profile strong { color: var(--ink); font-size: 11px; }
.google-profile span { margin-top: 3px; color: #7a857f; font-size: 8px; }
.google-profile button { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 8px; color: #77837c; background: transparent; cursor: pointer; }
.google-profile button:hover { color: var(--red); background: #faece9; }
.google-profile button svg { width: 16px; height: 16px; }
.sync-status { padding: 10px 12px; display: flex; align-items: center; gap: 8px; border-radius: 10px; color: #68736d; background: rgba(255,255,255,.58); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c99c45; box-shadow: 0 0 0 4px rgba(201,156,69,.12); }
.sync-status.is-online .status-dot { background: #4b9a6d; box-shadow: 0 0 0 4px rgba(75,154,109,.12); }
.sync-status.is-error .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(184,77,66,.12); }
.data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.sheet-link { padding: 8px 7px; display: flex; align-items: center; gap: 6px; border: 0; border-radius: 9px; color: #6c7771; background: transparent; text-align: left; text-decoration: none; font-size: 10px; cursor: pointer; }
.sheet-link:hover { color: var(--green); }
.sheet-link svg { width: 16px; height: 16px; }

.main-content { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { height: 104px; padding: 25px clamp(24px, 4vw, 64px) 18px; display: flex; align-items: center; gap: 16px; }
.topbar-copy { flex: 1; }
.eyebrow, .section-kicker { display: block; color: var(--green-2); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.topbar h1 { margin: 5px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(25px, 3vw, 34px); font-weight: 500; letter-spacing: -.03em; }
.menu-button { display: none; }
.streak-pill { min-width: 112px; padding: 9px 15px 9px 11px; display: flex; align-items: baseline; justify-content: center; gap: 5px; border: 1px solid #ead4bf; border-radius: 999px; color: #8c4e2a; background: #fff8f1; box-shadow: 0 5px 18px rgba(112,78,42,.06); }
.streak-pill strong { font-size: 20px; }
.streak-pill span:last-child { color: #9b7056; font-size: 11px; }
.streak-flame { font-size: 17px; align-self: center; }

.connection-banner { margin: 0 clamp(24px, 4vw, 64px) 16px; padding: 12px 16px; align-items: center; gap: 10px; border: 1px solid #ecc6b8; border-radius: 12px; color: #7d3f35; background: #fff2ec; font-size: 13px; }
.connection-banner:not([hidden]) { display: flex; }
.connection-banner span { flex: 1; color: #94685f; }
.connection-banner button { padding: 6px 11px; border: 1px solid #d8a898; border-radius: 8px; background: #fff; cursor: pointer; }

.view { display: none; padding: 8px clamp(24px, 4vw, 64px) 48px; }
.view.is-active { display: block; animation: view-in .28s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

.review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 248px; gap: 28px; max-width: 1180px; margin: 0 auto; }
.review-main { min-width: 0; }
.welcome-card { min-height: 128px; padding: 26px 29px; display: flex; align-items: center; justify-content: space-between; gap: 30px; border: 1px solid rgba(93, 112, 101, .13); border-radius: var(--radius-lg); background: rgba(255,255,255,.74); box-shadow: 0 12px 40px rgba(47,71,59,.045); }
.welcome-card h2 { margin: 8px 0 5px; font-family: Georgia, serif; font-size: clamp(21px, 2.4vw, 29px); font-weight: 500; letter-spacing: -.025em; }
.welcome-card p { margin: 0; color: var(--muted); font-size: 13px; }
.mini-progress { position: relative; width: 82px; height: 82px; flex: 0 0 82px; }
.mini-progress svg { width: 82px; height: 82px; transform: rotate(-90deg); }
.mini-progress circle { fill: none; stroke-width: 5; }
.progress-track { stroke: #e7ebe4; }
.progress-value { stroke: var(--green-2); stroke-linecap: round; stroke-dasharray: 182.2; stroke-dashoffset: 182.2; transition: stroke-dashoffset .45s ease; }
.mini-progress div { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.mini-progress strong { font-size: 15px; }
.mini-progress span { margin-top: 1px; color: #7f8a84; font-size: 8px; }

.study-stage { position: relative; margin-top: 20px; padding: 19px; border: 1px solid rgba(93,112,101,.13); border-radius: var(--radius-lg); background: rgba(255,255,255,.55); }
.study-toolbar { min-height: 34px; margin-bottom: 12px; padding: 0 6px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; }
.session-meta { display: flex; align-items: center; gap: 7px; font-weight: 650; }
.folder-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-2); }
.session-counter strong { color: var(--ink); font-size: 13px; }

.review-deck { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.review-card { position: relative; min-width: 0; aspect-ratio: 1.35 / 1; padding: 0; border: 0; border-radius: 16px; color: var(--ink); background: transparent; cursor: pointer; perspective: 900px; transition: transform .18s ease, filter .18s ease; }
.review-card:hover { transform: translateY(-2px); }
.review-card.is-active { filter: drop-shadow(0 12px 20px rgba(32,73,54,.18)); }
.review-card:focus-visible { outline: 3px solid rgba(47,117,86,.34); outline-offset: 3px; }
.review-card-inner { position: absolute; inset: 0; display: block; transform-style: preserve-3d; transition: transform .58s cubic-bezier(.2,.75,.25,1); }
.review-card.is-revealed .review-card-inner { transform: rotateY(180deg); }
.review-card-face { position: absolute; inset: 0; padding: 35px 15px 29px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #d9ded6; border-radius: 16px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.review-card-front { background: linear-gradient(rgba(55,83,69,.032) 1px, transparent 1px), linear-gradient(90deg, rgba(55,83,69,.032) 1px, transparent 1px), #fff; background-size: 20px 20px; }
.review-card.is-active .review-card-front { border-color: rgba(47,117,86,.55); box-shadow: inset 0 0 0 2px rgba(47,117,86,.08); }
.review-card-back { color: #f8fbf6; background: radial-gradient(circle at 82% 14%, rgba(221,239,165,.2), transparent 8rem), linear-gradient(145deg, #245c45, #173b2e); border-color: rgba(255,255,255,.13); transform: rotateY(180deg); }
.review-card-label { position: absolute; top: 14px; left: 15px; color: #8a958f; font-size: 7px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.review-card-box { position: absolute; top: 11px; right: 12px; padding: 4px 7px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 7px; font-weight: 850; }
.review-card-word { max-width: 94%; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(23px, 3vw, 36px); line-height: 1.16; letter-spacing: -.02em; overflow-wrap: anywhere; }
.review-card-answer { max-width: 94%; color: #fff; font-family: Georgia, serif; font-size: clamp(17px, 2.1vw, 25px); line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-card-back .review-card-label { color: rgba(255,255,255,.57); }
.review-card-back .review-card-box { color: #173c2e; background: var(--lime); }
.review-card-hint { position: absolute; bottom: 11px; display: flex; align-items: center; gap: 5px; color: #8b958f; font-size: 7px; }
.review-card-hint svg { width: 12px; height: 12px; }
.review-card-back .review-card-hint { color: rgba(255,255,255,.56); }
.deck-help { margin: 11px 3px 0; color: var(--muted); text-align: center; font-size: 9px; }

.review-actions { margin-top: 19px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer-button { min-height: 66px; padding: 10px 13px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; border: 1px solid; border-radius: 15px; text-align: left; cursor: pointer; transition: .18s ease; }
.answer-button:disabled { opacity: .42; cursor: not-allowed; filter: grayscale(.25); }
.answer-button:not(:disabled):hover { transform: translateY(-2px); }
.answer-button.again { border-color: #efd0bf; background: #fff5ef; color: #87472f; }
.answer-button.good { border-color: #bad4c3; background: #edf7ef; color: #285e43; }
.answer-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.7); font-size: 18px; }
.answer-button strong, .answer-button small { display: block; }
.answer-button strong { font-size: 13px; }
.answer-button small { margin-top: 3px; opacity: .73; font-size: 9px; }
kbd { padding: 3px 6px; border: 1px solid currentColor; border-radius: 5px; opacity: .45; background: rgba(255,255,255,.5); font: 9px ui-monospace, monospace; }

.empty-state { min-height: 350px; padding: 50px 25px; text-align: center; }
.empty-icon { width: 72px; height: 72px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-soft); font-size: 28px; }
.empty-state h3 { margin: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.empty-state p { max-width: 410px; margin: 9px auto 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.stats-panel { display: flex; flex-direction: column; gap: 12px; }
.stats-heading { min-height: 25px; display: flex; justify-content: space-between; align-items: center; }
.live-badge { display: flex; align-items: center; gap: 5px; color: #6c7771; font-size: 9px; }
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: #5c9e72; }
.stat-card { border: 1px solid rgba(93,112,101,.13); border-radius: var(--radius-md); background: rgba(255,255,255,.72); }
.stat-card.accent { min-height: 122px; padding: 21px; display: grid; grid-template-columns: 38px 1fr; align-items: center; column-gap: 12px; background: var(--green); color: #fff; box-shadow: 0 12px 35px rgba(36,92,69,.18); }
.stat-card.accent .stat-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.13); font-size: 20px; }
.stat-card.accent span { display: block; opacity: .72; font-size: 10px; }
.stat-card.accent strong { display: block; margin-top: 2px; font-size: 32px; line-height: 1; }
.stat-card.accent small { grid-column: 1 / -1; align-self: end; opacity: .55; font-size: 9px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card.compact { padding: 15px; }
.stat-card.compact span { display: block; min-height: 25px; color: var(--muted); font-size: 9px; }
.stat-card.compact strong { display: block; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.box-legend { margin-top: 2px; padding: 18px; border: 1px solid rgba(93,112,101,.13); border-radius: var(--radius-md); background: rgba(255,255,255,.58); }
.legend-heading { display: flex; justify-content: space-between; align-items: center; }
.legend-heading strong { font-size: 11px; }
.legend-heading span { color: #8a958f; font-size: 8px; text-transform: uppercase; letter-spacing: .12em; }
.box-legend ol { margin: 16px 0 0; padding: 0; display: grid; gap: 10px; list-style: none; }
.box-legend li { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; font-size: 9px; }
.box-legend li i { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--green-2) calc(var(--level) * 14%), #d9ded8); }
.box-legend li small { color: #88928d; font-size: 8px; }

.cards-header { max-width: 1180px; margin: 0 auto 25px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.cards-header h2 { margin: 7px 0 5px; font-family: Georgia, serif; font-size: 30px; font-weight: 500; letter-spacing: -.025em; }
.cards-header p { margin: 0; color: var(--muted); font-size: 13px; }
.primary-button, .secondary-button, .danger-button { min-height: 42px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; font-size: 12px; font-weight: 700; cursor: pointer; transition: .18s ease; }
.primary-button { border: 1px solid var(--green); color: #fff; background: var(--green); box-shadow: 0 7px 16px rgba(36,92,69,.16); }
.primary-button:hover { background: #1e503b; transform: translateY(-1px); }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary-button svg { width: 17px; height: 17px; }
.secondary-button { border: 1px solid var(--line); background: #fff; }
.danger-button { border: 1px solid var(--red); color: #fff; background: var(--red); }

.list-toolbar { max-width: 1180px; margin: 0 auto 12px; padding: 11px; display: grid; grid-template-columns: 190px minmax(220px, 1fr) auto; align-items: end; gap: 10px; border: 1px solid rgba(93,112,101,.13); border-radius: 15px; background: rgba(255,255,255,.62); }
.select-field span { display: block; margin: 0 0 5px 2px; color: #7c8781; font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .1em; }
.select-field select, .search-field { height: 39px; border: 1px solid #d9dfd7; border-radius: 10px; background: #fff; }
.select-field select { width: 100%; padding: 0 32px 0 11px; color: var(--ink); font-size: 12px; }
.search-field { display: flex; align-items: center; gap: 8px; padding: 0 11px; }
.search-field svg { width: 17px; color: #859089; }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.list-total { height: 39px; padding: 0 10px; display: flex; align-items: center; gap: 4px; color: #7c8781; font-size: 10px; }
.list-total strong { color: var(--ink); font-size: 14px; }

.cards-table-wrap { max-width: 1180px; min-height: 300px; margin: 0 auto; overflow: hidden; border: 1px solid rgba(93,112,101,.13); border-radius: var(--radius-md); background: rgba(255,255,255,.78); box-shadow: 0 12px 40px rgba(47,71,59,.04); }
.cards-table { width: 100%; border-collapse: collapse; }
.cards-table th { padding: 13px 16px; color: #7a857f; background: #f1f3ee; text-align: left; font-size: 8px; letter-spacing: .09em; text-transform: uppercase; }
.cards-table td { padding: 15px 16px; border-top: 1px solid #e9ece7; font-size: 12px; vertical-align: middle; }
.cards-table td:first-child { max-width: 220px; font-family: Georgia, "Noto Serif SC", serif; font-size: 16px; font-weight: 600; }
.cards-table td:nth-child(2) { max-width: 300px; color: #59665f; }
.cards-table td:first-child, .cards-table td:nth-child(2) { overflow-wrap: anywhere; white-space: pre-wrap; }
.cards-table td:nth-last-child(1) { width: 50px; text-align: right; }
.box-chip { display: inline-flex; min-width: 47px; padding: 5px 8px; justify-content: center; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 9px; font-weight: 800; }
.date-cell { color: #738078; font-size: 10px !important; white-space: nowrap; }
.delete-row { width: 31px; height: 31px; display: grid; place-items: center; border: 0; border-radius: 9px; color: #9b6962; background: transparent; cursor: pointer; }
.delete-row:hover { color: var(--red); background: #faece9; }
.delete-row svg { width: 16px; height: 16px; }
.table-empty { padding: 60px 20px; text-align: center; }
.table-empty > div { width: 54px; height: 54px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-soft); font-size: 23px; }
.table-empty h3 { margin: 0; font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.table-empty p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }

.modal { width: min(560px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 22px; color: var(--ink); background: #fbfcf8; box-shadow: 0 30px 90px rgba(22,40,31,.26); }
.modal::backdrop { background: rgba(25,39,32,.48); backdrop-filter: blur(3px); }
.modal form { padding: 25px; }
.small-modal { width: min(460px, calc(100vw - 28px)); }
.modal-header { margin-bottom: 22px; display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.modal-header h2 { margin: 6px 0 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.form-field { margin-top: 14px; display: block; }
.form-field > span { display: block; margin: 0 0 7px 2px; font-size: 10px; font-weight: 750; }
.form-field input, .form-field textarea, .form-field select { width: 100%; border: 1px solid #d8ded6; border-radius: 11px; outline: 0; color: var(--ink); background: #fff; transition: border-color .16s, box-shadow .16s; }
.form-field input, .form-field select { height: 43px; padding: 0 12px; }
.form-field textarea { padding: 11px 12px; line-height: 1.5; resize: vertical; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus { border-color: #6b947d; box-shadow: 0 0 0 3px rgba(47,117,86,.1); }
.form-field small { display: block; margin: 5px 0 0 2px; color: #89938d; font-size: 9px; }
.modal-note { margin-top: 17px; padding: 11px 13px; display: flex; align-items: center; gap: 9px; border-radius: 10px; color: #557060; background: var(--green-soft); font-size: 10px; }
.modal-note span { width: 19px; height: 19px; display: grid; place-items: center; flex: 0 0 19px; border: 1px solid #93b3a0; border-radius: 50%; font-family: Georgia, serif; font-style: italic; }
.modal-actions { margin-top: 23px; display: flex; justify-content: flex-end; gap: 9px; }
.delete-copy { color: var(--muted); font-size: 13px; line-height: 1.6; }
.danger-text { color: var(--red); }

.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 250px; max-width: 360px; padding: 12px 15px; border: 1px solid #d8dfd6; border-radius: 12px; color: var(--ink); background: #fff; box-shadow: 0 12px 35px rgba(31,57,45,.15); font-size: 11px; animation: toast-in .24s ease both; }
.toast.is-error { border-color: #e4b5aa; color: #8e3f35; background: #fff6f3; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.batch-modal form { text-align: center; }
.batch-icon { width: 56px; height: 56px; margin: 0 auto 17px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green-2); box-shadow: 0 12px 28px rgba(36,92,69,.22); font-size: 26px; }
.batch-summary h2 { margin: 7px 0 8px; font-family: Georgia, serif; font-size: 26px; }
.batch-summary p { max-width: 390px; margin: 0 auto; color: var(--muted); font-size: 11px; line-height: 1.6; }
.batch-actions { justify-content: stretch; }
.batch-actions button { flex: 1; }

.ai-fab { position: fixed; z-index: 68; right: 22px; bottom: 22px; min-height: 52px; padding: 0 18px 0 10px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 999px; color: #fff; background: var(--green); box-shadow: 0 15px 38px rgba(36,92,69,.3); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease; }
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 18px 44px rgba(36,92,69,.38); }
.ai-fab > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--lime); font-size: 18px; }
.ai-fab strong { font-size: 12px; letter-spacing: .01em; }
.ai-fab[aria-expanded="true"] { pointer-events: none; opacity: 0; transform: translateY(10px); }
.ai-fab ~ .toast-region { bottom: 84px; }
.ai-backdrop { position: fixed; inset: 0; z-index: 69; background: transparent; }
.ai-panel { position: fixed; z-index: 70; top: 18px; right: 18px; bottom: 18px; width: min(390px, calc(100vw - 36px)); display: grid; grid-template-rows: auto auto auto auto minmax(0,1fr) auto auto; border: 1px solid rgba(58,83,69,.14); border-radius: 24px; overflow: hidden; color: var(--ink); background: #fbfcf8; box-shadow: 0 30px 90px rgba(22,40,31,.25); transform: translateX(calc(100% + 38px)); visibility: hidden; transition: transform .28s ease, visibility .28s; }
.ai-panel.is-open { visibility: visible; transform: translateX(0); }
.ai-panel-header { min-height: 74px; padding: 14px 15px; display: grid; grid-template-columns: 44px 1fr 38px; align-items: center; gap: 10px; color: #fff; background: var(--green); }
.ai-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; color: var(--green); background: var(--lime); font-size: 21px; box-shadow: 0 7px 18px rgba(18,46,34,.22); }
.ai-panel-header strong { display: block; font-family: Georgia, serif; font-size: 19px; }
.ai-panel-header span { margin-top: 4px; display: flex; align-items: center; gap: 6px; color: rgba(255,255,255,.72); font-size: 9px; }
.ai-panel-header span i { width: 6px; height: 6px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(221,239,165,.15); }
.ai-panel-header .icon-button { color: #fff; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); }
.ai-context { margin: 13px 15px 0; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid #dbe3d9; border-radius: 12px; background: var(--green-soft); }
.ai-context span { color: var(--muted); font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.ai-context strong { max-width: 225px; overflow: hidden; color: var(--green); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ai-modes { margin: 10px 15px 0; padding: 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border-radius: 11px; background: #e9ede7; }
.ai-modes button { min-height: 31px; border: 0; border-radius: 8px; color: #68756e; background: transparent; font-size: 9px; font-weight: 750; cursor: pointer; }
.ai-modes button.is-active { color: var(--green); background: #fff; box-shadow: 0 3px 10px rgba(34,61,47,.08); }
.ai-panel[data-mode="cards"] .ai-quick-actions { display: none; }
.ai-quick-actions { padding: 10px 15px 4px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.ai-quick-actions::-webkit-scrollbar { display: none; }
.ai-quick-actions button { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #dbe2d9; border-radius: 999px; color: #496356; background: #fff; font-size: 9px; font-weight: 700; cursor: pointer; }
.ai-quick-actions button:hover { border-color: #87a393; background: #f1f6ef; }
.ai-messages { min-height: 0; padding: 12px 15px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; scroll-behavior: smooth; }
.ai-message { max-width: 88%; display: flex; align-items: flex-start; gap: 7px; }
.ai-message.is-user { margin-left: auto; justify-content: flex-end; }
.ai-message-avatar { width: 25px; height: 25px; flex: 0 0 25px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--green-2); font-size: 11px; }
.ai-message p { margin: 0; padding: 10px 12px; border: 1px solid #e0e5de; border-radius: 5px 14px 14px 14px; color: #3f4f47; background: #fff; font-size: 11px; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-message.is-user p { color: #fff; border: 0; border-radius: 14px 14px 5px 14px; background: var(--green-2); }
.ai-message.is-loading p { min-width: 54px; color: #809087; }
.ai-message.is-loading p::after { content: "···"; display: inline-block; letter-spacing: 3px; animation: ai-dots 1s ease-in-out infinite; }
@keyframes ai-dots { 50% { opacity: .35; transform: translateY(-2px); } }
.ai-form { margin: 0 15px; min-height: 48px; padding: 5px 5px 5px 12px; display: grid; grid-template-columns: 1fr 38px; align-items: end; gap: 7px; border: 1px solid #d2dbd1; border-radius: 15px; background: #fff; box-shadow: 0 6px 22px rgba(40,67,52,.07); }
.ai-form:focus-within { border-color: #6b947d; box-shadow: 0 0 0 3px rgba(47,117,86,.1); }
.ai-form textarea { width: 100%; max-height: 110px; padding: 9px 0 7px; resize: none; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; line-height: 1.4; }
.ai-form button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 11px; color: #fff; background: var(--green); cursor: pointer; }
.ai-form button:disabled { cursor: wait; opacity: .55; }
.ai-form button svg { width: 18px; height: 18px; }
.ai-note { margin: 8px 0 11px; color: #919b95; font-size: 8px; text-align: center; }
.ai-panel.is-open ~ .toast-region { right: 430px; }

.sidebar-backdrop { display: none; }
.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; }
[hidden] { display: none !important; }

@media (max-width: 980px) {
  :root { --sidebar: 224px; }
  .review-layout { grid-template-columns: minmax(0,1fr) 210px; gap: 18px; }
  .stats-panel { gap: 9px; }
  .box-legend { padding: 15px; }
  .review-deck { gap: 10px; }
  .cards-table th, .cards-table td { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-102%); transition: transform .25s ease; box-shadow: 10px 0 35px rgba(26,47,36,.18); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(25,39,32,.35); }
  .sidebar-backdrop.is-visible { display: block; }
  .main-content { margin-left: 0; }
  .topbar { height: 91px; padding: 18px 18px 14px; }
  .menu-button { display: grid; flex: 0 0 38px; }
  .view { padding: 6px 16px 38px; }
  .connection-banner { margin-left: 16px; margin-right: 16px; flex-wrap: wrap; }
  .review-layout { display: block; }
  .review-deck { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-panel { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; }
  .stats-heading, .box-legend { grid-column: 1 / -1; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .cards-table-wrap { overflow-x: auto; }
  .cards-table { min-width: 780px; }
  .ai-backdrop { background: rgba(25,39,32,.32); backdrop-filter: blur(2px); }
  .ai-panel { top: auto; right: 0; bottom: 0; width: 100%; max-height: min(720px, 92dvh); height: 92dvh; border-radius: 24px 24px 0 0; transform: translateY(105%); }
  .ai-panel.is-open { transform: translateY(0); }
  .ai-panel.is-open ~ .toast-region { right: 14px; }
}

@media (max-width: 540px) {
  .topbar h1 { font-size: 25px; }
  .eyebrow { display: none; }
  .streak-pill { min-width: 91px; padding: 8px 11px; }
  .streak-pill span:last-child { display: none; }
  .welcome-card { padding: 20px; min-height: 110px; }
  .welcome-card p { display: none; }
  .mini-progress { width: 68px; height: 68px; flex-basis: 68px; }
  .mini-progress svg { width: 68px; height: 68px; }
  .study-stage { padding: 12px; }
  .review-deck { gap: 9px; }
  .review-card { aspect-ratio: 1.24 / 1; }
  .review-card-face { padding-left: 10px; padding-right: 10px; }
  .review-actions { grid-template-columns: 1fr; }
  .answer-button { min-height: 58px; }
  .stats-panel { display: grid; }
  .stat-card.accent { min-height: 105px; }
  .cards-header { align-items: start; }
  .cards-header p { display: none; }
  .cards-header .primary-button { min-width: 43px; padding: 0 12px; font-size: 0; }
  .list-toolbar { grid-template-columns: 1fr auto; }
  .search-field { grid-column: 1 / -1; grid-row: 2; }
  .list-total { grid-column: 2; grid-row: 1; }
  .modal form { padding: 21px; }
  .ai-fab { right: 14px; bottom: 14px; min-height: 48px; padding-right: 15px; }
  .ai-fab > span { width: 31px; height: 31px; }
  .toast-region { right: 14px; bottom: 74px; }
  .ai-panel-header { min-height: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
