/* ===== DESIGN TOKENS ===== */
/* --accent and --accent-active are injected per-user via wp_add_inline_style */
#srs-app {
  --blue: #007AFF;
  --blue-active: #0056CC;
  --red: #FF3B30;
  --orange: #FF9500;
  --yellow: #FFCC00;
  --green: #34C759;
  --green2: #30D158;
  --gray: #8E8E93;
  --gray5: #E5E5EA;
  --gray6: #F2F2F7;
  --separator: #C6C6C8;
  --label: #000;
  --bg: #F2F2F7;
  --card: rgba(255,255,255,.7);
  --white: #FFF;
  --radius: 12px;
  --border: none;
  --chart-text: rgba(0,0,0,1);
  --chart-grid: rgba(0,0,0,.07);
  --shadow: 0 0 12px 2px rgba(0,0,0,.18), 0 0 4px 0px rgba(0,0,0,.1);
  --shadow-hover: 0 0 24px 4px rgba(0,0,0,.26), 0 0 8px 1px rgba(0,0,0,.14);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', sans-serif;
  --transition: all .2s ease;
}

/* ===== RESET ===== */
#srs-app { overflow: hidden; }
html:has(#srs-app) body { overflow: hidden; }
#srs-app {
  font-family: var(--font);
  font-size: 15px;
  /* background injected per-user via wp_add_inline_style on #srs-app */
  color: var(--label);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
}
#srs-app * { box-sizing: border-box; color: var(--label); }
#srs-app h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px 0; }

/* ===== BUTTONS ===== */
#srs-app .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: var(--border);
  background: var(--card);
  color: var(--label);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: var(--transition);
  text-decoration: none;
  width: 100%;
}
#srs-app .btn:hover {
  box-shadow: var(--shadow-hover);
  background: color-mix(in srgb, var(--card) 80%, rgba(0,0,0,.15));
}
#srs-app .btn:active {
  box-shadow: var(--shadow);
}

/* Unified accent button style — btn-filled, btn-home share the same pastel treatment */
#srs-app .btn-filled,
#srs-app .btn-home {
  background: color-mix(in srgb, var(--accent) 35%, white);
  color: rgba(0,0,0,.8) !important;
  border-color: transparent;
}
#srs-app .btn-filled { font-weight: 600; }
#srs-app .btn-home  { font-weight: 500; }
#srs-app .btn-filled * { color: rgba(0,0,0,.8) !important; }
#srs-app .btn-home  * { color: rgba(0,0,0,.8) !important; }
#srs-app .btn-filled:hover,
#srs-app .btn-home:hover  { background: color-mix(in srgb, var(--accent) 50%, white); box-shadow: var(--shadow-hover); }
#srs-app.dark .btn-filled,
#srs-app.dark .btn-home   { background: color-mix(in srgb, var(--accent) 35%, var(--gray6)) !important; color: rgba(255,255,255,.9) !important; }
#srs-app.dark .btn-filled *,
#srs-app.dark .btn-home * { color: rgba(255,255,255,.9) !important; }
#srs-app.dark .btn-filled:hover,
#srs-app.dark .btn-home:hover { background: color-mix(in srgb, var(--accent) 50%, var(--gray6)) !important; }

#srs-app .btn-gray {
  background: var(--gray5);
}
#srs-app .btn-gray:hover { background: color-mix(in srgb, var(--gray5) 82%, black); box-shadow: var(--shadow-hover); }

#srs-app .btn-sm {
  min-height: 34px;
  padding: 7px 14px;
  font-size: 13px;
}

/* Form action buttons with background emoji */
#srs-app .btn-action {
  position: relative;
  overflow: hidden;
}
#srs-app .btn-action .btn-label {
  position: relative;
  z-index: 1;
}
#srs-app .btn-action .btn-deco {
  position: absolute;
  right: 4px;
  bottom: -16px;
  font-size: 72px;
  line-height: 1;
  opacity: .35;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* ===== ICON BUTTONS ===== */
#srs-app .icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 14px 8px;
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  box-shadow: var(--shadow);
  transition: opacity .3s ease, box-shadow .3s ease, transform .3s ease;
}
/* Dashboard Quick Add — stat-card style */
#srs-app #v-home .grid-5 .icon-btn {
  position: relative; overflow: hidden;
  min-height: 90px; align-items: flex-start; justify-content: flex-start;
  padding: 16px; flex-direction: column; gap: 0;
  transition: opacity .8s ease, box-shadow .4s ease, transform .3s ease;
}
#srs-app #v-home .grid-5 .icon-btn .label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; position: relative; z-index: 1;
}
#srs-app #v-home .grid-5 .icon-btn .icon {
  font-size: 90px; line-height: 1;
  position: absolute; right: 4px; bottom: -10px;
  opacity: .35; pointer-events: none; z-index: 0;
}
/* Dashboard snake effect */
#srs-app #v-home .grid-5:hover .icon-btn { opacity: .55; }
#srs-app #v-home .grid-5 .icon-btn:hover { opacity: 1; box-shadow: var(--shadow-hover); transform: translateY(-2px); transition: opacity .15s ease, box-shadow .2s ease, transform .2s ease; }
/* Add view: active bright, rest dim */
#srs-app #v-add .icon-btn {
  position: relative; overflow: hidden;
  min-height: 90px; align-items: flex-start; justify-content: flex-start;
  padding: 16px; flex-direction: column; gap: 0;
  opacity: .5;
}
#srs-app #v-add .icon-btn.active { opacity: 1; }
#srs-app #v-add .icon-btn:hover { opacity: .8; }
#srs-app #v-add .icon-btn.active:hover { opacity: 1; }
#srs-app #v-add .icon-btn .label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; position: relative; z-index: 1;
}
#srs-app #v-add .icon-btn .icon {
  font-size: 90px; line-height: 1;
  position: absolute; right: 4px; bottom: -10px;
  opacity: .35; pointer-events: none; z-index: 0;
}

/* ===== FILTER BUTTONS ===== */
#srs-app .filter-btn {
  min-height: 34px;
  padding: 7px 14px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
#srs-app .filter-btn:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
#srs-app .filter-btn:active { transform: translateY(0); box-shadow: var(--shadow); }
#srs-app .filter-btn.active {
  background: color-mix(in srgb, var(--accent) 35%, white);
  color: rgba(0,0,0,.8) !important;
  border-color: transparent;
  font-weight: 600;
}
#srs-app .filter-btn.active:hover { background: color-mix(in srgb, var(--accent) 50%, white); transform: translateY(-2px); }
#srs-app.dark .filter-btn.active { background: color-mix(in srgb, var(--accent) 35%, var(--gray6)) !important; color: rgba(255,255,255,.9) !important; }
#srs-app.dark .filter-btn.active:hover { background: color-mix(in srgb, var(--accent) 50%, var(--gray6)) !important; }

/* ===== RATING BUTTONS ===== */
#srs-app .rate-btn {
  min-height: 44px;
  padding: 12px;
  border: var(--border);
  border-radius: var(--radius);
  color: var(--white) !important;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
#srs-app .rate-btn * { color: var(--white) !important; }
#srs-app .rate-btn:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  filter: brightness(1.1);
}
#srs-app .rate-btn:active { transform: translateY(0); box-shadow: var(--shadow); }
#srs-app .rate-btn span { display: block; font-size: 11px; font-weight: 400; margin-top: 4px; }
#srs-app .r1{background:var(--red)} #srs-app .r2{background:var(--orange)} #srs-app .r3{background:var(--yellow)} #srs-app .r4{background:var(--green)} #srs-app .r5{background:var(--green2)}

/* ===== REVIEW ENGINE ===== */
#rv-topbar { display:flex; align-items:center; gap:8px; margin-bottom:12px; }
#rv-progress { position:relative; flex:1; min-width:0; height:34px; background:rgba(128,128,128,.15); border-radius:var(--radius); overflow:hidden; }
#rv-progress-fill { position:absolute; left:0; top:0; bottom:0; background:var(--accent); width:0%; transition:width .3s ease; }
#rv-progress-text { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:600; color:var(--label); z-index:1; }
#rv-chain-scroll { min-width:0; overflow-x:auto; scrollbar-width:none; padding:10px 6px; margin:-2px -6px 10px; }
#rv-chain-scroll::-webkit-scrollbar { display:none; }
#rv-queue-chain { display:flex; align-items:center; gap:4px; }
.rv-q-pill { font-size:11px; font-weight:500; min-height:34px; padding:0 10px; border-radius:var(--radius); background:var(--card); border:var(--border); white-space:nowrap; min-width:0; overflow:hidden; text-overflow:ellipsis; max-width:120px; flex-shrink:0; color:var(--label); opacity:.5; display:inline-flex; align-items:center; }
.rv-q-pill.rv-q-current { opacity:1; font-weight:700; cursor:default; pointer-events:none; }
.rv-q-pill.rv-q-future { cursor:pointer; }
.rv-q-pill.rv-q-future:hover { filter:drop-shadow(0 0 6px rgba(0,0,0,.32)) drop-shadow(0 2px 4px rgba(0,0,0,.18)); }
.rv-q-pill.rv-q-preview { opacity:.9; background:color-mix(in srgb,var(--accent) 10%,var(--card)); border-color:color-mix(in srgb,var(--accent) 35%,transparent); cursor:default; pointer-events:none; }
.rv-q-pill.rv-q-jumped { opacity:.2; text-decoration:line-through; cursor:default !important; }
.rv-q-arrow,.rv-q-more { font-size:11px; opacity:.28; flex-shrink:0; color:var(--label); line-height:1; }
.rv-q-finish { font-size:14px; flex-shrink:0; opacity:.55; margin-left:auto; }
#rv-xp, #rv-streak { font-size:14px; font-weight:700; padding:4px 10px; background:var(--card); border:var(--border); border-radius:20px; box-shadow:var(--shadow); }

/* Question card */
.rv-card { background:var(--card); border:var(--border); border-radius:var(--radius); padding:24px 20px 20px; box-shadow:var(--shadow); text-align:center; }
.rv-prompt { font-size:24px; font-weight:700; margin:0 0 6px; line-height:1.3; }
.rv-sub { font-size:13px; opacity:.45; margin:0 0 4px; }
.rv-type-label { font-size:11px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; opacity:.35; margin-bottom:16px; }

/* Format A — Multiple choice */
.rv-mc-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.rv-mc-btn { padding:14px 10px; border-radius:var(--radius); border:2px solid transparent; background:var(--card); cursor:pointer; font-size:14px; font-family:var(--font); transition:var(--transition); text-align:center; box-shadow:var(--shadow); line-height:1.3; }
.rv-mc-btn:hover { background:var(--gray5); transform:translateY(-1px); box-shadow:var(--shadow-hover); }
.rv-mc-btn.correct { background:rgba(52,199,89,.18) !important; border-color:var(--green) !important; }
.rv-mc-btn.wrong   { background:rgba(255,59,48,.13) !important; border-color:var(--red) !important; }
.rv-mc-btn:disabled { cursor:default; transform:none !important; }

/* Format B — Type answer */
.rv-type-form { display:flex; gap:8px; margin-top:4px; align-items:stretch; }
.rv-type-input { flex:1 1 0; min-width:0; padding:10px 14px; border-radius:var(--radius); border:var(--border); background:var(--card); font-family:var(--font); font-size:15px; color:var(--label); outline:none; box-shadow:var(--shadow); transition:border-color .2s; width:auto !important; }
.rv-type-input:focus { border-color:var(--accent); }
.rv-type-input.correct { border-color:var(--green) !important; background:rgba(52,199,89,.1); }
.rv-type-input.wrong   { border-color:var(--red)   !important; background:rgba(255,59,48,.08); }
.rv-type-form .rv-submit { width:auto !important; flex-shrink:0; min-width:80px; margin-top:0; font-size:13px !important; }
.rv-type-skip { opacity:.55; }

/* Format C — Word bank */
.rv-bank-target { min-height:48px; border:2px dashed rgba(128,128,128,.3); border-radius:var(--radius); padding:8px 10px; display:flex; flex-wrap:wrap; gap:6px; margin-bottom:12px; background:var(--card); transition:border-color .2s; }
.rv-bank-target.correct { border-color:var(--green); background:rgba(52,199,89,.08); }
.rv-bank-target.wrong   { border-color:var(--red);   background:rgba(255,59,48,.06); }
.rv-bank-source { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:12px; min-height:36px; }
.rv-chip { padding:6px 13px; background:var(--gray5); border-radius:20px; cursor:pointer; font-size:14px; font-family:var(--font); user-select:none; transition:var(--transition); border:2px solid transparent; }
.rv-chip:hover    { background:var(--accent); color:#fff; transform:translateY(-1px); }
.rv-chip.placed   { opacity:.2; pointer-events:none; }
.rv-chip.answer   { background:var(--accent); color:#fff; cursor:pointer; }
.rv-chip.answer:hover { background:var(--accent-active); }

/* Format D — Match pairs */
.rv-match-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.rv-match-grid > div { display:flex; flex-direction:column; gap:8px; }
.rv-match-item { padding:12px 10px; border-radius:var(--radius); border:2px solid transparent; background:var(--card); cursor:pointer; text-align:center; font-size:13px; font-family:var(--font); transition:var(--transition); box-shadow:var(--shadow); line-height:1.3; }
.rv-match-item:hover   { background:var(--gray5); transform:translateY(-1px); }
.rv-match-item.selected { border-color:var(--accent); background:rgba(0,122,255,.08); }
.rv-match-item.matched  { border-color:var(--green); background:rgba(52,199,89,.12); pointer-events:none; opacity:.7; }
.rv-match-item.wrong    { border-color:var(--red); animation:rv-shake .35s; }
.rv-match-col-label { font-size:10px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; opacity:.35; text-align:center; margin-bottom:4px; }
/* AI Quiz format */
.rv-ai-question { background:var(--card); border-radius:var(--radius); padding:14px; box-shadow:var(--shadow); border:1.5px solid transparent; transition:border-color .3s; }
.rv-ai-question.rv-ai-correct { border-color:var(--green); background:rgba(52,199,89,.06); }
.rv-ai-q-text { font-size:14px; font-weight:500; margin:0 0 10px; line-height:1.45; color:var(--label); }
.rv-ai-feedback { font-size:13px; min-height:18px; margin-top:6px; line-height:1.4; }
.rv-ai-ok  { color:var(--green); }
.rv-ai-err { color:var(--red); }
.rv-ai-checking { opacity:.5; font-style:italic; }
.rv-ai-loading { text-align:center; padding:24px 0; opacity:.55; font-size:14px; }
.rv-ai-done { padding:8px 0 2px; }
.rv-insight-body { font-size:16px; line-height:1.5; margin:14px 0 20px; color:var(--label); white-space:pre-wrap; }
.rv-insight-actions { display:flex; gap:10px; flex-wrap:wrap; }
.rv-insight-btn { flex:1 1 0; min-width:140px; min-height:48px; padding:12px 14px; font-size:14px; font-weight:600; border-radius:var(--radius); border:none; cursor:pointer; transition:transform .15s ease, box-shadow .2s ease; box-shadow:var(--shadow); }
.rv-insight-btn:hover { transform:translateY(-1px); box-shadow:var(--shadow-hover); }
.rv-insight-yes { background:var(--green); color:#fff; }
.rv-insight-no  { background:#f5a623; color:#fff; }

/* Unified spacing */
#v-review .glass { display:flex; flex-direction:column; width:85%; }
#rv-question-wrap { display:flex; flex-direction:column; gap:12px; flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; padding:6px 8px; margin:-6px -8px; }
#rv-question-wrap::-webkit-scrollbar { width:6px; }
#rv-question-wrap::-webkit-scrollbar-thumb { background:rgba(0,0,0,.15); border-radius:3px; }
#rv-question-wrap::-webkit-scrollbar-track { background:transparent; }
.rv-submit { width:100%; }

/* Skip button */
.rv-skip-btn { width:100% !important; opacity:.4; font-size:13px !important; background:transparent !important; border:1px dashed rgba(128,128,128,.3) !important; box-shadow:none !important; }
.rv-skip-btn:hover { opacity:.7; background:var(--gray5) !important; }

/* Feedback overlay */
.rv-feedback { display:none; position:absolute; inset:0; border-radius:var(--radius); flex-direction:column; align-items:center; justify-content:center; z-index:20; pointer-events:none; padding:32px 24px; }
.rv-feedback.show-c { display:flex; background:rgba(52,199,89,.13); animation:rv-flash .55s ease forwards; }
.rv-feedback.show-w { display:flex; background:rgba(255,255,255,.97); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); pointer-events:auto; }
#srs-app.dark .rv-feedback.show-w { background:rgba(25,25,25,.97); }
#rv-feedback-icon    { font-size:56px; line-height:1; }
#rv-feedback-user    { font-size:14px; margin-top:10px; color:var(--red); text-align:center; opacity:.75; }
#rv-feedback-correct { font-size:16px; font-weight:700; margin-top:6px; color:var(--label); text-align:center; }
#rv-feedback-explain { font-size:13px; opacity:.6; margin-top:14px; max-width:380px; text-align:center; line-height:1.6; color:var(--label); }
#rv-feedback-ok { margin-top:20px; width:100%; max-width:280px; }
#rv-feedback-user { font-size:14px; margin-top:10px; color:var(--red); text-align:center; opacity:.75; }
.diff-ok  { color:var(--green); }
.diff-err { color:var(--red); text-decoration:underline dotted; }
.rv-tts-btn { background:none; border:none; cursor:pointer; font-size:16px; opacity:.45; transition:opacity .15s; padding:2px 4px; line-height:1; vertical-align:middle; }
.rv-tts-btn:hover { opacity:.9; }
#rv-summary-actions { display:flex; gap:8px; margin-top:16px; flex-wrap:wrap; justify-content:center; }
#rv-summary-actions .btn { min-width:140px; }
.rv-study { display:flex; flex-direction:column; align-items:center; text-align:center; gap:10px; }
.rv-study-prompt { font-size:22px; font-weight:600; margin:0; }
.rv-study-divider { width:40px; height:2px; background:var(--accent,#7c5af5); border-radius:2px; opacity:.4; margin:2px 0; }
.rv-study-answer { font-size:20px; color:var(--green,#4caf50); margin:0; font-weight:500; }
.rv-card-top[data-type="srs_term"] .rv-study-answer { font-size:15px; line-height:1.55; font-weight:400; }
.rv-study-extra { font-size:14px; color:var(--text-muted,rgba(255,255,255,.5)); margin:0; }
.rv-study-example { font-style:italic; }
.rv-study-mnemonic { background:rgba(255,255,255,.06); border-left:3px solid var(--accent,#7c5af5); border-radius:6px; padding:8px 12px; font-size:14px; text-align:left; width:100%; box-sizing:border-box; }
.rv-study-mnem-label { margin-right:6px; }
.rv-study-btn { margin-top:10px; min-width:160px; }

/* ===== MNEMONIC STUDY GRID ===== */
.rv-study-card { flex:1; min-height:0; display:flex; flex-direction:column; }
.rv-study-grid { display:grid; grid-template-columns:1fr 1fr 1fr; grid-template-rows:minmax(0,1fr); gap:12px; width:100%; flex:1; min-height:280px; }
.rv-left-col { display:flex; flex-direction:column; gap:10px; }
.rv-forecast-col { display:flex; flex-direction:column; gap:8px; overflow-y:auto; min-height:0; }
#srs-app .rv-forecast-col #rv-fc-content { display:flex; flex-direction:column; gap:8px; }
.rv-inner-card { background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow); border:var(--border); padding:14px 16px; box-sizing:border-box; color:var(--label); }
.rv-mnem-card { flex:1; min-width:0; display:flex; flex-direction:column; gap:8px; }
.rv-mnem-nav-row { display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,.07); border-radius:20px; padding:2px; flex-shrink:0; }
.rv-mnem-nav-btn { background:none; border:none; cursor:pointer; font-size:16px; padding:4px 12px; border-radius:18px; line-height:1; color:var(--label); opacity:.6; transition:all .15s; }
.rv-mnem-nav-btn:hover:not(:disabled) { background:var(--card); box-shadow:var(--shadow); opacity:1; }
.rv-mnem-nav-btn:disabled { opacity:.2; cursor:default; }
.rv-mnem-nav-counter { font-size:11px; font-weight:600; opacity:.45; padding:0 2px; min-width:24px; text-align:center; }
.rv-card-hdr { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.6px; margin:-14px -16px 0; padding:14px 16px; border-bottom:1px solid rgba(0,0,0,.09); display:flex; align-items:center; gap:6px; flex-shrink:0; white-space:nowrap; }
.rv-card-hdr--center { justify-content:center; text-align:center; }
.rv-card-hdr-text { flex:1; display:flex; flex-direction:column; gap:2px; align-items:center; text-align:center; }
.rv-mnem-techname { font-size:11px; font-weight:500; opacity:.65; text-transform:none; letter-spacing:0; }
.rv-mnem-text { flex:1; font-size:13px; line-height:1.65; min-height:40px; }
.rv-mnem-loading { opacity:.45; font-style:italic; animation:rv-pulse 1.2s ease-in-out infinite; }
.rv-mnem-error-text { color:var(--red); font-size:12px; }
.rv-mnem-btns { display:flex; gap:6px; }
.rv-mnem-btns .btn { flex:1; font-size:11px; padding:6px 4px; }
.rv-card-col { display:flex; flex-direction:column; min-height:0; }
.rv-card-top { display:flex; flex-direction:column; align-items:stretch; flex:1; min-height:0; }
.rv-card-prompt-area { display:flex; flex-direction:column; align-items:center; text-align:center; gap:7px; padding:8px 0 6px; flex-shrink:0; }
.rv-card-answer-area { flex:1; min-height:0; overflow-y:auto; display:flex; flex-direction:column; align-items:center; text-align:center; gap:7px; padding:4px 0 8px; }
.rv-card-bottom { display:flex; flex-direction:column; gap:8px; flex:1; min-height:0; }
.rv-assoc-list { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:5px; min-height:36px; }
.rv-assoc-item { background:rgba(0,0,0,.04); border-radius:7px; padding:6px 8px; display:flex; flex-direction:column; gap:2px; }
.rv-assoc-item-hdr { display:flex; align-items:center; gap:4px; }
.rv-assoc-item-tech { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.4px; opacity:.4; flex:1; }
.rv-assoc-del { background:none; border:none; cursor:pointer; font-size:11px; color:var(--red); opacity:0; transition:opacity .15s, background .15s; padding:3px 5px; border-radius:5px; flex-shrink:0; }
.rv-assoc-item:hover .rv-assoc-del { opacity:.5; }
.rv-assoc-del:hover { background:rgba(255,59,48,.1) !important; opacity:1 !important; }
.rv-assoc-item-text { font-size:12px; line-height:1.45; }
.rv-assoc-empty { font-size:12px; opacity:.3; font-style:italic; text-align:center; padding:6px 0; }
@keyframes rv-pulse { 0%,100%{opacity:.45} 50%{opacity:.2} }

/* ===== MNEMONIC LIBRARY (inline settings-popup) ===== */
.mnem-lib-item { background:rgba(0,0,0,.05); border-radius:8px; padding:10px 12px; display:flex; flex-direction:column; gap:5px; position:relative; transition:opacity .15s; }
.mnem-lib-item.disabled { opacity:.45; }
.mnem-lib-item-hdr { display:flex; align-items:center; gap:8px; }
.mnem-lib-item-name { font-size:13px; font-weight:700; flex:1; }
.mnem-lib-toggle { position:relative; width:34px; height:20px; flex-shrink:0; cursor:pointer; }
.mnem-lib-toggle input { opacity:0; width:0; height:0; position:absolute; }
.mnem-lib-toggle-track { position:absolute; inset:0; border-radius:10px; background:var(--gray); cursor:pointer; transition:background .2s; }
.mnem-lib-toggle input:checked + .mnem-lib-toggle-track { background:var(--accent); }
.mnem-lib-toggle-track::after { content:''; position:absolute; top:3px; left:3px; width:14px; height:14px; border-radius:50%; background:#fff; transition:transform .2s; box-shadow:0 1px 3px rgba(0,0,0,.3); }
.mnem-lib-toggle input:checked + .mnem-lib-toggle-track::after { transform:translateX(14px); }
.mnem-lib-item-prompt { font-size:12px; opacity:.5; line-height:1.5; }
.mnem-lib-item-del { background:none; border:none; cursor:pointer; font-size:13px; color:var(--red); opacity:0; transition:opacity .15s, background .15s; padding:5px 7px; border-radius:7px; flex-shrink:0; }
.mnem-lib-item:hover .mnem-lib-item-del { opacity:.55; }
.mnem-lib-item-del:hover { background:rgba(255,59,48,.1) !important; opacity:1 !important; }

/* XP pop */
.rv-xp-pop { animation:rv-pop .35s cubic-bezier(.36,.07,.19,.97); }

/* Streak pop */
.rv-streak-toast { position:fixed; top:40%; left:50%; transform:translate(-50%,-50%); font-size:26px; font-weight:800; color:var(--accent); background:var(--card); padding:12px 24px; border-radius:30px; box-shadow:var(--shadow-hover); animation:rv-streakpop .9s ease forwards; pointer-events:none; z-index:200; white-space:nowrap; }

/* Session summary */
#rv-summary { text-align:center; padding:8px 0 4px; }
.rv-stat-row { display:flex; justify-content:center; gap:28px; flex-wrap:wrap; margin:0 0 8px; }
.rv-stat { text-align:center; }
.rv-stat-val   { font-size:36px; font-weight:800; color:var(--accent); line-height:1; }
.rv-stat-label { font-size:11px; opacity:.45; margin-top:4px; }

@keyframes rv-flash     { 0%{opacity:0} 25%{opacity:1} 75%{opacity:1} 100%{opacity:0} }
@keyframes rv-shake     { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-7px)} 60%{transform:translateX(7px)} }
@keyframes rv-pop       { 0%{transform:scale(1)} 50%{transform:scale(1.45)} 100%{transform:scale(1)} }
@keyframes rv-streakpop { 0%{opacity:0;transform:translate(-50%,-60%) scale(.5)} 25%{opacity:1;transform:translate(-50%,-50%) scale(1.05)} 70%{opacity:1;transform:translate(-50%,-50%) scale(1)} 100%{opacity:0;transform:translate(-50%,-42%) scale(.9)} }

/* ===== INPUTS ===== */
#srs-app .input,
#srs-app .textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 16px;
  border: var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: var(--transition);
}
#srs-app .input::placeholder,
#srs-app .textarea::placeholder {
  color: var(--gray);
  font-weight: 400;
}
#srs-app .input:hover,
#srs-app .textarea:hover {
  box-shadow: var(--shadow-hover);
}
#srs-app .input:focus,
#srs-app .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent), var(--shadow);
}
#srs-app .textarea { min-height: 100px; resize: vertical; }
#srs-app .search {
  flex: 1;
  min-width: 200px;
  min-height: 44px;
  padding: 11px 16px;
  border: var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: var(--transition);
}
#srs-app .search::placeholder { color: var(--gray); }
#srs-app .search:hover { box-shadow: var(--shadow-hover); }
#srs-app .search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent), var(--shadow);
}

/* ===== CARDS ===== */
#srs-app .stat-card {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  min-height: 90px;
}
#srs-app .stat-card:hover {
  box-shadow: var(--shadow-hover);
}
#srs-app .stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin: 0 0 6px 0; position: relative; z-index: 1; }
#srs-app .stat-val {
  font-size: 130px;
  font-weight: 800;
  margin: 0;
  position: absolute;
  right: 4px;
  bottom: -24px;
  line-height: 1;
  color: color-mix(in srgb, var(--accent) 100%, transparent) !important;
  opacity: .35;
  pointer-events: none;
  z-index: 0;
}

#srs-app .review-card {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  margin-bottom: 16px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
}
#srs-app .review-card h3 { font-size: 20px; font-weight: 600; margin: 0 0 12px 0; }
#srs-app .review-card p { margin: 0; }

#srs-app .lib-item {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
#srs-app .lib-item:hover {
  box-shadow: var(--shadow-hover);
}
#srs-app .lib-item h4 { font-size: 14px; font-weight: 600; margin: 0 0 4px 0; }
#srs-app .lib-item p { font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#srs-app .lib-item-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
#srs-app .badge { font-size: 11px; background: var(--gray6); padding: 3px 10px; border-radius: var(--radius); font-weight: 500; }

/* ===== ANIMATIONS ===== */
@keyframes srs-fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes srs-lib-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes srs-fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes srs-scaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes srs-card-from-left  { from { opacity:0; transform:translateX(-60px); } to { opacity:1; transform:translateX(0); } }
@keyframes srs-card-from-right { from { opacity:0; transform:translateX( 60px); } to { opacity:1; transform:translateX(0); } }
/* srs-scaleIn on view switch handled manually in go() — not auto */
#srs-app .glass { transition: opacity .2s ease, transform .2s ease; }
#srs-app [id^="f-"] { transition: opacity .2s ease, transform .2s ease; }
#srs-app [id^="f-"].fade-out { opacity: 0; transform: translateY(6px); }
#srs-app [id^="f-"].fade-in { /* container shown instantly — children animate via JS */ }

/* ===== LAYOUT ===== */
#srs-app .section { margin-bottom: 16px; }
#srs-app .section:last-child { margin-bottom: 0; }
#srs-app .view { display: none; }
#srs-app .view.active { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

#srs-app .grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 16px; }
#srs-app .grid-5 { display: grid; grid-template-columns: repeat(6,1fr); gap: 10px; }
#srs-app .grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
#srs-app .flex-row { display: flex; gap: 12px; }
#srs-app .flex-1 { flex: 1; }
#srs-app .lib-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 12px; }
#srs-app .lib-top { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
#srs-app .lib-top .search { flex: 1; min-width: 80px; margin: 0; }
#srs-app .lib-type-row { display: flex; gap: 5px; flex-shrink: 0; }
#srs-app .lib-flt {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 44px; padding: 0 14px;
  background: var(--card); border: var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 15px; font-weight: 500;
  color: var(--label); cursor: pointer; white-space: nowrap;
  transition: var(--transition); font-family: var(--font);
}
#srs-app .lib-flt:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
#srs-app .lib-flt:active { transform: translateY(0); box-shadow: var(--shadow); }
#srs-app .lib-flt.active { background: color-mix(in srgb, var(--accent) 30%, white); color: rgba(0,0,0,.8) !important; font-weight: 600; }
#srs-app.dark .lib-flt.active { background: color-mix(in srgb, var(--accent) 30%, rgba(40,40,40,1)); color: rgba(255,255,255,.9) !important; }
#srs-app .form-group { margin-bottom: 16px; }

/* Progress */
#srs-app .progress { height: 4px; background: var(--gray5); border-radius: var(--radius); margin-bottom: 24px; }
#srs-app .progress-bar { height: 100%; background: var(--accent); border-radius: var(--radius); transition: width .3s; }

/* Misc */
#srs-app .empty { text-align: center; padding: 40px; grid-column: 1 / -1; }
#srs-app .toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: var(--white) !important;
  padding: 14px 24px; border-radius: 20px; z-index: 1000;
  font-size: 15px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

/* ===== LIQUID GLASS ===== */
#srs-app .glass {
  position: relative;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(16px) saturate(1.4) brightness(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(1.4) brightness(1.05);
  border-radius: 24px;
  border: none;
  box-shadow:
    0 12px 48px rgba(0,0,0,.35),
    0 4px 12px rgba(0,0,0,.15),
    inset 0 0 0 .5px rgba(255,255,255,.3);
  padding: 28px 32px;
  width: 60%;
  height: 60vh;
  overflow: hidden;
  margin: 20px auto;
}
#srs-app #v-add .glass { height: auto; overflow: visible; }
#srs-app #v-library .glass { height: 80vh; overflow-y: auto; overflow-x: hidden; }
#srs-app #v-home .glass { height: auto; overflow: visible; }
#srs-app #v-forecast .glass { width: 30%; height: 85vh; display: flex; flex-direction: column; align-items: stretch; padding: 24px 20px; }
#srs-app #v-forecast .fc-content { flex:1; overflow-y:auto; min-height:0; margin-bottom:12px; padding:16px 8px; display:flex; flex-direction:column; gap:8px; }
#srs-app #v-forecast .fc-bucket, #srs-app .rv-forecast-col .fc-bucket { background:var(--card); border:var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:10px 12px; }
#srs-app #v-forecast .fc-bucket-head, #srs-app .rv-forecast-col .fc-bucket-head { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
#srs-app #v-forecast .fc-bucket-lbl, #srs-app .rv-forecast-col .fc-bucket-lbl { font-size:11px; font-weight:600; padding:2px 8px; border-radius:20px; border:1px solid; white-space:nowrap; flex-shrink:0; color:var(--chart-text); }
#srs-app #v-forecast .fc-bar-track, #srs-app .rv-forecast-col .fc-bar-track { flex:1; height:6px; border-radius:4px; background:rgba(0,0,0,.07); overflow:hidden; }
#srs-app #v-forecast .fc-bar-fill, #srs-app .rv-forecast-col .fc-bar-fill { height:100%; border-radius:4px; width:0%; transition:width .5s cubic-bezier(.4,0,.2,1); }
#srs-app.dark #v-forecast .fc-bar-track, #srs-app.dark .rv-forecast-col .fc-bar-track { background:rgba(255,255,255,.09); }
#srs-app #v-forecast .fc-bucket-count, #srs-app .rv-forecast-col .fc-bucket-count { font-size:11px; font-weight:800; opacity:.55; flex-shrink:0; }
#srs-app #v-forecast .fc-words, #srs-app .rv-forecast-col .fc-words { display:flex; flex-wrap:wrap; gap:4px; margin-top:2px; }
#srs-app #v-forecast .fc-word, #srs-app .rv-forecast-col .fc-word { font-size:10px; padding:2px 7px; border-radius:20px; background:rgba(0,0,0,.06); border:1px solid rgba(0,0,0,.12); font-weight:500; white-space:nowrap; color:var(--chart-text); cursor:pointer; }
#srs-app #v-forecast .fc-word:hover, #srs-app .rv-forecast-col .fc-word:hover { background:rgba(0,0,0,.13); }
#srs-app.dark #v-forecast .fc-word, #srs-app.dark .rv-forecast-col .fc-word { background:rgba(255,255,255,.08); border-color:rgba(255,255,255,.15); }
#srs-app .glass.no-flip-anim { animation: none !important; }

/* Field row: label-badge + input inline */
#srs-app .field-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 12px;
}
#srs-app .field-label {
  width: 155px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  min-height: 44px;
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
#srs-app .field-row:has([data-req="1"]) .field-label::after {
  content: ' *';
  color: #888;
  opacity: .7;
  font-weight: 700;
}
#srs-app #add-form .sync-btn,
#srs-app #edit-popup .sync-btn {
  position: static;
  width: 18px; height: 18px; flex-shrink: 0;
  background: none; border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 1; transition: opacity .15s ease;
}
#srs-app #add-form .sync-btn svg path,
#srs-app #edit-popup .sync-btn svg path { fill: var(--accent); transition: fill .15s ease; }
#srs-app #add-form .sync-btn.inactive svg path,
#srs-app #edit-popup .sync-btn.inactive svg path { fill: #888; }
#srs-app.dark #add-form .sync-btn.inactive svg path,
#srs-app.dark #edit-popup .sync-btn.inactive svg path { fill: #aaa; }
#srs-app #add-form .sync-btn.inactive,
#srs-app #edit-popup .sync-btn.inactive { opacity: .35; }
#srs-app #add-form .sync-btn:hover,
#srs-app #edit-popup .sync-btn:hover { opacity: .85; }
#srs-app #add-form .sync-btn.inactive:hover,
#srs-app #edit-popup .sync-btn.inactive:hover { opacity: .6; }
/* Two-column label layout: [sync-col | divider | text-col] */
#srs-app .field-label:has(.sync-col) { padding: 0; justify-content: flex-start; gap: 0; }
#srs-app .field-label .sync-col { width: 34%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
#srs-app .field-label .sync-divider { width: 1px; align-self: stretch; background: rgba(0,0,0,.1); flex-shrink: 0; }
#srs-app.dark .field-label .sync-divider { background: rgba(255,255,255,.12); }
#srs-app .field-label .sync-text-col { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
/* Suppress ::after star on restructured labels (star is added via JS) */
#srs-app .field-label:has(.sync-col)::after { content: none !important; }
#srs-app .field-label.no-sync .sync-col,
#srs-app .field-label.no-sync .sync-divider { display: none; }
#srs-app .field-label.no-sync .sync-text-col { flex: 1 1 100%; }
#srs-app .field-row:has(.textarea) { align-items: flex-start; }
#srs-app .field-row:has(.textarea) .field-label { height: 44px; }
#srs-app .field-row .input,
#srs-app .field-row .textarea {
  flex: 1;
  margin: 0;
}

/* ===== SETTINGS BUTTONS ===== */
#srs-app .settings-bar {
  position: fixed;
  top: 46px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 100;
}
#srs-app .settings-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 8px rgba(0,0,0,.15), inset 0 0 0 .5px rgba(255,255,255,.3);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
#srs-app .settings-btn:hover { background-color: rgba(255,255,255,.35); }
/* Bulk Add button: only visible when Add view is active.
   Sits first in the settings bar; 16px padding on both sides of the centered divider. */
#srs-app .bulk-add-wrap { display: none; position: relative; align-items: center; padding: 0 16px; margin-right: 8px; }
#srs-app .bulk-add-wrap::after { content: ''; position: absolute; top: 25%; bottom: 25%; right: 0; width: 1px; background: rgba(0,0,0,.12); }
#srs-app.dark .bulk-add-wrap::after { background: rgba(255,255,255,.15); }
#srs-app:has(#v-add.active) .bulk-add-wrap { display: inline-flex; }
#srs-app .bulk-add-btn { padding: 10px 18px; font-size: 14px; border-radius: var(--radius); white-space: nowrap; }
/* Bulk Add view: vertical narrow glass like Forecast */
#srs-app #v-bulk-add .glass { width: 30%; height: 85vh; display: flex; flex-direction: column; align-items: stretch; padding: 24px 20px; }
#srs-app #v-bulk-add #bulk-step-input,
#srs-app #v-bulk-add #bulk-step-review { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; }
#srs-app .bulk-sub { font-size: 12px; opacity: .6; text-align: center; margin: 0 0 10px; flex-shrink: 0; }
#srs-app #bulk-words-input { flex: 1 1 0; min-height: 0; width: 100%; resize: none; font-family: var(--font); font-size: 14px; line-height: 1.45; }
#srs-app .bulk-progress { font-size: 12px; font-weight: 600; opacity: .55; text-align: center; margin: 0 0 10px; letter-spacing: .5px; flex-shrink: 0; }
/* Pill switch */
#srs-app .pill-switch { display: flex; background: rgba(0,0,0,.07); border-radius: 999px; padding: 4px; margin: 0 0 14px; gap: 4px; flex-shrink: 0; }
#srs-app.dark .pill-switch { background: rgba(255,255,255,.07); }
#srs-app .pill-switch .pill { flex: 1; padding: 8px 12px; border-radius: 999px; border: none; background: transparent; cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--label); opacity: .55; transition: all .2s ease; }
#srs-app .pill-switch .pill.active { background: var(--card); opacity: 1; box-shadow: var(--shadow); }
#srs-app .pill-switch .pill:hover:not(.active) { opacity: .8; }
/* Active bulk form fills the remaining vertical space; its textarea field grows */
#srs-app #v-bulk-add .bulk-form { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; gap: 8px; }
#srs-app #v-bulk-add .bulk-form .field-row { margin: 0; flex-shrink: 0; }
#srs-app #v-bulk-add .bulk-form .field-row:has(textarea) { flex: 1 1 0; min-height: 0; align-items: stretch; }
#srs-app #v-bulk-add .bulk-form textarea.textarea { flex: 1 1 0; height: 100%; min-height: 0; resize: none; }
#srs-app #v-bulk-add #bulk-next-btn,
#srs-app #v-bulk-add #bulk-import-btn { flex-shrink: 0; }
#srs-app .logout-btn { background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNDQ0IiBzdHJva2Utd2lkdGg9IjIuMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNOSAyMUg1YTIgMiAwIDAgMS0yLTJWNWEyIDIgMCAwIDEgMi0yaDQiLz48cG9seWxpbmUgcG9pbnRzPSIxNiAxNyAyMSAxMiAxNiA3Ii8+PGxpbmUgeDE9IjIxIiB5MT0iMTIiIHgyPSI5IiB5Mj0iMTIiLz48L3N2Zz4="); background-repeat: no-repeat; background-position: center; background-size: 18px 18px; }
#srs-app .settings-popup {
  display: none;
  position: absolute;
  top: 48px;
  right: 0;
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(24px) saturate(1.6) brightness(1.08);
  -webkit-backdrop-filter: blur(24px) saturate(1.6) brightness(1.08);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,.28), 0 4px 12px rgba(0,0,0,.12), inset 0 0 0 .5px rgba(255,255,255,.35);
  border: none;
  color: var(--label);
}
#srs-app .settings-popup.open,
#srs-app .settings-popup[open] { display: block; }
#srs-app .settings-popup::backdrop { background: transparent; }
#srs-app .theme-section { padding: 8px 0; border-bottom: 1px solid rgba(128,128,128,.1); }
#srs-app .theme-section:last-child { border-bottom: none; padding-bottom: 0; }
#srs-app .theme-section-header { font-size: 12px; font-weight: 600; margin-bottom: 8px; opacity: .7; display: flex; align-items: center; justify-content: center; gap: 6px; }
#srs-app .theme-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}
#srs-app .color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
#srs-app .color-swatch {
  width: 100%; aspect-ratio: 1; border-radius: 8px; border: 2px solid transparent;
  cursor: pointer; transition: all .15s ease;
}
#srs-app .color-swatch:hover { transform: scale(1.15); }
#srs-app .color-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
#srs-app .color-hue-wrap { margin-bottom: 10px; }
#srs-app .color-hue {
  -webkit-appearance: none; appearance: none; width: 100%; height: 12px; border-radius: 6px; outline: none; cursor: pointer;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
#srs-app .color-hue::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,.2); box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
#srs-app .color-preview-row { display: flex; align-items: center; gap: 8px; }
#srs-app .color-preview { width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(0,0,0,.1); flex-shrink: 0; }
#srs-app .color-hex {
  flex: 1; padding: 6px 8px; border: 1px solid rgba(0,0,0,.1); border-radius: 8px;
  font-size: 13px; font-family: monospace; text-align: center;
}
#srs-app .settings-popup input[type="file"] { display: none; }
#srs-app .settings-popup .file-btn {
  padding: 6px 12px;
  background: var(--gray5);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  border: none;
  font-family: var(--font);
}

/* ===== DARK THEME ===== */
#srs-app.dark { --label: #fff; --card: rgba(30,30,30,.8); --gray5: #333; --gray6: #1a1a1a; --chart-text: rgba(255,255,255,1); --chart-grid: rgba(255,255,255,.08); --border: none; }
#srs-app.dark .dark-overlay { display: block; }
#srs-app .dark-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); pointer-events: none; z-index: 0; }
#srs-app.dark * { color: #fff; }
#srs-app.dark .stat-card,
#srs-app.dark .chart-card,
#srs-app.dark .btn,
#srs-app.dark .btn-gray,
#srs-app.dark .icon-btn,
#srs-app.dark .input,
#srs-app.dark .textarea,
#srs-app.dark .search,
#srs-app.dark .field-label,
#srs-app.dark .lib-item,
#srs-app.dark .review-card {
  background: rgba(40,40,40,.8);
  border-color: rgba(255,255,255,.1);
}
#srs-app.dark .input::placeholder,
#srs-app.dark .textarea::placeholder,
#srs-app.dark .search::placeholder { color: #888; }
#srs-app.dark .glass {
  background: rgba(0,0,0,.15);
  box-shadow: 0 8px 32px rgba(0,0,0,.4), inset 0 0 0 .5px rgba(255,255,255,.15);
}
#srs-app.dark .stat-val { color: color-mix(in srgb, var(--accent) 100%, transparent) !important; opacity: .4; }
#srs-app.dark .btn-filled { background: var(--accent) !important; }
#srs-app.dark .btn-filled:hover { background: var(--accent-active) !important; }
#srs-app.dark .settings-popup { background: rgba(15,15,15,.3); box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3), inset 0 0 0 .5px rgba(255,255,255,.08); }
#srs-app.dark .tag-btn,
#srs-app.dark .tag-filter-badge { background: rgba(40,40,40,.8); border-color: rgba(255,255,255,.1); }
#srs-app.dark .tag-btn.selected { border-color: currentColor; }
#srs-app.dark .star-popup-item:hover { background: rgba(255,255,255,.08); }
#srs-app.dark .rv-card-hdr { border-bottom-color:rgba(255,255,255,.12); }
#srs-app.dark .rv-assoc-item { background: rgba(255,255,255,.06); }

/* ===== CHARTS ===== */
#srs-app .charts-row { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 12px; margin-bottom: 16px; }
#srs-app .chart-card { background: var(--card); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; align-items: stretch; transition: box-shadow .3s ease; }
/* Cohort matrix — clean style, hover row/col highlights */
#srs-app .chart-card-cohort { width: 100%; min-width: 0; overflow: hidden; max-height: 320px; display: flex; flex-direction: column; }
#srs-app .cohort-hscroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
#srs-app .cohort-hscroll::-webkit-scrollbar { height: 4px; }
#srs-app .cohort-hscroll::-webkit-scrollbar-thumb { background: rgba(128,128,128,.3); border-radius: 2px; }
#srs-app .cohort-content { display: inline-block; vertical-align: top; }
#srs-app .cohort-scroll { overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#srs-app .cohort-scroll::-webkit-scrollbar { height: 4px; width: 4px; }
#srs-app .cohort-scroll::-webkit-scrollbar-thumb { background: rgba(128,128,128,.3); border-radius: 2px; }
/* Days header — separate table OUTSIDE the scroll wrapper. Same rounded cells & spacing. */
#srs-app .cohort-table-days { margin-top: 2px; }
#srs-app .cohort-table-days td { font-size: 9px; font-weight: 600; opacity: 1; padding: 6px 0 4px; line-height: 1.2; white-space: nowrap; height: auto; transition: opacity .2s ease; }
#srs-app .cohort-table-days td.cohort-today { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#srs-app .cohort-table { border-collapse: separate; border-spacing: 2px; border: 0; width: 100%; outline: none; table-layout: fixed; }
#srs-app .cohort-table thead, #srs-app .cohort-table tbody, #srs-app .cohort-table tfoot,
#srs-app .cohort-table tr, #srs-app .cohort-table th, #srs-app .cohort-table td { border: 0 !important; outline: none; box-shadow: none; }
#srs-app .cohort-table th, #srs-app .cohort-table td { padding: 0; margin: 0; text-align: center; vertical-align: middle; height: 24px; line-height: 1; border-radius: 8px; overflow: hidden; background-clip: padding-box; background-color: rgba(0,0,0,.03); transition: background-color .6s ease, color .6s ease; }
#srs-app.dark .cohort-table th, #srs-app.dark .cohort-table td { background-color: rgba(255,255,255,.04); }
#srs-app .cohort-table tr.cohort-hl td,
#srs-app .cohort-table td.cohort-hl { transition: background-color .15s ease, color .15s ease; }
#srs-app .cohort-cell { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 0; font-size: 11px; font-weight: 800; line-height: 1; border-radius: 0; color: #fff; white-space: nowrap; box-sizing: border-box; opacity: 1; transition: opacity .2s ease; position: relative; }
/* Status overlays */
#srs-app .cohort-cell.cohort-st-overdue { box-shadow: inset 0 0 0 2px #ff3b30; }
#srs-app .cohort-cell.cohort-st-done { color: rgba(0,0,0,.5) !important; }
#srs-app .cohort-cell.cohort-st-future { opacity: .55; }
#srs-app .cohort-cell.q  { background: rgba(128,128,128,.2); color: var(--label); font-weight: 600; opacity: .55; }
#srs-app .cohort-cell.done { background: rgba(52,199,89,.7); }
/* Today highlight — only the date cell in the days-table; body cells stay clean. */
#srs-app .cohort-table-days td.cohort-today { background: color-mix(in srgb, var(--accent) 10%, transparent); }
/* Hover highlights — one row + one column, accent colour @ higher opacity */
/* Forecast-style hover: everything DIMS when something is hovered, focus stays bright */
#srs-app .cohort-content.cohort-hovering .cohort-cell { opacity: .15; transition: opacity .2s ease; }
#srs-app .cohort-content.cohort-hovering .cohort-table-days td { opacity: .2; transition: opacity .2s ease; }
/* Hovered column un-dims */
#srs-app .cohort-content.cohort-hovering td.cohort-hl .cohort-cell { opacity: 1; }
#srs-app .cohort-content.cohort-hovering .cohort-table-days td.cohort-hl { opacity: 1; }
/* Today stays bright always (even during hover of others) */
#srs-app .cohort-content.cohort-hovering td.cohort-today .cohort-cell,
#srs-app .cohort-content.cohort-hovering .cohort-table-days td.cohort-today { opacity: 1; }
/* No rounded corners on cells — keeps row/column band intersections perfectly continuous. */
/* Legend — centered, bottom */
#srs-app .cohort-legend { display: flex; gap: 8px 12px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 10px; }
#srs-app .cohort-legend .lg-head { font-size: 11px; font-weight: 700; opacity: .8; margin-right: 4px; }
#srs-app .cohort-legend .lg { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; opacity: .65; }
#srs-app .cohort-legend .lg-sw { width: 10px; height: 10px; border-radius: 50%; }
#srs-app .chart-eyebrow { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--chart-text); margin: -14px -14px 10px; padding: 8px 14px; border-bottom: 1.5px solid rgba(0,0,0,.18); text-align: center; align-self: stretch; }
#srs-app.dark .chart-eyebrow { border-bottom-color: rgba(255,255,255,.2); }
#srs-app .chart-card:hover { box-shadow: var(--shadow-hover); }
#srs-app .chart-card-pie { align-items: center; }
/* Cap heights so charts stay proportional at single-row layout */
#srs-app .chart-card-pie,
#srs-app .chart-card-forecast { max-height: 320px; overflow: hidden; }
#srs-app .chart-card-pie svg { max-width: 100%; max-height: 220px; display: block; margin: 0 auto; }
#srs-app .chart-card-bar { min-width: 0; grid-column: span 2; }
#srs-app .forecast-chart-wrap { flex: 1; width: 100%; overflow: visible; display: flex; flex-direction: row; align-items: stretch; gap: 5px; }
#srs-app .fc-labels { display: flex; flex-direction: column; justify-content: space-around; padding: 6px 0; flex-shrink: 0; width: 50px; }
#srs-app .fc-labels span { font-size: 9px; display: flex; align-items: center; justify-content: center; padding: 2px 6px; border-radius: 20px; border: 1px solid; white-space: nowrap; font-weight: 600; color: var(--chart-text); transition: opacity .2s ease; cursor: default; }
#srs-app .fc-labels:hover span { opacity: .3; }
#srs-app .fc-labels span:hover { opacity: 1 !important; }
#srs-app .chart-title { font-size: 11px; font-weight: 700; color: var(--label); margin: 0 0 10px; opacity: .45; align-self: flex-start; letter-spacing: .5px; }
#srs-app #pie-chart { width: 100%; height: auto; }
#srs-app .bar-chart-wrap { flex: 1; width: 100%; overflow-x: auto; overflow-y: hidden; }
#srs-app #bar-chart { display: block; width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,.22)); }
#srs-app #forecast-chart { display: block; flex: 1; height: 100%; min-width: 0; }
#srs-app.dark #forecast-chart .fc-track { fill: rgba(255,255,255,.08) !important; }
/* Forecast: JS controls opacity, CSS just transitions */
#srs-app #forecast-chart .fc-row { transition: opacity .2s ease; }
/* Bar chart column hover — only dim when hovering a specific bar */
#srs-app #bar-chart .bar-col { transition: opacity .2s ease; }
#srs-app #bar-chart:has(.bar-col:hover) .bar-col { opacity: .35; }
#srs-app #bar-chart .bar-col:hover { opacity: 1 !important; }
/* Pie: JS controls both arc and legend opacity */
#srs-app #pie-chart g[filter] circle { transition: opacity .2s ease; }
#srs-app .chart-legend span { transition: opacity .2s ease; }
#srs-app .forecast-action-btn { margin-top: 10px; }
#srs-app .chart-legend { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; margin-top: 10px; justify-content: center; }
#srs-app .chart-legend span { font-size: 9px; display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
#srs-app .chart-legend i { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ===== LOGIN FORM ===== */
#srs-app #v-login .glass { height: auto; overflow: visible; max-width: 380px; width: 90%; }
#srs-app .login-title { font-size: 20px; font-weight: 700; text-align: center; margin: 0 0 6px; }
#srs-app .login-sub { font-size: 13px; text-align: center; opacity: .55; margin: 0 0 20px; }
#srs-app .login-error { color: var(--red) !important; font-size: 13px; text-align: center; margin-top: 8px; min-height: 18px; }

/* ===== TAG SYSTEM ===== */
#srs-app .tag-row { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; align-items: center; }
#srs-app .tag-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px 4px 6px; border-radius: 20px; border: 1.5px solid transparent;
  font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: all .2s ease; opacity: 1; background: var(--card);
  font-family: var(--font);
}
#srs-app .tag-btn:hover { box-shadow: var(--shadow); }
#srs-app .tag-btn.selected { border-color: currentColor; }
#srs-app .tag-btn .tag-emoji { font-size: 14px; }
#srs-app .tag-btn-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; border: 1.5px dashed var(--gray);
  font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap;
  background: var(--card); color: var(--label); font-family: var(--font);
  transition: all .2s ease;
}
#srs-app .tag-btn-add:hover { border-color: var(--accent); color: var(--accent); }

/* Tag popup (modal) */
#srs-app .srs-popup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: none; align-items: center; justify-content: center;
  animation: srs-fadeIn .2s ease-out;
}
#srs-app .srs-popup-overlay.open { display: flex; }
#srs-app .srs-popup {
  background: rgba(255,255,255,.85); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 16px; padding: 20px; min-width: 300px; max-width: 380px; width: 90%;
  box-shadow: 0 12px 48px rgba(0,0,0,.3), inset 0 0 0 .5px rgba(255,255,255,.3);
  animation: srs-scaleIn .25s ease-out;
}
#srs-app.dark .srs-popup { background: rgba(30,30,30,.9); }
#srs-app .srs-popup h3 { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
#srs-app .srs-popup .popup-field { margin-bottom: 12px; }
#srs-app .srs-popup .popup-field label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; opacity: .6; }
#srs-app .srs-popup .popup-field input[type="text"] {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: var(--border);
  background: var(--card); font-family: var(--font); font-size: 14px;
  color: var(--label); box-shadow: var(--shadow);
}
#srs-app .srs-popup .popup-field .emoji-input { width: 50px; text-align: center; font-size: 20px; padding: 6px; }
#srs-app .srs-popup .popup-row { display: flex; gap: 10px; align-items: flex-end; }
#srs-app .srs-popup .popup-row > .popup-field:first-child { flex: 0 0 auto; }
#srs-app .srs-popup .popup-row > .popup-field:last-child { flex: 1; }
#srs-app .srs-popup .color-section { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#srs-app .srs-popup .color-section label.accent-check { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; cursor: pointer; text-transform: none; letter-spacing: 0; opacity: 1; }
#srs-app .srs-popup .color-section .color-picker-row { display: flex; gap: 8px; align-items: center; width: 100%; margin-top: 6px; }
#srs-app .srs-popup .color-section .tag-hue-slider { flex: 1; height: 24px; border-radius: 12px; -webkit-appearance: none; appearance: none; background: linear-gradient(to right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00); outline: none; cursor: pointer; }
#srs-app .srs-popup .color-section .tag-hue-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid rgba(0,0,0,.2); box-shadow: 0 1px 4px rgba(0,0,0,.2); cursor: pointer; }
#srs-app .srs-popup .tag-color-preview { width: 28px; height: 28px; border-radius: 8px; border: var(--border); flex-shrink: 0; }
#srs-app .srs-popup .tag-hex-input { width: 80px; text-align: center; font-size: 12px; font-family: monospace; }
#srs-app .srs-popup .popup-actions { display: flex; gap: 8px; margin-top: 16px; }
#srs-app .srs-popup .popup-actions button { flex: 1; padding: 8px 16px; border-radius: 8px; border: var(--border); font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s ease; }
#srs-app .srs-popup .popup-actions .popup-save { background: var(--accent); color: #fff !important; border-color: transparent; }
#srs-app .srs-popup .popup-actions .popup-cancel { background: var(--card); }
#srs-app .srs-popup .popup-actions .popup-delete { background: var(--red); color: #fff !important; border-color: transparent; }

/* Library tag filter badges */
#srs-app .tag-filter-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; justify-content: center; }
#srs-app .tag-filter-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500; cursor: pointer; white-space: nowrap;
  border: 1px solid rgba(0,0,0,.12); transition: box-shadow .2s ease; opacity: 1;
  background: rgba(0,0,0,.04); font-family: var(--font);
}
#srs-app .tag-filter-badge:hover { box-shadow: var(--shadow); }
#srs-app.dark .tag-filter-badge { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); }
#srs-app .tag-filter-badge .tag-emoji { font-size: 12px; }
#srs-app .tag-filter-badge .gear-icon { font-size: 15px; margin-left: 3px; opacity: .5; cursor: pointer; }
#srs-app .tag-filter-badge .gear-icon:hover { opacity: 1; }

/* Star button on lib cards */
#srs-app .lib-item { position: relative; }
#srs-app .star-btn {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow); border: var(--border);
  cursor: pointer; padding: 0; line-height: 1; opacity: .5; transition: all .2s ease;
  z-index: 2; display: flex; align-items: center; justify-content: center;
}
#srs-app .star-btn:hover { opacity: .85; transform: scale(1.1); }
#srs-app .star-btn.tagged { opacity: 1; }
#srs-app .lib-item.tagged { border: 2px solid var(--accent); }
#srs-app #lib-grid.sel-mode .lib-item { opacity:.35; transition:opacity .3s ease, box-shadow .2s ease; cursor:pointer; user-select:none; }
#srs-app #lib-grid.sel-mode .lib-item.sel-picked { opacity:1; box-shadow:0 0 0 2.5px var(--accent); }
#srs-app #lib-sel-bar { display:flex; align-items:center; gap:8px; padding:0; opacity:0; transform:translateY(-6px); transition:opacity .25s ease, transform .25s ease, padding .3s ease; pointer-events:none; }
#srs-app #lib-sel-bar.visible { padding:10px 0 12px; opacity:1; transform:translateY(0); pointer-events:auto; }
#srs-app #lib-sel-count { font-size:13px; font-weight:600; flex:1; }
#srs-app #lib-sel-del { color:var(--red) !important; width:auto; padding:0 14px; }
#srs-app #lib-sel-cancel { width:auto; padding:0 14px; }

/* Edit (pencil) button on lib cards */
#srs-app .edit-btn {
  position: absolute; top: 8px; right: 36px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow); border: var(--border);
  cursor: pointer; padding: 0; line-height: 1; transition: all .2s ease;
  z-index: 2; display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
#srs-app .edit-btn { opacity: .5; }
#srs-app .edit-btn:hover { opacity: .85; transform: scale(1.1); }

/* Edit popup – wider scrollable form */
#srs-app .edit-popup-inner {
  max-width: 460px; max-height: 90vh; overflow-y: auto;
}
#srs-app .edit-popup-inner h3 { margin-bottom: 10px; }

/* Recent background thumbnails */
#srs-app .bg-recent-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
#srs-app .bg-thumb-wrap { position: relative; flex-shrink: 0; }
#srs-app .bg-thumb {
  width: 44px; height: 44px; border-radius: 8px; cursor: pointer;
  background-size: cover; background-position: center;
  border: 2px solid transparent; transition: all .2s ease;
  box-shadow: var(--shadow); display: block;
}
#srs-app .bg-thumb:hover { border-color: var(--accent); transform: scale(1.05); }
#srs-app .bg-thumb.active { border-color: var(--accent); }
#srs-app .bg-thumb-del {
  position: absolute; top: -5px; right: -5px; width: 16px; height: 16px;
  border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; border: none;
  font-size: 9px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease; z-index: 3; padding: 0;
}
#srs-app .bg-thumb-wrap:hover .bg-thumb-del { opacity: 1; }

/* Language flag selector (inside input) */
#srs-app .lang-input-wrap { position:relative; flex:1; }
#srs-app .dual-input-wrap { display:flex; flex:1; gap:10px; }
#srs-app .dual-input-wrap .input { flex:1; min-width:0; }
#srs-app .lang-input-wrap .input { width:100%; padding-right:96px; box-sizing:border-box; }
#srs-app #f-srs_term .lang-input-wrap .input { padding-right:42px; }
#srs-app .lang-flags-inner { position:absolute; right:6px; top:50%; transform:translateY(-50%); display:flex; gap:3px; align-items:center; }
#srs-app .lang-btn, #srs-app .accent-word-btn { width:26px; height:26px; border-radius:50%; background:var(--card); box-shadow:var(--shadow); border:var(--border); cursor:pointer; font-size:15px; padding:0; flex-shrink:0; opacity:.5; transition:all .2s ease; line-height:1; display:flex; align-items:center; justify-content:center; color:var(--fg); }
#srs-app .lang-btn.active { opacity:1; box-shadow:0 0 0 1.5px var(--accent), var(--shadow); }
#srs-app .lang-btn:hover, #srs-app .accent-word-btn:hover { opacity:.85; transform:scale(1.1); }
#srs-app .accent-word-btn { font-size:12px; font-weight:700; }
#srs-app #tts-play-btn { font-size:10px; font-weight:700; }
#srs-app .accent-word-btn:disabled { opacity:.2; cursor:default; transform:none; }
/* Language flag badge on lib cards — circle with shadow, left of star */
#srs-app .lang-flag-badge { position:absolute; top:8px; right:64px; opacity:.5; width:24px; height:24px; border-radius:50%; background:var(--card); box-shadow:var(--shadow); border:var(--border); display:flex; align-items:center; justify-content:center; font-size:14px; line-height:1; pointer-events:none; z-index:2; }

/* Star tag popup (small, positioned near star) */
#srs-app .star-popup {
  position: absolute; top: 30px; right: 0;
  background: rgba(255,255,255,.9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 10px; padding: 8px; min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 10;
  animation: srs-scaleIn .15s ease-out; display: none;
}
#srs-app.dark .star-popup { background: rgba(30,30,30,.9); }
#srs-app .star-popup.open { display: block; }
#srs-app .star-popup-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500;
  transition: background .15s; font-family: var(--font); border: none;
  background: none; width: 100%; text-align: left;
}
#srs-app .star-popup-item:hover { background: rgba(0,0,0,.06); }
#srs-app.dark .star-popup-item:hover { background: rgba(255,255,255,.08); }
#srs-app .star-popup-item .check { width: 14px; font-size: 12px; }

/* scrollbar inside glass */
#srs-app .glass::-webkit-scrollbar { width: 6px; }
#srs-app .glass::-webkit-scrollbar-track { background: transparent; }
#srs-app .glass::-webkit-scrollbar-thumb { background: rgba(128,128,128,.3); border-radius: 3px; }
#srs-app .glass::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,.5); }

/* ===== RESPONSIVE ===== */
@media(max-width:768px) {
  #srs-app .grid-4 { grid-template-columns: repeat(2,1fr); }
  #srs-app .grid-5 { grid-template-columns: repeat(3,1fr); }
  #srs-app .grid-2 { grid-template-columns: 1fr; }
  #srs-app .glass { width: 90%; margin: 10px auto; padding: 16px; border-radius: 16px; }
  #srs-app .stat-val { font-size: 80px; bottom: -14px; }
}
/* ===== EASTER EGG CELEBRATION ===== */
#save-celebration {
  position: fixed; inset: 0; z-index: 9999;
  display: none; cursor: pointer;
  background: rgba(0,0,0,.5);
  overflow: hidden;
}
#save-celebration.active { display: block; animation: srs-fadeIn .3s ease; }
#save-celebration .cel-gif {
  position: absolute;
  width: 170px; height: 170px; object-fit: cover;
  border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,.55);
  animation: cel-popIn .45s cubic-bezier(.34,1.56,.64,1) both;
  transform: rotate(var(--rot,0deg));
}
#save-celebration .cel-word {
  position: absolute; left: 50%; top: 50%;
  font-size: clamp(44px, 11vw, 100px); font-weight: 900;
  letter-spacing: -.03em; white-space: nowrap;
  font-family: var(--font);
  background: linear-gradient(120deg, #fff 0%, var(--accent) 55%, #ffd700 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 2px 12px rgba(0,0,0,.35));
  animation: cel-slideIn .55s cubic-bezier(.34,1.56,.64,1) .1s both;
  z-index: 2;
}
#save-celebration .cel-stonks {
  position: absolute; left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: 50vw; max-width: 50vh;
  object-fit: contain;
  z-index: 1;
  animation: cel-stonksIn .6s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes cel-stonksIn {
  from { transform: translateX(-50%) translateY(100%); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}
@keyframes cel-popIn {
  from { transform: scale(0) rotate(var(--rot,0deg)); opacity: 0; }
  to   { transform: scale(1) rotate(var(--rot,0deg)); opacity: 1; }
}
@keyframes cel-slideIn {
  from { transform: translate(110vw, -50%); opacity: 0; }
  to   { transform: translate(-50%, -50%); opacity: 1; }
}
@keyframes cel-fadeOut {
  to { opacity: 0; transform: scale(1.04); }
}
#save-celebration.mini {
  background: transparent;
  pointer-events: none;
  cursor: default;
}
#save-celebration .cel-gif.cel-mini { width: 130px; height: 130px; }

@media(max-width:480px) {
  /* Adaptive base — use rem (root html font-size = 16px), em (parent), svh/vw/% (viewport) */
  /* px reserved only for borders/shadows/sub-1rem details */

  /* ===== APP / VIEW ===== */
  #srs-app { position: relative; font-size: 1rem; }
  #srs-app .view.active { align-items: stretch; justify-content: flex-start; min-height: 0; height: 92.25svh; max-height: 92.25svh; padding: 0 0.5em 7.75svh; box-sizing: border-box; overflow: hidden; }

  /* Glass: full bleed with em-based padding */
  #srs-app .glass { width: 100% !important; max-width: 100% !important; height: 100% !important; margin: 0 !important; padding: 0.5em !important; border-radius: 0.875rem; box-sizing: border-box; box-shadow: none !important; }

  /* Add view: full svh with internal scroll */
  #srs-app #v-add .glass { height: calc(100svh - 4.25rem); overflow-y: auto; }

  /* ===== SETTINGS BAR — static, 10svh, in normal flow above .view ===== */
  #srs-app .settings-bar { position: static; top: auto; left: auto; right: auto; transform: none; display: flex; justify-content: center; align-items: center; gap: 0.3125rem; padding: 0 1em; width: 100%; height: 7.75svh; box-sizing: border-box; overflow-x: auto; overflow-y: visible; scrollbar-width: none; -webkit-overflow-scrolling: touch; flex-shrink: 0; }
  #srs-app .settings-bar::-webkit-scrollbar { display: none; }
  #srs-app .settings-btn { width: 2.25rem; min-width: 2.25rem; height: 2.25rem; min-height: 2.25rem; flex: 0 0 2.25rem; aspect-ratio: 1/1; border-radius: 50%; font-size: 1rem; padding: 0; }

  /* Popups — keep inside #srs-app for CSS scoping; force own composite layer to escape iOS Safari backdrop-filter trap */
  #srs-app .settings-popup { position: fixed !important; top: 8svh !important; left: 1rem !important; right: 1rem !important; bottom: auto !important; max-width: 22rem !important; width: auto !important; margin: 0 auto !important; max-height: 84svh !important; min-width: 0 !important; overflow-y: auto !important; z-index: 2147483647 !important; transform: translate3d(0,0,0) !important; -webkit-transform: translate3d(0,0,0) !important; will-change: transform; box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.15); border: 1px solid rgba(0,0,0,.08); }
  #srs-app .settings-popup.open { display: block !important; }

  /* ===== HOME ===== */
  #srs-app .grid-4 { grid-template-columns: repeat(4,1fr); gap: 0.375rem; margin-bottom: 0.5rem; }
  #srs-app .charts-row { gap: 0.375rem; margin-bottom: 0.5rem; }
  #srs-app .section { margin-bottom: 0.5rem; }
  #srs-app .flex-row { gap: 0.375rem; }

  #srs-app .stat-label { text-align: center; }
  #srs-app .stat-val { font-size: clamp(2.25rem, 12vw, 3.375rem); top: 50%; bottom: auto; right: auto; left: 50%; transform: translate(-50%, -50%); }
  #srs-app .stat-card { min-height: 2.75rem; padding: 0.375rem 0.375rem 0.25rem; position: relative; }
  #srs-app .stat-label[data-short] { font-size: 0; }
  #srs-app .stat-label[data-short]::before { content: attr(data-short); font-size: 0.5625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.025em; }

  /* Home glass: 4 rows 20/30/20/20 — exact 100% of glass height */
  #srs-app #v-home .glass { display: grid !important; grid-template-columns: 1fr 1fr !important; grid-template-rows: 20fr 35fr 20fr 5fr !important; gap: 0.625rem !important; align-items: stretch !important; }
  #srs-app #v-home .grid-4 { grid-column: 1; grid-row: 1; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 0.375rem; margin-bottom: 0; min-height: 0; }
  #srs-app #v-home .charts-row { display: contents; }
  #srs-app #v-home .chart-card-pie { grid-column: 2; grid-row: 1; height: 100%; overflow: hidden; order: unset; padding: 0.375rem; min-height: 0; }
  #srs-app #v-home .chart-card-bar { display: none; }
  #srs-app #v-home .chart-card-forecast { grid-column: 1 / -1; grid-row: 2; height: 100%; overflow: hidden; order: unset; display: flex; flex-direction: column; padding: 0.5rem; min-height: 0; }
  #srs-app #v-home .chart-card-forecast .forecast-chart-wrap { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  /* Labels match SVG row math: padT=padB=6px (= 0.375rem), 8 equal rows, items centered */
  #srs-app #v-home .chart-card-forecast .fc-labels { padding: 0; display: grid; grid-template-rows: repeat(8, 1fr); gap: 0; width: auto; min-width: 3.25rem; justify-content: stretch; }
  #srs-app #v-home .chart-card-forecast .fc-labels span { align-self: stretch; justify-self: stretch; font-size: 0.5625rem; padding: 0; min-height: 0; line-height: 1; white-space: nowrap; display: flex; align-items: center; justify-content: center; margin: 0.125rem 0; }
  /* Reduce x-stretch on SVG numbers — keep aspect for text layer */
  #srs-app #v-home .chart-card-forecast #forecast-chart text { font-size: 0.5625rem; font-weight: 700; }
  #srs-app #v-home .chart-card-forecast .forecast-action-btn { flex-shrink: 0; margin-top: 0.5rem; }
  /* Sections fill explicit rows (5 and 7, skipping spacer rows 2, 4 and 6) */
  #srs-app #v-home .glass > .section { grid-column: 1 / -1; grid-row: 3; margin-bottom: 0; min-height: 0; display: flex; }
  #srs-app #v-home .glass > .section ~ .section { grid-row: 4; }
  #srs-app #v-home .section > .grid-5,
  #srs-app #v-home .section > .flex-row { width: 100%; height: 100%; }
  #srs-app #v-home .section + .section { margin-top: 0; padding-top: 0; border-top: none; }

  /* Quick Add: 2 inner rows fill the section */
  #srs-app #v-home .grid-5 .icon-btn { min-height: 0; height: 100%; }
  #srs-app .grid-5 { grid-template-columns: repeat(3,1fr); grid-template-rows: 1fr 1fr; gap: 0.375rem; }
  #srs-app .grid-5 .icon-btn:nth-child(1),
  #srs-app .grid-5 .icon-btn:nth-child(2),
  #srs-app .grid-5 .icon-btn:nth-child(3),
  #srs-app .grid-5 .icon-btn:nth-child(4),
  #srs-app .grid-5 .icon-btn:nth-child(5),
  #srs-app .grid-5 .icon-btn:nth-child(6) { grid-column: auto; }

  /* CTA flex-row fills row 4 */
  #srs-app #v-home .flex-row { align-items: stretch; height: 100%; gap: 0.375rem; }
  #srs-app #v-home .flex-row > * { height: 100%; }
  /* Stat cards stretch */
  #srs-app #v-home .grid-4 .stat-card { min-height: 0; height: 100%; padding: 0.25rem 0.375rem; }

  /* ===== FORECAST PAGE ===== */
  #srs-app #v-forecast .glass { height: calc(100svh - 4.25rem); }
  #srs-app #v-bulk-add .glass { width: 100%; height: calc(100svh - 4.25rem); padding: 1rem 0.875rem !important; }

  /* ===== REVIEW / TEST ===== */
  #srs-app #v-review .glass { min-height: calc(100svh - 4.25rem); padding: 0.75rem 0.625rem !important; }
  #rv-topbar { gap: 0.25rem; margin-bottom: 0.5rem; }
  #rv-chain-scroll { padding: 0.5rem 0.25rem; margin: -0.5rem -0.25rem; }
  .rv-q-pill { font-size: 0.6875rem; padding: 0.25em 0.625em; }

  .rv-card { padding: 0.75rem 0.625rem; }
  .rv-prompt { font-size: 1.0625rem; }
  .rv-type-label { font-size: 0.625rem; }

  /* MC */
  .rv-mc-grid { gap: 0.375rem; }
  .rv-mc-btn { padding: 0.6875em 0.625em; font-size: 0.8125rem; line-height: 1.35; }

  /* Type */
  .rv-type-form { gap: 0.375rem; flex-wrap: wrap; }
  .rv-type-input { font-size: 0.875rem; padding: 0.5625em 0.625em; flex: 1 1 100%; min-width: 0; }
  .rv-type-form .rv-submit { flex: 1 1 auto !important; min-width: 6.25rem; }

  /* Match */
  .rv-match-grid { gap: 0.375rem; }
  .rv-match-item { font-size: 0.75rem; padding: 0.625em 0.5em; line-height: 1.3; }

  /* AI Quiz */
  .rv-ai-question { padding: 0.625em 0.75em; }
  .rv-ai-q-text { font-size: 0.8125rem; margin-bottom: 0.5em; line-height: 1.4; }
  .rv-ai-feedback { font-size: 0.75rem; }
  .rv-ai-loading { padding: 1em 0; font-size: 0.8125rem; }

  /* Study mode */
  .rv-study-card { flex: none; height: auto; }
  .rv-study-grid { grid-template-columns: 1fr; flex: none; height: auto; min-height: 0; }
  .rv-left-col { order: 2; }
  .rv-card-col { order: 1; }
  .rv-forecast-col { order: 3; }
  .rv-assoc-list { max-height: 7.5rem; }

  /* ===== FORMS / LIBRARY ===== */
  #srs-app .field-row { flex-wrap: wrap; gap: 0.25rem; }
  #srs-app .field-label { min-width: 0; flex: 1 1 100%; font-size: 0.6875rem; opacity: .55; }
  #srs-app .field-row .input,
  #srs-app .field-row .textarea { flex: 1 1 100%; font-size: 0.875rem; }
  #srs-app .input { font-size: 0.875rem; }

  .lib-flt { font-size: 0.75rem; padding: 0.375em 0.625em; }
  .lib-search { font-size: 0.8125rem; }

  /* ===== POPUP OVERLAYS ===== */
  .srs-popup-overlay .srs-popup { width: calc(100vw - 1rem) !important; max-width: 100% !important; max-height: calc(100svh - 2rem) !important; padding: 1rem 0.875rem !important; box-sizing: border-box; }
}
