  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; }

  :root {
    --bg:        #111318;
    --surface:   #1a1d24;
    --surface2:  #21252e;
    --surface3:  #282c38;
    --border:    #2a2e3a;
    --border2:   #363b4c;
    --text:      #cdd1de;
    --text-dim:  #8a90a8;
    --text-mute: #5c6280;

    --ns:    #3a3d4a;
    --ns-bg: #1c1e26;
    --red:    #e05555;
    --red-bg: #2b1d1d;
    --yel:    #d4a843;
    --yel-bg: #2b2418;
    --grn:    #4aac78;
    --grn-bg: #192b22;

    --a1: #5b8af5;
    --p1: #c47af0;
    --b1: #f0934a;
    --h1: #4abfcf;
    --n1: #e06090;
  }

  html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    overflow: hidden;
  }

  #app {
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-rows: 52px 38px 1fr 195px;
    height: calc(100vh / 1.25);
    gap: 0;
    zoom: 1.25;
  }

  #header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    grid-column: 1 / -1;
  }

  .logo {
    font-family: 'Cormorant Garamond', serif;
    font-size: 21px;
    font-style: italic;
    letter-spacing: 0.02em;
    color: #e8eaf5;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .logo span { color: var(--a1); }

  .header-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: 8px;
  }

  .header-stat {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-size: 10px;
    color: var(--text-dim);
  }
  .header-stat-num {
    font-size: 16px;
    font-weight: 300;
    line-height: 1;
  }
  .header-stat-num.green { color: var(--grn); }
  .header-stat-num.pace  { color: var(--yel); }

  .header-progress {
    width: 120px;
    height: 4px;
    background: var(--surface3);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
  }
  .header-progress-touched {
    position: absolute;
    left: 0; top: 0; height: 100%;
    border-radius: 2px;
    background: #555a6e;
    transition: width 0.6s ease;
  }
  .header-progress-fill {
    position: absolute;
    left: 0; top: 0; height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--grn), #60d89a);
    transition: width 0.6s ease;
  }

  .dday-strip {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
  }

  .dday-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 11px;
    border-radius: 4px;
    border: 1px solid var(--border2);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.15s, filter 0.15s;
  }
  .dday-pill:hover { filter: brightness(1.15); }
  .dday-pill .subj-label {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.06em;
  }
  .dday-pill .days-num {
    font-size: 17px;
    font-weight: 300;
    line-height: 1;
  }
  .dday-pill .days-unit {
    font-size: 8px;
    color: var(--text-dim);
    line-height: 1;
  }
  .dday-pill.urgent .days-num { color: var(--red) !important; }
  .dday-scope { font-size: 7px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
  .subj-credits { font-size: 10px; color: var(--text-mute); margin-left: 6px; font-weight: 600; background: var(--surface3); padding: 1px 5px; border-radius: 3px; }
  .exam-timeline { display: flex; gap: 8px; font-size: 8px; color: var(--text-dim); padding: 4px 0; flex-wrap: wrap; }
  .exam-timeline-item { padding: 2px 6px; background: var(--surface2); border-radius: 3px; }
  .exam-timeline-item.next { border: 1px solid var(--border2); color: var(--text); }

  #tabs {
    display: flex;
    align-items: stretch;
    padding: 0 20px;
    gap: 2px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    grid-column: 1 / -1;
  }

  .tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    position: relative;
    top: 1px;
  }
  .tab .tab-dot {
    width: 6px; height: 6px; border-radius: 50%;
    opacity: 0.7;
  }
  .tab.active { color: var(--text); }
  .tab[data-subj="__schedule__"].active,
  .tab[data-subj="__dq__"].active {
    border-color: var(--tab-color);
    color: var(--tab-color);
  }

  .tab .prog-badge {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text-dim);
    margin-left: 2px;
  }

  .tab-progress {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
  }
  .tab-progress-touched {
    position: absolute;
    left: 0; top: 0; height: 100%;
    background: #555a6e;
    transition: width 0.4s ease;
  }
  .tab-progress-fill {
    position: absolute;
    left: 0; top: 0; height: 100%;
    transition: width 0.4s ease;
  }

  .tab-spacer { flex: 1; }

  .legend {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
  }
  .legend-item {
    display: flex; align-items: center; gap: 5px;
    font-size: 9px; color: var(--text-dim); letter-spacing: 0.04em;
  }
  .legend-dot {
    width: 7px; height: 7px; border-radius: 2px;
  }

  #main {
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
    gap: 0;
  }

  #grid-panel {
    padding: 12px 16px 12px 20px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
  }

  .section-group { margin-bottom: 12px; }
  .section-label {
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 5px;
    padding-left: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    width: fit-content;
  }
  .section-label:hover { color: var(--text-dim); }
  .section-arrow { font-size: 8px; transition: transform 0.15s; }
  .section-group.collapsed .section-arrow { transform: rotate(-90deg); }
  .section-group.collapsed .topic-grid { display: none; }
  .section-progress {
    font-size: 8px;
    color: var(--text-mute);
    font-weight: 400;
  }

  .topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 4px;
  }

  .topic-cell {
    position: relative;
    padding: 7px 9px 6px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--ns-bg);
    cursor: pointer;
    transition: filter 0.12s, border-color 0.12s, transform 0.1s;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .topic-cell:hover { filter: brightness(1.2); transform: translateY(-1px); }
  .topic-cell.selected { outline: 2px solid var(--a1); outline-offset: 1px; }

  .topic-cell.lvl-not_started { border-left: 3px solid var(--ns); }
  .topic-cell.lvl-red    { background: var(--red-bg); border-color: #4a2222; border-left: 3px solid var(--red); }
  .topic-cell.lvl-yellow { background: var(--yel-bg); border-color: #4a3a18; border-left: 3px solid var(--yel); }
  .topic-cell.lvl-green  { background: var(--grn-bg); border-color: #1a4a30; border-left: 3px solid var(--grn); }
  .topic-cell.selected.lvl-red    { outline-color: var(--red); }
  .topic-cell.selected.lvl-yellow { outline-color: var(--yel); }
  .topic-cell.selected.lvl-green  { outline-color: var(--grn); }

  .cell-lecture {
    font-size: 7px;
    color: var(--dim);
    opacity: 0.7;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cell-drill-tag {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 6.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 3px;
    padding: 1px 4px;
    line-height: 1.4;
    text-transform: uppercase;
  }
  .cell-name {
    font-size: 10px;
    line-height: 1.3;
    color: var(--text);
    word-break: keep-all;
  }
  .topic-cell.lvl-red    .cell-name { color: #f0a0a0; }
  .topic-cell.lvl-yellow .cell-name { color: #f0d090; }
  .topic-cell.lvl-green  .cell-name { color: #90e0b0; }

  .cell-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
  }

  .cell-history {
    display: flex; gap: 2px; align-items: center;
  }
  .history-dot {
    width: 5px; height: 5px; border-radius: 50%;
    flex-shrink: 0;
  }
  .hd-ns  { background: var(--ns); }
  .hd-red { background: var(--red); }
  .hd-yel { background: var(--yel); }
  .hd-grn { background: var(--grn); }

  /* 회독 dots */
  .hoedok-row { display: flex; align-items: center; gap: 4px; }
  .hoedok-dot {
    width: 18px; height: 18px; border-radius: 50%;
    border: 1.5px solid var(--border2);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 600;
    color: var(--text-mute);
    cursor: pointer;
    transition: all 0.12s;
    flex-shrink: 0;
  }
  .hoedok-dot.hd-grn {
    background: var(--grn);
    border-color: var(--grn);
    color: #fff;
  }
  .hoedok-dot.hd-yel {
    background: var(--yel);
    border-color: var(--yel);
    color: #fff;
  }
  .hoedok-dot.hd-red {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
  }
  .hoedok-dot:hover { transform: scale(1.15); }
  .hoedok-add {
    width: 10px; height: 10px; border-radius: 50%;
    border: 1.5px dashed var(--text-mute);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; color: var(--text-mute);
    cursor: pointer; flex-shrink: 0;
    transition: all 0.12s;
  }
  .hoedok-add:hover { border-color: var(--subj-color, var(--a1)); color: var(--subj-color, var(--a1)); }
  /* 회독 이해도 피커 */
  .hoedok-picker-wrap { position: relative; display: inline-flex; }
  .hoedok-picker {
    position: fixed;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 8px 10px;
    display: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  }
  .hoedok-picker.open { display: block; }
  .hoedok-picker-label {
    font-size: 9px;
    color: var(--text-mute);
    margin-bottom: 6px;
    text-align: center;
    letter-spacing: 0;
    word-spacing: 0;
  }
  .hoedok-picker-opts { display: flex; gap: 8px; }
  .hoedok-popt {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    cursor: pointer; padding: 4px 6px; border-radius: 6px;
    transition: background 0.1s;
  }
  .hoedok-popt:hover { background: var(--surface3); }
  .hoedok-popt-dot {
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600;
    transition: transform 0.1s;
  }
  .hoedok-popt:hover .hoedok-popt-dot { transform: scale(1.15); }
  .hoedok-popt-dot.plvl-red { background: var(--red-bg); color: var(--red); border: 1.5px solid color-mix(in srgb, var(--red) 60%, transparent); }
  .hoedok-popt-dot.plvl-yel { background: var(--yel-bg); color: var(--yel); border: 1.5px solid color-mix(in srgb, var(--yel) 60%, transparent); }
  .hoedok-popt-dot.plvl-grn { background: var(--grn-bg); color: var(--grn); border: 1.5px solid color-mix(in srgb, var(--grn) 60%, transparent); }
  .hoedok-popt-text { font-size: 9px; color: var(--text-dim); letter-spacing: 0; word-spacing: 0; }

  /* 우측 패널 회독 */
  .hoedok-detail-row { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
  .hoedok-detail-row .hoedok-dot { width: 24px; height: 24px; font-size: 11px; }
  .hoedok-detail-row .hoedok-add,
  .hoedok-detail-row .hoedok-add-half { width: 24px; height: 24px; font-size: 13px; }
  .hoedok-detail-row .hoedok-add-half { font-size: 11px; }

  .cell-times {
    font-size: 8px;
    color: var(--text-mute);
  }

  /* Level stamp button */
  .cell-star-btn {
    position: absolute;
    top: 5px;
    right: 6px;
    cursor: pointer;
    opacity: 0.2;
    transition: opacity 0.15s, transform 0.1s;
    font-size: 18px;
    color: var(--text-mute);
    z-index: 10;
    line-height: 1;
  }
  .topic-cell:hover .cell-star-btn { opacity: 0.4; }
  .cell-star-btn:hover { opacity: 0.8 !important; transform: scale(1.2); }
  .cell-star-btn.active { opacity: 1; color: #f5c542; filter: drop-shadow(0 0 3px rgba(245,197,66,0.4)); }

  /* Level picker popup */
  .level-picker {
    position: absolute;
    top: 0;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 6px;
    padding: 4px;
    z-index: 50;
    display: flex;
    gap: 3px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: fcIn 0.1s ease;
  }
  .level-pick-btn {
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-family: 'DM Mono', monospace;
    transition: all 0.1s;
    white-space: nowrap;
  }
  .level-pick-btn:hover { transform: scale(1.15); }
  .level-pick-btn.pick-red    { background: transparent; border-color: var(--red); color: var(--red); }
  .level-pick-btn.pick-yellow { background: transparent; border-color: var(--yel); color: var(--yel); }
  .level-pick-btn.pick-green  { background: transparent; border-color: var(--grn); color: var(--grn); }
  .level-pick-btn.pick-red.active    { background: var(--red-bg); border-color: var(--red); }
  .level-pick-btn.pick-yellow.active { background: var(--yel-bg); border-color: var(--yel); }
  .level-pick-btn.pick-green.active  { background: var(--grn-bg); border-color: var(--grn); }

  #right-panel {
    border-left: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    grid-column: 2;
    grid-row: 3 / 5;
  }

  .panel-header {
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
  }
  .panel-title {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text);
  }
  .panel-count {
    font-size: 10px;
    color: var(--text-dim);
  }

  #detail-view {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
  }

  .detail-topic-name {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.3;
  }
  .detail-section {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
  }

  .lvl-seg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 4px;
    font-size: 10px;
    color: var(--text-dim);
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: all 0.15s;
  }
  .lvl-seg:last-child { border-right: none; }
  .lvl-seg:hover { background: var(--surface2); }
  .lvl-seg.active {
    background: var(--surface2);
    color: var(--seg-color);
    font-weight: 600;
  }

  .detail-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 10px;
    margin-bottom: 14px;
    cursor: pointer;
    transition: filter 0.15s;
  }
  .detail-level-badge:hover { filter: brightness(1.2); }
  .badge-ns  { background:#24262e; color: var(--text-dim); }
  .badge-red { background: var(--red-bg); color: var(--red); border: 1px solid #4a2222; }
  .badge-yel { background: var(--yel-bg); color: var(--yel); border: 1px solid #4a3a18; }
  .badge-grn { background: var(--grn-bg); color: var(--grn); border: 1px solid #1a4a30; }

  .detail-sub {
    font-size: 11px;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .detail-section-block {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .detail-section-block:last-child { border-bottom: none; }

  /* ─── New side panel ─── */
  .sp-header { padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
  .sp-subj-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--text-mute); margin-bottom: 5px; }
  .sp-subj-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
  .sp-title { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.4; }

  .sp-stats { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .sp-stat {
    flex: 1; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; padding: 7px 8px; display: flex; flex-direction: column; gap: 1px;
  }
  .sp-stat-label { font-size: 9px; color: var(--text-mute); }
  .sp-stat-val { font-size: 16px; font-weight: 500; color: var(--text); }
  .sp-stat-sub { font-size: 9px; color: var(--text-mute); }

  .sp-section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .sp-section:last-child { border-bottom: none; }
  .sp-sec-title {
    font-size: 10px; color: var(--text-mute); letter-spacing: 0.06em;
    text-transform: uppercase; margin-bottom: 8px;
  }

  .sp-hoedok-entry { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
  .sp-hdot {
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; flex-shrink: 0;
  }
  .sp-hdot.h-red { background: var(--red-bg); color: var(--red); border: 1.5px solid color-mix(in srgb, var(--red) 50%, transparent); }
  .sp-hdot.h-yel { background: var(--yel-bg); color: var(--yel); border: 1.5px solid color-mix(in srgb, var(--yel) 50%, transparent); }
  .sp-hdot.h-grn { background: var(--grn-bg); color: var(--grn); border: 1.5px solid color-mix(in srgb, var(--grn) 50%, transparent); }
  .sp-hinfo { flex: 1; }
  .sp-hinfo-top { display: flex; justify-content: space-between; align-items: center; }
  .sp-hinfo-label { font-size: 11px; color: var(--text); font-weight: 500; }
  .sp-hinfo-date { font-size: 10px; color: var(--text-mute); }
  .sp-hinfo-sub { font-size: 9px; color: var(--text-mute); margin-top: 1px; }
  .sp-hinfo-del {
    cursor: pointer; font-size: 10px; color: var(--text-mute); opacity: 0.4;
    transition: opacity .15s, color .15s; margin-left: 4px;
  }
  .sp-hinfo-del:hover { opacity: 1; color: var(--red); }

  .sp-add-hoedok {
    display: flex; align-items: center; gap: 8px; margin-top: 8px; cursor: pointer;
    padding: 7px 10px; border: 1px dashed var(--border2); border-radius: 6px;
    transition: border-color 0.12s, background 0.12s;
  }
  .sp-add-hoedok:hover { border-color: var(--a1); background: color-mix(in srgb, var(--a1) 8%, transparent); }
  .sp-add-plus { font-size: 16px; color: var(--text-mute); line-height: 1; }
  .sp-add-hoedok:hover .sp-add-plus { color: var(--a1); }
  .sp-add-hoedok span { font-size: 11px; color: var(--text-dim); }
  .sp-add-hoedok:hover span { color: var(--a1); }

  .sp-memo {
    width: 100%; background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; padding: 7px 10px; font-size: 11px; color: var(--text);
    font-family: inherit; resize: none; min-height: 60px; line-height: 1.5;
    box-sizing: border-box;
  }
  .sp-memo:focus { outline: none; border-color: var(--border2); }
  .sp-memo::placeholder { color: var(--text-mute); }

  .sp-rel-item {
    display: flex; align-items: center; gap: 7px; padding: 6px 8px;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 5px;
    cursor: pointer; transition: border-color 0.12s; margin-bottom: 4px;
  }
  .sp-rel-item:hover { border-color: var(--border2); }
  .sp-rel-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
  .sp-rel-title { font-size: 10px; color: var(--text); flex: 1; line-height: 1.3; }
  .sp-rel-badge {
    font-size: 9px; padding: 2px 5px; border-radius: 99px; flex-shrink: 0; font-weight: 500;
  }
  .sp-rel-badge.rb-done { background: var(--grn-bg); color: var(--grn); }
  .sp-rel-badge.rb-none { background: var(--surface); color: var(--text-mute); border: 1px solid var(--border); }

  /* subtopic memo items */
  .stm-item {
    display: flex; flex-direction:column;
    padding: 5px 8px; margin-bottom: 3px;
    border-radius: 5px; background: var(--surface2);
    transition: background .1s;
  }
  .stm-item:hover { background:var(--bg); }
  .stm-item.open .stm-arrow { transform:rotate(90deg); }
  .stm-item.open .stm-body { display:block !important; }

  .history-timeline {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 14px;
  }
  .history-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--surface2);
  }
  .history-idx {
    font-size: 10px;
    color: var(--text-dim);
    width: 14px;
    text-align: right;
    flex-shrink: 0;
  }
  .history-color-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  }
  .history-date {
    font-size: 11px;
    color: var(--text);
    flex: 1;
  }
  .history-level-text { font-size: 11px; }
  .hl-not_started { color: var(--text-dim); }
  .hl-red { color: var(--red); }
  .hl-yel, .hl-yellow { color: var(--yel); }
  .hl-grn, .hl-green  { color: var(--grn); }

  .no-history { font-size: 11px; color: var(--text-dim); padding: 8px 0; }

  .detail-wrong-item {
    padding: 8px 10px;
    border-radius: 5px;
    background: var(--red-bg);
    border: 1px solid #3a2020;
    margin-bottom: 5px;
  }
  .detail-wrong-topic { font-size: 12px; color: #f0a0a0; margin-bottom: 4px; }
  .detail-wrong-row { display: flex; gap: 6px; align-items: flex-start; }
  .detail-wrong-label { font-size: 10px; color: var(--text-dim); flex-shrink: 0; margin-top: 1px; }
  .detail-wrong-text { font-size: 12px; line-height: 1.5; }
  .detail-wrong-x { color: #e08080; }
  .detail-wrong-o { color: #70d0a0; }

  .detail-concept-item {
    padding: 8px 12px;
    border-radius: 5px;
    background: #1a2030;
    border: 1px solid #2a3050;
    margin-bottom: 5px;
    font-size: 12px;
    color: #b8d0f0;
    line-height: 1.6;
  }

  /* Concept carousel */
  .concept-carousel {
    position: relative;
    margin-bottom: 8px;
  }
  .concept-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
  }
  .concept-track::-webkit-scrollbar { display: none; }
  .concept-card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    padding: 12px 14px;
    border-radius: 6px;
    background: #1a2030;
    border: 1px solid #2a3050;
    min-height: 60px;
  }
  .concept-card-num {
    font-size: 9px;
    color: var(--text-mute);
    margin-bottom: 6px;
  }
  .concept-card-text {
    font-size: 12px;
    color: #b8d0f0;
    line-height: 1.7;
  }
  .concept-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
  }
  .concept-nav-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 10px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
  }
  .concept-nav-btn:hover { background: var(--surface3); color: var(--text); }
  .concept-nav-counter { font-size: 11px; color: var(--text-dim); letter-spacing: 0.03em; min-width: 100px; text-align: center; }
  .concept-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }

  .review-tag { font-size: 8px; padding: 1px 5px; border-radius: 3px; margin-left: 6px; vertical-align: middle; font-family: 'DM Mono', monospace; }
  .review-tag.review-due  { background: var(--red-bg); color: var(--red); border: 1px solid #4a2222; }
  .review-tag.review-soon { background: var(--yel-bg); color: var(--yel); border: 1px solid #4a3a18; }
  .review-tag.review-later { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); }

  .detail-empty { font-size: 11px; color: var(--text-dim); padding: 4px 0; }

  #wrong-view {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
  }

  .wrong-item {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.1s;
  }
  .wrong-item:hover { background: var(--surface2); }
  .wrong-panel-group-header {
    padding: 6px 14px;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: 'DM Mono', monospace;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .wrong-filter-btn {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.12s;
  }
  .wrong-filter-btn:hover { border-color: var(--border2); color: var(--text); }
  .wrong-filter-btn.active { background: var(--surface3); border-color: var(--border2); color: var(--text); }

  #fc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(17,19,24,0.88);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
  }
  #fc-overlay.open { display: flex; }

  #fc-card {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 12px;
    width: min(560px, 90vw);
    min-height: 300px;
    padding: 32px 36px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: fcIn 0.18s ease;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }
  #fc-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
  @keyframes fcIn {
    from { opacity:0; transform: translateY(10px) scale(0.98); }
    to   { opacity:1; transform: translateY(0) scale(1); }
  }

  .fc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .fc-subject { font-size: 9px; color: var(--text-mute); letter-spacing: 0.06em; }
  .fc-counter { font-size: 9px; color: var(--text-mute); }
  .fc-count-badge { background: #3a2020; color: var(--red); border: 1px solid #4a2222; border-radius: 10px; padding: 1px 7px; font-size: 9px; margin-left: 8px; }

  .fc-question {
    font-size: 16px;
    color: var(--text);
    line-height: 1.65;
    text-align: center;
    padding: 20px 0;
  }

  .fc-hint {
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
    letter-spacing: 0.05em;
    margin-top: 12px;
  }

  .fc-my-answer {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 12px; line-height: 1.5;
    resize: none; outline: none;
    margin-top: 14px;
    min-height: 60px;
    transition: border-color 0.15s;
  }
  .fc-my-answer:focus { border-color: var(--a1); }
  .fc-my-answer::placeholder { color: var(--text-mute); font-size: 10px; }

  .fc-shortcut-hint {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
  }
  .fc-key {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .fc-key kbd {
    background: var(--surface3);
    border: 1px solid var(--border2);
    border-radius: 3px;
    padding: 2px 7px;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--text);
  }

  .fc-my-answer-label { font-size: 9px; color: var(--text-mute); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
  .fc-my-answer-box {
    font-size: 13px; line-height: 1.5;
    padding: 10px 14px; border-radius: 6px;
    background: #1a2030; border: 1px solid #2a3050;
    color: var(--text); margin-bottom: 12px;
    white-space: pre-wrap;
  }

  .fc-answer {
    display: none;
    padding-top: 16px;
  }
  .fc-answer.show { display: block; }

  .fc-ans-row { margin-bottom: 12px; }
  .fc-ans-label { font-size: 9px; color: var(--text-mute); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
  .fc-ans-text { font-size: 15px; line-height: 1.65; padding: 12px 16px; border-radius: 6px; }
  .fc-wrong-box { background: var(--red-bg); border: 1px solid #4a2222; color: #f0b0b0; }
  .fc-right-box { background: var(--grn-bg); border: 1px solid #1a4a30; color: #a0ecc0; }

  .fc-question-flipped {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
    line-height: 1.6;
    opacity: 0.85;
  }

  .fc-nav {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .fc-nav-btn {
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text-dim);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    padding: 7px 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.1s;
  }
  .fc-nav-btn:hover { background: var(--surface3); color: var(--text); }
  .fc-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
  .fc-close-btn {
    background: none; border: 1px solid var(--border);
    color: var(--text-mute); font-size: 10px;
    padding: 7px 14px; border-radius: 5px;
    cursor: pointer; font-family: 'DM Mono', monospace;
    transition: all 0.1s;
  }
  .fc-close-btn:hover { color: var(--text); border-color: var(--border2); }

  .fc-fix-btn {
    background: none; border: 1px solid #4a3a18;
    color: var(--yel); font-size: 10px;
    padding: 7px 14px; border-radius: 5px;
    cursor: pointer; font-family: 'DM Mono', monospace;
    transition: all 0.1s;
  }
  .fc-fix-btn:hover { background: var(--yel-bg); }

  .fc-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    padding: 8px 18px;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 400;
    pointer-events: none;
  }
  .fc-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  #fix-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(17,19,24,0.92);
    align-items: center;
    justify-content: center;
  }
  #fix-modal.open { display: flex; }

  .fix-box {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 10px;
    width: min(440px, 88vw);
    padding: 24px;
  }
  .fix-title { font-size: 12px; color: var(--yel); margin-bottom: 6px; }
  .fix-topic { font-size: 10px; color: var(--text-dim); margin-bottom: 14px; }
  .fix-textarea {
    width: 100%; min-height: 80px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 10px 12px;
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 11px; line-height: 1.5;
    resize: vertical; outline: none;
    margin-bottom: 12px;
  }
  .fix-textarea:focus { border-color: var(--yel); }
  .fix-textarea::placeholder { color: var(--text-mute); }
  .fix-actions { display: flex; gap: 8px; justify-content: flex-end; }

  .corrections-badge {
    background: var(--yel-bg);
    color: var(--yel);
    border: 1px solid #4a3a18;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 9px;
    cursor: pointer;
  }
  .corrections-badge:hover { filter: brightness(1.2); }

  .fc-rating {
    display: none;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
  }
  .fc-rating.show { display: flex; }

  .fc-rate-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 18px;
    border-radius: 6px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    cursor: pointer;
    font-family: 'DM Mono', monospace;
    transition: all 0.12s;
    min-width: 72px;
  }
  .fc-rate-btn:hover { transform: translateY(-1px); filter: brightness(1.15); }
  .fc-rate-label { font-size: 11px; font-weight: 500; display: flex; align-items: center; gap: 4px; }
  .fc-rate-label kbd {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 3px;
    padding: 0 4px;
    line-height: 16px;
    color: inherit;
    opacity: 0.6;
  }
  .fc-rate-time { font-size: 8px; color: var(--text-mute); }

  .fc-rate-btn.again { border-color: #4a2222; }
  .fc-rate-btn.again .fc-rate-label { color: var(--red); }
  .fc-rate-btn.again:hover { background: var(--red-bg); }

  .fc-rate-btn.hard { border-color: #4a3a18; }
  .fc-rate-btn.hard .fc-rate-label { color: var(--yel); }
  .fc-rate-btn.hard:hover { background: var(--yel-bg); }

  .fc-rate-btn.good { border-color: #2a4a3a; }
  .fc-rate-btn.good .fc-rate-label { color: var(--grn); }
  .fc-rate-btn.good:hover { background: var(--grn-bg); }

  .fc-rate-btn.easy { border-color: #2a3a5a; }
  .fc-rate-btn.easy .fc-rate-label { color: var(--a1); }
  .fc-rate-btn.easy:hover { background: #1a2340; }

  .fc-unknown-area {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }
  .fc-unknown-btn {
    background: none;
    border: 1px dashed #6b3a8a;
    border-radius: 8px;
    padding: 8px 20px;
    cursor: pointer;
    color: #b07acc;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    transition: background 0.15s, border-color 0.15s;
  }
  .fc-unknown-btn:hover {
    background: rgba(107, 58, 138, 0.15);
    border-color: #b07acc;
  }
  .fc-unknown-input-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .fc-unknown-input-wrap textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid #6b3a8a;
    border-radius: 6px;
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    padding: 8px 10px;
    resize: none;
    height: 50px;
  }
  .fc-unknown-input-wrap textarea:focus {
    outline: none;
    border-color: #b07acc;
  }
  .fc-unknown-submit {
    align-self: flex-end;
    background: rgba(107, 58, 138, 0.2);
    border: 1px solid #6b3a8a;
    border-radius: 5px;
    color: #b07acc;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    padding: 5px 14px;
    cursor: pointer;
  }
  .fc-unknown-submit:hover { background: rgba(107, 58, 138, 0.35); }
  .fc-unknown-btn kbd {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 3px;
    padding: 0 4px;
    line-height: 16px;
    color: inherit;
    opacity: 0.6;
    margin-right: 4px;
  }

  .due-badge {
    font-size: 8px;
    padding: 1px 5px;
    border-radius: 8px;
    background: #2a1a3a;
    color: var(--p1);
    border: 1px solid #3a2a5a;
    margin-left: 4px;
  }

  .fc-complete {
    text-align: center;
    padding: 30px 0;
  }
  .fc-complete-title { font-size: 18px; color: var(--text); margin-bottom: 8px; }
  .fc-complete-sub { font-size: 11px; color: var(--text-dim); margin-bottom: 20px; }
  .fc-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: 320px;
    margin: 0 auto 20px;
  }
  .fc-stat-box {
    padding: 8px;
    border-radius: 5px;
    background: var(--surface2);
    border: 1px solid var(--border);
  }
  .fc-stat-num { font-size: 18px; font-weight: 300; }
  .fc-stat-label { font-size: 8px; color: var(--text-mute); letter-spacing: 0.05em; }

  .wrong-topic {
    font-size: 12px;
    color: var(--text);
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .wrong-subject {
    font-size: 10px;
    color: var(--text-dim);
    margin-bottom: 3px;
  }
  .wrong-count-badge {
    background: #3a2020;
    color: var(--red);
    border: 1px solid #4a2222;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
    flex-shrink: 0;
  }
  .wrong-ans-row { display: flex; gap: 6px; align-items: flex-start; margin-top: 3px; }
  .wrong-label { font-size: 10px; color: var(--text-dim); padding-top: 1px; white-space: nowrap; }
  .wrong-text  { font-size: 11px; }
  .wrong-wrong { color: #e08080; }
  .wrong-right { color: #70d0a0; }

  #back-btn {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-dim);
    cursor: pointer;
    padding: 5px 8px;
    letter-spacing: 0.04em;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface2);
    transition: all 0.12s;
    margin-bottom: 12px;
    width: fit-content;
  }
  #back-btn:hover { color: var(--text); border-color: var(--border2); background: var(--surface3); }
  #back-btn svg { width: 10px; height: 10px; }

  #chart-panel {
    border-top: 1px solid var(--border);
    background: var(--surface);
    display: grid;
    grid-template-columns: 200px 220px 1fr;
    padding: 0;
    overflow: hidden;
  }

  .bottom-panel-col {
    padding: 12px 16px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    overflow: hidden;
    min-width: 0;
  }

  .chart-meta-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin: 0;
  }

  .subj-prog-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .subj-prog-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .subj-prog-name {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .subj-prog-num {
    font-size: 9px;
    color: var(--text-dim);
  }
  .subj-prog-bar {
    height: 5px;
    background: var(--surface3);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
  }
  .subj-prog-touched {
    position: absolute;
    left: 0; top: 0; height: 100%;
    background: #6b7280;
    border-radius: 2px;
  }
  .subj-prog-fill {
    position: absolute;
    left: 0; top: 0; height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
  }

  .chart-stat { margin-bottom: 2px; }
  .chart-stat-num {
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.2;
  }
  .chart-stat-label {
    font-size: 9px;
    color: var(--text-dim);
    letter-spacing: 0.03em;
  }

  .streak-area {
    margin-top: auto;
    display: flex;
    align-items: flex-end;
    gap: 12px;
  }
  .streak-num {
    font-size: 14px;
    font-weight: 600;
    color: #f59e0b;
    white-space: nowrap;
    line-height: 1;
    padding-bottom: 2px;
  }
  .streak-num span {
    font-size: 9px;
    font-weight: 400;
    color: var(--text-dim);
    margin-left: 2px;
  }
  .streak-bars {
    display: flex;
    gap: 3px;
    flex: 1;
    align-items: flex-end;
    height: 30px;
  }
  .streak-bars > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    height: 100%;
    justify-content: flex-end;
  }
  .streak-bar {
    width: 100%;
    border-radius: 2px;
    min-height: 0;
  }
  .streak-bar-stack {
    width: 100%;
    display: flex;
    flex-direction: column-reverse;
    gap: 0;
    border-radius: 3px;
    overflow: hidden;
    cursor: default;
  }
  .streak-col { position: relative; }
  .streak-tip {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 8px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
  }
  .streak-col:hover .streak-tip { display: block; }
  .streak-day {
    font-size: 7px;
    color: var(--text-dim);
    line-height: 1;
  }


  .action-grid {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    align-items: stretch;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
  }
  .action-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.15s;
    overflow: hidden;
    min-width: 120px;
    max-width: 150px;
    flex-shrink: 0;
  }
  .action-card-all {
    background: var(--surface3);
    border: 1px dashed var(--border2);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    flex-shrink: 0;
    font-size: 9px;
    color: var(--text-mute);
    transition: color 0.15s;
  }
  .action-card-all:hover { color: var(--red); }
  .action-card:hover { border-color: var(--border2); }
  .action-card-type {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .action-card-title {
    font-size: 12px;
    color: var(--text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
  }
  .action-card-sub {
    font-size: 9px;
    color: var(--text-mute);
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Heatmap (unused, kept for reference) */
  #heatmap-wrap {
    padding: 12px 12px 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .heatmap-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-shrink: 0;
  }
  .heatmap-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    align-items: start;
  }
  .heatmap-cell {
    width: 100%;
    height: 22px;
    border-radius: 3px;
    background: var(--surface3);
    cursor: default;
    position: relative;
    transition: filter 0.1s;
  }
  .heatmap-cell:hover { filter: brightness(1.3); }
  .heatmap-cell.today {
    outline: 1px solid var(--text-dim);
    outline-offset: 1px;
  }
  .heatmap-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 9px;
    color: var(--text);
    white-space: nowrap;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
    line-height: 1.7;
  }
  .heatmap-cell:hover .heatmap-tooltip { display: block; }

  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

  /* Wrong full view tab */
  #wrong-full-view {
    display: none;
    grid-column: 1 / -1;
    padding: 16px 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
  }
  #wrong-full-view.active { display: block; }

  .wrong-full-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .wrong-full-filters {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
  }
  .wrong-full-filter-btn {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    padding: 4px 12px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.12s;
  }
  .wrong-full-filter-btn:hover { border-color: var(--border2); color: var(--text); }
  .wrong-full-filter-btn.active { background: var(--surface3); border-color: var(--border2); color: var(--text); }

  .wrong-full-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 10px;
    color: var(--text-dim);
  }

  .wrong-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
    align-items: start;
  }

  .wrong-card {
    position: relative;
    padding: 8px 12px 8px 18px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .wrong-card.expanded {
    background: var(--surface2);
    border-color: var(--border2);
  }
  .wrong-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    border-radius: 6px 0 0 6px;
    background: var(--card-color, var(--red));
  }
  .wrong-card-body {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
  }
  .wrong-card-topic {
    font-size: 11px;
    color: var(--text);
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .wrong-card-expand {
    display: none;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
  }
  .wrong-card.expanded .wrong-card-expand { display: block; }
  .wrong-card-play {
    font-size: 9px;
    color: var(--a1);
    border: 1px solid var(--a1);
    border-radius: 4px;
    padding: 2px 8px;
    flex-shrink: 0;
    display: none;
  }
  .wrong-card.expanded .wrong-card-play { display: inline; }
  .wrong-card-ans {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    margin-top: 3px;
  }
  .wrong-card-label {
    font-size: 10px;
    color: var(--text-dim);
    padding-top: 1px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .wrong-card-text { font-size: 11px; line-height: 1.5; }
  .wrong-card-x { color: #e08080; }
  .wrong-card-o { color: #70d0a0; }
  .wrong-card-subject {
    font-size: 9px;
    color: var(--text-mute);
    margin-bottom: 4px;
  }

  /* Tab style for wrong tab — pill style, visually separated */
  .tab.wrong-tab {
    background: var(--red-bg);
    border: 1px solid #3a2020;
    border-radius: 5px;
    margin: 4px 8px 4px 0;
    padding: 0 12px;
    border-bottom: none;
    top: 0;
  }
  .tab.wrong-tab .tab-dot { background: var(--red); }
  .tab.wrong-tab.active {
    background: #3a2020;
    border-color: var(--red);
    color: var(--red);
  }

  /* Right panel summary cards */
  .wrong-summary-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
  }
  .wrong-summary-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
  }
  .wrong-summary-name {
    font-size: 11px;
    color: var(--text);
    flex: 1;
  }
  .wrong-summary-count {
    font-size: 11px;
    font-weight: 500;
  }
  /* Subject overview panel */
  .subject-overview-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .subject-overview-section:last-child { border-bottom: none; }

  /* Stat boxes */
  .stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
  .stat-box {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
    padding: 8px 10px; display: flex; flex-direction: column; gap: 1px;
  }
  .stat-box-label { font-size: 9px; color: var(--text-mute); }
  .stat-box-val { font-size: 18px; font-weight: 600; color: var(--text); line-height: 1.2; font-family: 'DM Mono', monospace; }
  .stat-box-sub { font-size: 9px; color: var(--text-mute); }

  /* 회독 추천 배너 */
  .hoedok-banner {
    background: color-mix(in srgb, var(--a1) 10%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--a1) 25%, var(--border));
    border-radius: 6px; padding: 8px 11px;
    display: flex; gap: 8px; align-items: flex-start;
  }
  .hoedok-banner-icon { font-size: 12px; flex-shrink: 0; margin-top: 1px; }
  .hoedok-banner-text { font-size: 11px; color: var(--a1); line-height: 1.5; }
  .hoedok-banner-text strong { font-weight: 600; color: var(--text); display: block; }

  /* 회독 타임라인 엔트리 */
  .hd-entry { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
  .hd-entry + .hd-entry { border-top: 1px solid var(--border); }
  .hd-dot {
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; flex-shrink: 0;
  }
  .hd-dot.hd-r { background: var(--red-bg); color: var(--red); border: 1.5px solid color-mix(in srgb, var(--red) 50%, transparent); }
  .hd-dot.hd-y { background: var(--yel-bg); color: var(--yel); border: 1.5px solid color-mix(in srgb, var(--yel) 50%, transparent); }
  .hd-dot.hd-g { background: var(--grn-bg); color: var(--grn); border: 1.5px solid color-mix(in srgb, var(--grn) 50%, transparent); }
  .hd-info { flex: 1; }
  .hd-top { display: flex; justify-content: space-between; align-items: center; }
  .hd-label { font-size: 12px; color: var(--text); font-weight: 500; }
  .hd-date { font-size: 10px; color: var(--text-mute); }
  .hd-sub { font-size: 10px; color: var(--text-mute); margin-top: 1px; }
  .hd-del {
    cursor: pointer; font-size: 10px; color: var(--text-mute); opacity: 0.4;
    transition: opacity .15s, color .15s; margin-left: 4px;
  }
  .hd-del:hover { opacity: 1; color: var(--red); }

  /* 회독 추가 버튼 */
  .hd-add-row {
    display: flex; align-items: center; gap: 7px; margin-top: 8px;
    padding: 7px 10px; border: 1px dashed var(--border2); border-radius: 6px;
    cursor: pointer; transition: border-color 0.12s;
  }
  .hd-add-row:hover { border-color: var(--a1); }
  .hd-add-row span { font-size: 11px; color: var(--text-mute); }
  .hd-add-row:hover span { color: var(--a1); }

  /* 중단원 소단원 목록 */
  .rel-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    border-radius: 4px; margin-bottom: 2px; cursor: pointer;
    transition: background 0.12s;
  }
  .rel-item:hover { background: var(--surface2); }
  .rel-item.rel-active { background: var(--surface2); border-left: 2px solid var(--a1); }
  .rel-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
  .rel-title { font-size: 11px; color: var(--text-dim); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rel-item.rel-active .rel-title { color: var(--text); font-weight: 500; }
  .rel-badge { font-size: 9px; padding: 2px 6px; border-radius: 99px; flex-shrink: 0; font-weight: 500; }
  .rel-badge.rb-done { background: var(--grn-bg); color: var(--grn); }
  .rel-badge.rb-none { color: var(--text-mute); }
  .detail-level-btns {
    display:flex; align-items:center; gap:0;
    border:1px solid var(--border); border-radius:5px; overflow:hidden;
  }
  .detail-lvl-btn {
    flex:1; display:flex; align-items:center; justify-content:center; gap:4px;
    background:none; border:none; border-right:1px solid var(--border); color:var(--text-dim);
    padding:5px 0; font-size:10px; font-family:inherit;
    cursor:pointer; transition:all .12s;
  }
  .detail-lvl-btn:last-child { border-right:none; }
  .detail-lvl-btn:hover { background:var(--surface2); color:var(--text); }
  .detail-lvl-btn.active { background:var(--surface2); color:var(--text); }
  .dlb-dot { width:6px; height:6px; border-radius:50%; flex-shrink:0; }
  .subject-overview-label {
    font-size: 12px;
    color: #e0e2ea;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 8px;
    font-weight: 600;
    padding-bottom: 0;
    border-bottom: none;
  }
  .progress-bar-stacked {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg2);
    margin-bottom: 10px;
  }
  .progress-bar-stacked > div {
    height: 100%;
    transition: width 0.3s;
  }
  .progress-counts {
    display: flex;
    gap: 10px;
  }
  .progress-counts span {
    font-size: 9px;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
  }
  .progress-counts .dot {
    width: 6px; height: 6px; border-radius: 2px; display: inline-block; flex-shrink: 0;
  }
  .overview-wrong-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .overview-wrong-row .stats {
    font-size: 11px;
    color: var(--text);
  }
  .overview-wrong-row .stats em {
    font-style: normal;
    color: var(--red);
    font-weight: 600;
  }
  .overview-review-btn {
    background: transparent;
    border: 1px solid var(--a1);
    color: var(--a1);
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: all 0.12s;
  }
  .overview-review-btn:hover:not(:disabled) {
    background: var(--a1);
    color: #fff;
  }
  .overview-review-btn:disabled {
    opacity: 0.3;
    cursor: default;
  }
  .progress-counts span.dim {
    opacity: 0.35;
  }
  .weak-section-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    font-size: 10px;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.1s;
  }
  .weak-section-item:hover {
    background: var(--surface2);
  }
  .weak-section-item .rank {
    color: var(--text-mute);
    font-size: 9px;
    width: 14px;
    flex-shrink: 0;
  }
  .weak-section-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .weak-section-lvl {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    font-size: 10px;
  }
  .weak-section-lvl span { opacity: 0.5; }
  .weak-section-lvl span.has { opacity: 1; }
  .weak-section-item .wrong-cnt {
    font-size: 9px;
    color: var(--red);
    flex-shrink: 0;
  }
  /* 취약 소단원 */
  .weak-subtopic-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 3px;
  }
  .weak-subtopic-item:last-child { border-bottom: none; }
  .weak-subtopic-item:hover { background: var(--surface2); }
  .weak-subtopic-sec {
    font-size: 9px;
    color: var(--text-mute);
    display: block;
    margin-bottom: 2px;
  }
  .weak-subtopic-name {
    font-size: 10px;
    color: var(--red);
    display: block;
  }
  .weak-subtopic-note {
    font-size: 9px;
    color: var(--text-dim);
    display: block;
    margin-top: 3px;
    line-height: 1.4;
    font-style: italic;
  }

  /* 요일별 학습 히트맵 */
  .overview-heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
  }
  .overview-heatmap .day-label {
    font-size: 10px;
    color: var(--text-mute);
    text-align: center;
    padding-bottom: 4px;
  }
  .overview-heatmap .hm-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--surface3);
    position: relative;
  }
  .overview-heatmap .hm-cell.has-study { opacity: 0.3; }
  .overview-heatmap .hm-cell.has-study.lvl-1 { opacity: 0.4; }
  .overview-heatmap .hm-cell.has-study.lvl-2 { opacity: 0.6; }
  .overview-heatmap .hm-cell.has-study.lvl-3 { opacity: 0.85; }
  .overview-heatmap .hm-cell.today { outline: 2px solid var(--text-dim); outline-offset: -1px; }
  .overview-heatmap .hm-cell .hm-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface3);
    color: var(--text);
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
  }
  .overview-heatmap .hm-cell:hover .hm-tooltip { display: block; }

  .wrong-open-btn {
    display: block;
    width: calc(100% - 28px);
    margin: 10px 14px;
    padding: 8px;
    background: var(--red-bg);
    border: 1px solid #4a2222;
    border-radius: 5px;
    color: var(--red);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.12s;
    letter-spacing: 0.04em;
  }
  .wrong-open-btn:hover { filter: brightness(1.2); }

  /* Wrong full-view: two-column layout */
  .wrong-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 4px;
  }
  .wrong-col {
    min-width: 0;
  }
  .wrong-col-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
  }
  .wrong-col-title {
    font-size: 13px;
    font-weight: 500;
  }
  .wrong-col-count {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 10px;
  }
  .wrong-col-desc {
    font-size: 9px;
    color: var(--text-mute);
    margin-left: auto;
    margin-right: 4px;
  }

  /* Left column: unreviewed — "inbox" feel */
  .wrong-col-left .wrong-col-header {
    border-color: var(--border2);
  }
  .wrong-col-left .wrong-col-title { color: var(--text); }
  .wrong-col-left .wrong-col-count {
    background: var(--surface3);
    color: var(--text-dim);
  }
  .wrong-col-left .wrong-card {
    opacity: 0.85;
    border-style: dashed;
  }
  .wrong-col-left .wrong-card:hover { opacity: 1; }
  .wrong-start-btn {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--a1);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: filter 0.12s;
  }
  .wrong-start-btn:hover { filter: brightness(1.15); }

  /* Right column: reviewed — grouped by rating */
  .wrong-col-right .wrong-col-title { color: var(--grn); }
  .wrong-col-right .wrong-col-count {
    background: var(--grn-bg);
    color: var(--grn);
  }

  /* SRS rating group sections */
  .wrong-group-section {
    margin-top: 14px;
  }
  .wrong-group-section:first-child { margin-top: 0; }
  .wrong-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    user-select: none;
  }
  .wrong-group-header:hover { opacity: 0.85; }
  .wrong-group-bar {
    width: 4px;
    height: 18px;
    border-radius: 2px;
    flex-shrink: 0;
  }
  .wrong-group-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
  }
  .wrong-group-count {
    font-size: 9px;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--surface3);
    color: var(--text-dim);
  }
  .wrong-group-toggle {
    font-size: 10px;
    color: var(--text-mute);
    margin-left: auto;
    margin-right: 8px;
    transition: transform 0.2s;
  }
  .wrong-group-body {
    padding-left: 0;
    margin-top: 6px;
  }

  /* ─── SCHEDULE TAB ──────────────────────────────── */
  .tab-sep { width:1px; background:var(--border2); margin:8px 6px; flex-shrink:0; }
  #schedule-panel {
    display:none; padding:12px 16px 12px 20px; overflow-y:auto; height:100%;
    scrollbar-width:thin; scrollbar-color:var(--border2) transparent;
  }
  #schedule-panel.active { display:block; }
  #app.lecture-mode {
    grid-template-columns:1fr;
    grid-template-rows:52px 38px 1fr;
  }
  #app.lecture-mode #main {
    overflow:hidden;
    height:100%;
  }
  #lecture-full-view {
    display:none; overflow:hidden;
  }
  #lecture-full-view.active {
    display:block;
    height:100%; overflow:hidden;
  }
  #lecture-full-view.active > .qsel-layout {
    height:100%;
  }
  #lecture-full-view.active.qp-fullwidth {
    display:block; overflow-y:auto;
    height:100%;
  }
  .lec-left {
    display:flex; flex-direction:column; padding:0; overflow:hidden;
    border-right:1px solid var(--border);
  }
  .lec-left .lec-toolbar { padding-left:8px; padding-right:8px; }
  .lec-right {
    display:flex; flex-direction:column; padding:0; overflow:hidden;
  }
  .lec-toolbar {
    display:flex; align-items:center; gap:6px; padding:4px 0; flex-shrink:0;
    border-bottom:1px solid var(--border); margin-bottom:0; overflow-x:auto;
    scrollbar-width:none;
  }
  .lec-toolbar::-webkit-scrollbar { display:none; }
  .lec-select-sm {
    background:var(--surface2); color:var(--text); border:1px solid var(--border);
    border-radius:4px; padding:3px 6px; font-size:10px; font-family:inherit; outline:none;
    cursor:pointer; flex-shrink:0;
  }
  .lec-select-sm:focus { border-color:var(--a1); }
  .lec-toolbar-sep {
    width:1px; height:16px; background:var(--border); flex-shrink:0;
  }
  .lec-file-tab {
    display:inline-flex; align-items:center; gap:3px; padding:3px 8px;
    font-size:10px; color:var(--text-dim); cursor:pointer; border-radius:4px;
    white-space:nowrap; flex-shrink:0; transition:background .1s, color .1s;
  }
  .lec-file-tab:hover { background:var(--surface2); color:var(--text); }
  .lec-file-tab.active { background:var(--a1); color:#fff; }
  .lec-file-tab-x {
    font-size:9px; opacity:0; transition:opacity .1s; margin-left:2px;
  }
  .lec-file-tab:hover .lec-file-tab-x { opacity:0.6; }
  .lec-file-tab-x:hover { opacity:1 !important; }
  .lec-add-btn {
    display:flex; align-items:center; justify-content:center;
    width:22px; height:22px; border-radius:4px; font-size:14px;
    color:var(--text-mute); cursor:pointer; flex-shrink:0;
    border:1px dashed var(--border); transition:border-color .15s;
  }
  .lec-add-btn:hover { border-color:var(--a1); color:var(--a1); }
  .lec-dropzone {
    text-align:center; padding:32px 12px; border:2px dashed var(--border);
    border-radius:10px; cursor:pointer; transition:border-color .2s, background .2s;
    margin-bottom:12px;
  }
  .lec-dropzone.drag-over { border-color:var(--a1); background:rgba(91,138,245,0.06); }
  .lec-file-info {
    display:flex; align-items:center; gap:8px; padding:8px 12px;
    background:var(--surface2); border-radius:8px; margin-bottom:12px; font-size:11px;
  }
  .lec-pdf-viewer {
    border:none; border-radius:0;
    background:var(--bg); width:100%; height:100%;
    position:absolute; top:0; left:0; right:0; bottom:0;
  }
  #lec-viewer-area {
    position:relative; flex:1; min-height:0;
  }
  .lec-chat {
    flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:8px;
    scrollbar-width:thin; scrollbar-color:var(--border2) transparent;
  }
  .lec-img-preview {
    position:relative; display:inline-block; padding:8px 16px 4px;
  }
  .lec-chat-input-row {
    display:flex; gap:6px; padding:12px 16px; border-top:1px solid var(--border);
    background:var(--surface); flex-shrink:0;
  }
  .lec-chat-input {
    flex:1; background:var(--bg); color:var(--text); border:1px solid var(--border);
    border-radius:8px; padding:8px 12px; font-size:11px; font-family:inherit; outline:none;
    resize:none;
  }
  .lec-chat-input:focus { border-color:var(--a1); }
  .lec-chat-send {
    background:var(--a1); color:#fff; border:none; border-radius:8px;
    padding:6px 16px; font-size:11px; cursor:pointer; white-space:nowrap; flex-shrink:0;
  }
  .lec-chat-send:hover { opacity:0.9; }
  .lec-msg { padding:8px 12px; border-radius:8px; font-size:11px; line-height:1.6; max-width:85%; }
  .lec-msg-user {
    background:var(--surface2); align-self:flex-end; color:var(--text);
  }
  .lec-msg-ai {
    background:var(--surface); border:1px solid var(--border); align-self:flex-start;
    color:var(--text); white-space:pre-wrap;
  }
  .lec-popout-btn {
    position:absolute; top:8px; right:8px; z-index:10;
    background:var(--surface); border:1px solid var(--border); color:var(--text);
    border-radius:6px; width:28px; height:28px; cursor:pointer;
    font-size:14px; display:flex; align-items:center; justify-content:center;
    opacity:0.7; transition:opacity .15s;
  }
  .lec-popout-btn:hover { opacity:1; background:var(--a1); color:#fff; border-color:var(--a1); }
  .lec-file-list {
    display:flex; flex-direction:column; gap:2px; margin-bottom:6px; flex-shrink:0;
    max-height:120px; overflow-y:auto; scrollbar-width:thin;
  }
  .lec-file-item {
    display:flex; align-items:center; gap:6px; padding:4px 8px;
    background:var(--surface2); border-radius:4px; font-size:10px;
    cursor:pointer; transition:background .15s, border-color .15s;
    border:1px solid transparent;
  }
  .lec-file-item:hover { background:var(--bg); }
  .lec-file-item.active { border-color:var(--a1); background:var(--bg); }
  .lec-dropzone-mini {
    display:flex; align-items:center; justify-content:center; padding:4px;
    border:1px dashed var(--border); border-radius:4px; font-size:9px;
    color:var(--text-mute); cursor:pointer; transition:border-color .2s, background .2s;
  }
  .lec-dropzone-mini:hover { border-color:var(--a1); background:rgba(91,138,245,0.04); }
  .lec-empty-chat {
    flex:1; display:flex; align-items:center; justify-content:center;
    color:var(--text-mute); font-size:12px; text-align:center; padding:20px;
  }
  #memo-full-view {
    display:none; padding:24px 32px; overflow-y:auto; height:100%;
    scrollbar-width:thin; scrollbar-color:var(--border2) transparent;
  }
  #memo-full-view.active { display:flex; flex-direction:column; gap:20px; }
  .memo-chart-wrap { position:relative; width:100%; max-width:900px; height:320px; }
  .memo-stats-row { display:flex; gap:24px; flex-wrap:wrap; }
  .memo-stat { display:flex; flex-direction:column; gap:2px; }
  .memo-stat-num { font-size:28px; font-weight:700; letter-spacing:-0.02em; }
  .memo-stat-label { font-size:10px; color:var(--text-mute); letter-spacing:0.06em; text-transform:uppercase; }
  .sched-nav { display:flex; align-items:center; gap:12px; margin-bottom:12px; }
  .sched-nav-btn {
    background:var(--surface2); border:1px solid var(--border); color:var(--text-dim);
    font-family:'DM Mono',monospace; font-size:11px; padding:4px 10px;
    border-radius:4px; cursor:pointer; transition:all 0.12s;
  }
  .sched-nav-btn:hover { background:var(--surface3); color:var(--text); }
  .sched-week-label { font-size:12px; color:var(--text); }
  .sched-dates { font-size:9px; color:var(--text-mute); }
  .sched-grid {
    display:grid; grid-template-columns:46px repeat(5,1fr); gap:2px; font-size:10px;
  }
  .sched-day-hd {
    text-align:center; padding:6px 4px; font-size:9px; letter-spacing:0.08em;
    color:var(--text-dim); border-bottom:1px solid var(--border);
  }
  .sched-day-hd.today { color:var(--a1); border-bottom-color:var(--a1); font-weight:500; }
  .sched-time { font-size:9px; color:var(--text-mute); padding:4px 4px 4px 0; text-align:right; min-height:52px; display:flex; align-items:flex-start; justify-content:flex-end; }
  .sched-lunch { min-height:24px; align-items:center; color:var(--text-dim); font-style:italic; }
  .sched-lunch-bar { min-height:24px; border-bottom:1px dashed var(--border); }

  /* Schedule overview (right panel) */
  .so-section { padding:12px 14px; border-bottom:1px solid var(--border); }
  .so-section:last-child { border-bottom:none; }
  .so-label { font-size:11px; color:var(--text); font-weight:600; letter-spacing:0.02em; margin-bottom:10px; padding-bottom:6px; border-bottom:1px solid var(--border); }

  /* Mini calendar */
  .mini-cal-nav { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
  .mini-cal-nav button { background:none; border:none; color:var(--text-dim); cursor:pointer; font-size:13px; padding:2px 6px; border-radius:3px; }
  .mini-cal-nav button:hover { background:var(--surface3); }
  .mini-cal-month { font-size:11px; color:var(--text); font-weight:600; }
  .mini-cal { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; text-align:center; }
  .mini-cal-dh { font-size:8px; color:var(--text-mute); padding:2px 0; }
  .mini-cal-d { font-size:9px; color:var(--text-dim); padding:4px 0; border-radius:50%; cursor:pointer; position:relative; width:26px; height:26px; display:flex; align-items:center; justify-content:center; margin:0 auto; }
  .mini-cal-d:hover { background:var(--surface3); }
  .mini-cal-d.today { background:var(--a1); color:#fff; font-weight:600; }
  .mini-cal-d.selected { background:var(--surface3); outline:2px solid var(--a1); font-weight:600; color:var(--text); }
  .mini-cal-d.exam { color:var(--red); font-weight:600; }
  .mini-cal-d.exam::after { content:''; position:absolute; bottom:1px; width:4px; height:4px; border-radius:50%; background:var(--red); }
  .mini-cal-d.other-month { color:var(--text-mute); opacity:0.3; }
  .mini-cal-d.has-study { background:var(--grn-bg); }
  .mini-cal-d.today.has-study { background:var(--a1); }

  /* Today's classes */
  .so-class { display:flex; align-items:flex-start; gap:8px; padding:5px 0; border-bottom:1px solid var(--border); }
  .so-class:last-child { border-bottom:none; }
  .so-class-time { font-size:9px; color:var(--text-mute); min-width:36px; padding-top:1px; }
  .so-class-dot { width:6px; height:6px; border-radius:50%; margin-top:4px; flex-shrink:0; }
  .so-class-info { flex:1; }
  .so-class-title { font-size:10px; color:var(--text-dim); }
  .so-class-prof { font-size:8px; color:var(--text-mute); }
  .so-class-badge { font-size:7px; padding:1px 4px; border-radius:2px; margin-left:4px; }
  .so-empty { font-size:10px; color:var(--text-mute); padding:12px 0; text-align:center; }

  /* D-day list */
  .so-dday { display:flex; justify-content:space-between; align-items:center; padding:4px 0; }
  .so-dday-subj { font-size:10px; }
  .so-dday-val { font-size:10px; font-weight:600; }
  .sched-cell {
    min-height:52px; padding:5px 6px; border-radius:4px; border:1px solid transparent;
    font-size:9px; line-height:1.35; transition:filter 0.1s, border-color 0.15s;
    overflow:hidden; cursor:pointer; position:relative;
  }
  .sched-cell:hover { filter:brightness(1.2); }
  .sched-cell .sc-title { margin-bottom:1px; }
  .sched-cell .sc-prof { color:var(--text-dim); font-size:8px; opacity:0.8; }
  .sched-cell.sc-exam { background:var(--red-bg)!important; border-color:#4a2222!important; }
  .sched-cell.sc-exam .sc-title { color:var(--red)!important; font-weight:500; }
  .sched-cell.sc-lab { opacity:0.65; }
  .sched-cell.sc-today { box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--a1) 30%,transparent); }
  .sched-cell.sc-focused { box-shadow:inset 0 0 0 2px var(--a1); }
  .sched-cell.has-note::after {
    content:''; position:absolute; top:4px; right:4px; width:5px; height:5px;
    border-radius:50%; background:var(--yel);
  }
  .sched-empty { min-height:52px; cursor:default; }
  .sc-study-badge { position:absolute; bottom:3px; right:4px; font-size:7px; font-weight:600; border-radius:3px; padding:0 3px; line-height:14px; }
  .sc-study-badge.need { background:color-mix(in srgb,var(--red) 25%,transparent); color:var(--red); }
  .sc-study-badge.partial { background:color-mix(in srgb,var(--yel) 25%,transparent); color:var(--yel); }
  .sc-study-badge.ok { background:color-mix(in srgb,var(--grn) 20%,transparent); color:var(--grn); }

  /* Schedule note modal */
  #sched-note-modal { display:none; position:fixed; inset:0; z-index:300; background:rgba(17,19,24,0.92); align-items:center; justify-content:center; }
  #sched-note-modal.open { display:flex; }
  .sn-box {
    background:var(--surface); border:1px solid var(--border2); border-radius:10px;
    width:min(500px,90vw); max-height:80vh; padding:20px 24px; display:flex; flex-direction:column;
  }
  .sn-header { font-size:12px; color:var(--text); margin-bottom:4px; }
  .sn-sub { font-size:9px; color:var(--text-mute); margin-bottom:14px; }
  .sn-textarea {
    width:100%; min-height:120px; background:var(--surface2); border:1px solid var(--border);
    border-radius:5px; padding:10px 12px; color:var(--text); font-family:'DM Mono',monospace;
    font-size:11px; line-height:1.5; resize:vertical; outline:none; margin-bottom:12px;
  }
  .sn-textarea:focus { border-color:var(--a1); }
  .sn-textarea::placeholder { color:var(--text-mute); }
  /* Memo drawer */
  .memo-drawer {
    position:fixed; top:0; right:0; width:380px; height:100vh; z-index:200;
    background:var(--surface); border-left:1px solid var(--border2);
    display:flex; flex-direction:column; padding:16px;
    transform:translateX(100%); transition:transform 0.2s ease;
    box-shadow:-4px 0 20px rgba(0,0,0,0.3);
  }
  .memo-drawer.open { transform:translateX(0); }
  .memo-drawer-header { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
  .memo-drawer-color { width:3px; height:24px; border-radius:2px; flex-shrink:0; }
  .memo-drawer-title { font-size:12px; color:var(--text); font-weight:500; }
  .memo-drawer-sub { font-size:9px; color:var(--text-mute); margin-top:1px; }
  .memo-drawer-close { background:none; border:none; color:var(--text-mute); cursor:pointer; font-size:14px; padding:4px; }
  .memo-drawer-close:hover { color:var(--text); }
  .memo-drawer-input-row { margin-bottom:12px; }
  .memo-drawer-list { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:2px; }

  .sn-input-row { display:flex; gap:6px; margin-bottom:10px; }
  .sn-input {
    flex:1; background:var(--surface2); border:1px solid var(--border); border-radius:5px;
    padding:8px 12px; color:var(--text); font-family:'DM Mono',monospace; font-size:11px; outline:none;
  }
  .sn-input:focus { border-color:var(--a1); }
  .sn-input::placeholder { color:var(--text-mute); }
  .sn-memo-list { max-height:50vh; overflow-y:auto; display:flex; flex-direction:column; gap:2px; margin-bottom:12px; }
  .sn-memo {
    display:flex; align-items:flex-start; gap:8px; padding:6px 8px; border-radius:4px;
    background:var(--surface2); font-size:11px; line-height:1.4; color:var(--text);
  }
  .sn-memo.done { opacity:0.4; }
  .sn-memo.done .sn-memo-text { text-decoration:line-through; }
  .sn-memo input[type=checkbox] { margin-top:2px; flex-shrink:0; accent-color:var(--a1); }
  .sn-memo-text { flex:1; word-break:break-word; }
  .sn-memo-del { background:none; border:none; color:var(--text-mute); cursor:pointer; font-size:10px; padding:0 2px; flex-shrink:0; }
  .sn-memo-del:hover { color:var(--red); }
  .sn-actions { display:flex; gap:8px; justify-content:flex-end; }
  .sn-btn {
    background:var(--surface2); border:1px solid var(--border); color:var(--text-dim);
    font-family:'DM Mono',monospace; font-size:10px; padding:6px 14px; border-radius:5px;
    cursor:pointer; transition:all 0.1s;
  }
  .sn-btn:hover { background:var(--surface3); color:var(--text); }
  .sn-btn.primary { background:var(--a1); border-color:var(--a1); color:#fff; }
  .sn-btn.primary:hover { filter:brightness(1.1); }
  .sn-btn.danger { color:var(--red); border-color:#4a2222; }

  /* Todo section */
  #todo-modal { display:none; position:fixed; inset:0; z-index:300; background:rgba(17,19,24,0.92); align-items:center; justify-content:center; }
  #todo-modal.open { display:flex; }
  .todo-grid { display:flex; gap:6px; overflow-x:auto; overflow-y:hidden; flex:1; align-items:stretch; padding-bottom:4px; scrollbar-width:thin; scrollbar-color:var(--border2) transparent; }
  .todo-grid::-webkit-scrollbar { height:4px; }
  .todo-grid::-webkit-scrollbar-thumb { background:var(--border2); border-radius:2px; }
  .todo-group-label { display:none; }
  .todo-item { display:flex; flex-direction:column; gap:4px; padding:8px 10px; border-radius:6px; background:var(--surface2); font-size:10px; color:var(--text); cursor:default; min-width:140px; max-width:180px; flex-shrink:0; position:relative; border:1px solid var(--border); }
  .todo-item:hover { background:var(--surface3); border-color:var(--border2); }
  .todo-item.overdue { border-color:rgba(224,85,85,0.3); background:rgba(224,85,85,0.06); }
  .todo-item.done { opacity:0.35; }
  .todo-progress-wrap { display:flex; align-items:center; gap:6px; }
  .todo-progress-bar { height:4px; border-radius:2px; background:var(--surface3); flex:1; min-width:40px; overflow:hidden; }
  .todo-progress-fill { height:100%; border-radius:2px; background:var(--grn); transition:width 0.3s ease; }
  .todo-progress-text { font-size:9px; color:var(--text-dim); white-space:nowrap; }

  /* Daily questions review cards */
  /* Daily questions full view */
  #dq-full-view {
    display:none; grid-column:1/-1; padding:16px 24px; overflow-y:auto;
    scrollbar-width:thin; scrollbar-color:var(--border2) transparent;
  }
  #dq-full-view.active { display:block; }
  .dq-full-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; flex-wrap:wrap; gap:8px; }
  .dq-full-filters { display:flex; gap:4px; flex-wrap:wrap; }
  .dq-full-filter-btn { background:var(--surface2); border:1px solid var(--border); color:var(--text-dim); font-family:'DM Mono',monospace; font-size:10px; padding:4px 10px; border-radius:5px; cursor:pointer; }
  .dq-full-filter-btn:hover { border-color:var(--border2); color:var(--text); }
  .dq-full-filter-btn.active { border-color:var(--a1); color:var(--a1); background:rgba(91,138,245,0.08); }
  .dq-full-stats { display:flex; align-items:center; gap:10px; font-size:11px; color:var(--text-dim); }
  .dq-date-group { margin-bottom:20px; }
  .dq-date-label { font-size:11px; color:var(--text-mute); letter-spacing:0.05em; margin-bottom:8px; padding-bottom:4px; border-bottom:1px solid var(--border); }
  .dq-full-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(340px, 1fr)); gap:8px; }
  .dq-full-card { background:var(--surface2); border:1px solid var(--border); border-radius:6px; padding:12px 14px; cursor:pointer; border-left:4px solid transparent; transition:border-color 0.15s; }
  .dq-full-card:hover { border-color:var(--border2); }
  .dq-full-card.dq-wrong { border-left-color:var(--red); }
  .dq-full-card.dq-partial { border-left-color:#f59e0b; }
  .dq-full-card-header { display:flex; align-items:center; gap:6px; margin-bottom:6px; font-size:10px; }
  .dq-full-card-q { font-size:11px; color:var(--text); line-height:1.5; margin-bottom:6px; }
  .dq-full-card-a { font-size:11px; color:var(--grn); line-height:1.5; }
  .dq-full-card-user { display:none; font-size:10px; color:var(--text-mute); line-height:1.5; margin-top:8px; padding-top:8px; border-top:1px solid var(--border); }
  .dq-full-card.expanded .dq-full-card-user { display:block; }

  .todo-cat { font-size:8px; padding:1px 5px; border-radius:3px; color:#fff; white-space:nowrap; }
  .todo-add-btn { background:var(--surface3); border:1px solid var(--border); color:var(--text-dim); font-family:'DM Mono',monospace; font-size:9px; padding:2px 8px; border-radius:4px; cursor:pointer; }
  .todo-add-btn:hover { color:var(--text); border-color:var(--border2); }
  .todo-check { width:14px; height:14px; border-radius:3px; border:1px solid var(--border2); background:none; cursor:pointer; flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:9px; color:var(--grn); }
  .todo-check.checked { background:var(--grn); border-color:var(--grn); color:#fff; }
  .todo-del { position:absolute; top:4px; right:5px; background:none; border:none; color:var(--text-mute); font-size:12px; cursor:pointer; padding:0; line-height:1; }
  .todo-del:hover { color:var(--red); }
  .todo-title { font-size:10px; color:var(--text); line-height:1.35; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; flex:1; }
  .todo-item.done .todo-title { text-decoration:line-through; }
  .todo-time { font-size:8px; color:var(--text-mute); white-space:nowrap; }
  .todo-item-top { display:flex; align-items:center; gap:5px; }
  .todo-item-bottom { display:flex; align-items:center; justify-content:space-between; margin-top:auto; }
  .todo-group-label { font-size:9px; color:var(--text-mute); padding:4px 0 2px; letter-spacing:0.04em; }
  .sn-btn.danger:hover { background:var(--red-bg); }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .topic-cell { animation: fadeIn 0.15s ease both; }

  /* Pending change indicator on cells */
  .topic-cell.pending { outline: 2px dashed var(--yel); outline-offset: -1px; }
  .topic-cell.pending .cell-star-btn { opacity: 1; }

  /* Submit bar */
  #submit-bar {
    display: none;
    position: fixed;
    bottom: 156px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 8px 12px 8px 16px;
    z-index: 100;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: fcIn 0.18s ease;
  }
  #submit-bar.show { display: flex; }
  .submit-info {
    font-size: 10px;
    color: var(--text-dim);
  }
  .submit-info strong {
    color: var(--yel);
    font-weight: 500;
  }
  .submit-btn {
    background: var(--grn);
    border: none;
    color: #111;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 5px;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: filter 0.1s;
  }
  .submit-btn:hover { filter: brightness(1.15); }
  .submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
  .discard-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-mute);
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.1s;
  }
  .discard-btn:hover { color: var(--red); border-color: #4a2222; }

  /* Loading indicator */
  #loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    color: var(--text-mute);
  }
  .loading-logo {
    font-family: 'Cormorant Garamond', serif;
    font-size: 28px;
    font-style: italic;
    color: #e8eaf5;
    letter-spacing: 0.02em;
  }
  .loading-logo span { color: var(--a1); }
  .loading-dots {
    display: flex; gap: 5px;
  }
  .loading-dots span {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--border2);
    animation: loadpulse 1.2s ease-in-out infinite;
  }
  .loading-dots span:nth-child(2) { animation-delay: 0.2s; }
  .loading-dots span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes loadpulse {
    0%,80%,100% { background: var(--border2); }
    40%         { background: var(--a1); }
  }
  .loading-text { font-size: 10px; letter-spacing: 0.1em; }

  /* ── Notification bell ── */
  .notif-wrap { position: relative; margin-left: auto; }
  .notif-btn {
    background: none; border: none; color: var(--text-dim); font-size: 16px;
    cursor: pointer; padding: 4px 8px; position: relative;
  }
  .notif-btn:hover { color: var(--text); }
  .notif-dot {
    position: absolute; top: 2px; right: 4px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--red); display: none;
  }
  .notif-dot.show { display: block; }
  .notif-popup {
    display: none; position: absolute; top: 100%; right: 0; margin-top: 6px;
    background: var(--surface); border: 1px solid var(--border2); border-radius: 8px;
    padding: 12px 16px; min-width: 260px; z-index: 300;
    font-size: 11px; color: var(--text); line-height: 1.6;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }
  .notif-popup.open { display: block; }
  .notif-msg { padding: 6px 0; border-bottom: 1px solid var(--border); }
  .notif-msg:last-child { border-bottom: none; }

  /* ── Mobile responsive ── */
  /* ── Mobile styles (standalone #mobile-app, JS-switched) ── */
  .mob-review-btn {
    background: var(--a1); border: none; color: #fff;
    font-family: 'DM Mono', monospace; font-size: 16px;
    padding: 22px; border-radius: 12px; cursor: pointer;
    text-align: center; letter-spacing: 0.02em; width: 100%;
  }
  .mob-review-btn:active { opacity: 0.85; transform: scale(0.98); }
  .mob-btn-sub { font-size: 11px; opacity: 0.7; margin-top: 6px; }

  .mob-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .mob-stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px; text-align: center;
  }
  .mob-stat-num { font-size: 24px; font-weight: 300; }
  .mob-stat-label { font-size: 10px; color: var(--text-mute); margin-top: 4px; letter-spacing: 0.05em; }

  .mob-section-title { font-size: 10px; color: var(--text-mute); letter-spacing: 0.08em; margin-top: 6px; }
  .mob-subject-list { display: flex; flex-direction: column; gap: 8px; }
  .mob-subject-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 16px; cursor: pointer;
  }
  .mob-subject-row:active { background: var(--surface2); }
  .mob-subj-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .mob-subj-name { flex: 1; font-size: 13px; }
  .mob-subj-pct { font-size: 12px; color: var(--text-dim); }

  /* ── Flashcard mobile (when viewport is narrow) ── */
  @media (max-width: 768px) {
    #fc-overlay { padding: 6px; align-items: center; justify-content: center; }
    #fc-card {
      width: 100% !important; max-width: 100vw;
      min-height: auto; padding: 28px 20px;
      border-radius: 14px; margin: 0;
      justify-content: center; align-items: center;
    }
    #fc-card:hover { transform: none; }
    .fc-question { font-size: 16px; padding: 16px 0; line-height: 1.7; text-align: center; }
    .fc-question-flipped { font-size: 16px; line-height: 1.7; margin-bottom: 12px; }
    .fc-ans-text { font-size: 15px; padding: 14px 16px; line-height: 1.6; width: 100%; box-sizing: border-box; }
    .fc-answer.show { width: 100%; }
    .fc-ans-row { width: 100%; }
    .fc-my-answer { font-size: 14px; min-height: 80px; }
    .fc-rating { width: 100%; gap: 6px; }
    .fc-rate-btn { flex: 1; min-width: 0; padding: 12px 6px; font-size: 11px; }
    .fc-unknown-area { width: 100%; }
    .fc-unknown-btn { width: 100%; }
    .fc-nav {
      flex-wrap: wrap; justify-content: center; gap: 8px;
      width: 100%; padding: 0 4px;
    }
    .fc-nav-btn {
      padding: 14px 0; font-size: 13px;
      flex: 1; min-width: 55px; text-align: center;
    }
    .fc-close-btn { padding: 14px 18px; font-size: 13px; }
    .fc-shortcut-hint { display: none !important; }
    .fc-hint { font-size: 12px; }
  }

/* ─── Login styles ─── */
/* Login screen */
#login-screen { display:flex; flex-direction:column; align-items:center; justify-content:center; height:100vh; gap:32px; background:var(--bg); }
#login-screen .login-logo { font-family:'Cormorant Garamond',serif; font-size:48px; font-style:italic; color:var(--text); }
#login-screen .login-logo b { color:#fff; }
#login-screen .login-subtitle { color:var(--text-dim); font-size:13px; margin-top:-20px; }
#login-screen .error-msg { color:var(--red); font-size:12px; min-height:18px; }

/* ─── Quiz ─── */
.quiz-progress { font-size:10px; color:var(--text-mute); margin-bottom:4px; }
.quiz-type-badge { display:inline-block; font-size:9px; padding:1px 6px; border-radius:3px; background:var(--surface3); color:var(--text-dim); margin-bottom:6px; }
.quiz-question-text { font-size:12px; color:var(--text); line-height:1.6; margin-bottom:10px; white-space:pre-wrap; }
.quiz-ox-btns { display:flex; gap:8px; margin-bottom:8px; }
.quiz-ox-btn { flex:1; padding:8px; border:1px solid var(--border2); border-radius:6px; background:var(--surface2); color:var(--text); font-size:14px; font-weight:600; cursor:pointer; transition:border-color .15s, background .15s; font-family:inherit; }
.quiz-ox-btn:not(:disabled):hover { border-color:var(--a1); background:var(--surface3); }
.quiz-ox-btn:disabled { cursor:default; opacity:0.7; }
.quiz-mcq-opts { display:flex; flex-direction:column; gap:4px; margin-bottom:8px; }
.quiz-mcq-btn { text-align:left; padding:7px 10px; border:1px solid var(--border2); border-radius:5px; background:var(--surface2); color:var(--text); font-size:11px; cursor:pointer; transition:border-color .15s, background .15s; font-family:inherit; line-height:1.5; }
.quiz-mcq-btn:not(:disabled):hover { border-color:var(--a1); background:var(--surface3); }
.quiz-mcq-btn:disabled { cursor:default; }
.quiz-opt-correct { border-color:var(--grn) !important; background:var(--grn-bg) !important; color:var(--grn) !important; }
.quiz-opt-wrong { border-color:var(--red) !important; background:var(--red-bg) !important; color:var(--red) !important; }
.quiz-opt-answer { border-color:var(--grn) !important; background:var(--grn-bg) !important; opacity:0.6; }
.quiz-explanation { font-size:11px; color:var(--text-dim); padding:8px 10px; background:var(--surface2); border-radius:5px; margin-bottom:8px; line-height:1.6; }
.quiz-expl-label { font-weight:600; margin-right:4px; }
.quiz-opt-correct + .quiz-explanation .quiz-expl-label,
.quiz-explanation .quiz-expl-label { color:var(--grn); }
.quiz-opt-wrong ~ .quiz-explanation .quiz-expl-label { color:var(--red); }
.quiz-nav { display:flex; gap:6px; justify-content:center; }
.quiz-nav-btn { padding:4px 14px; border:1px solid var(--border2); border-radius:4px; background:var(--surface2); color:var(--text-dim); font-size:10px; cursor:pointer; font-family:inherit; }
.quiz-nav-btn:not(:disabled):hover { border-color:var(--a1); color:var(--text); }
.quiz-nav-btn:disabled { opacity:0.3; cursor:default; }

/* ─── Quiz Select (학습도구 탭) ─── */
.qsel-main { overflow-y:auto; min-height:0; background:var(--bg); }
.qsel-sidebar {
  border-left:1px solid var(--border); padding:16px; overflow-y:auto; min-height:0;
  background:var(--bg);
}

/* Quiz select layout */
.qsel-layout { display:grid; grid-template-columns:1fr 260px; height:100%; }
.qsel-main-scroll { overflow-y:auto; padding:20px 24px; }
.qsel-sidebar-r { border-left:0.5px solid var(--border); padding:20px; overflow-y:auto; background:var(--surface); }

/* Tabs */
.qsel-tabs { display:flex; gap:6px; margin-bottom:4px; }
.qsel-tab {
  padding:5px 13px; border-radius:99px; font-size:12px; cursor:pointer;
  border:0.5px solid var(--border2); color:var(--text-mute); background:transparent;
  font-family:inherit; transition:all .12s;
}
.qsel-tab:hover { border-color:var(--border2); color:var(--text-dim); }
.qsel-tab.on-a { background:rgba(91,138,245,0.12); border-color:rgba(91,138,245,0.4); color:var(--a1); }
.qsel-tab.on-p { background:rgba(196,122,240,0.12); border-color:rgba(196,122,240,0.4); color:var(--p1); }
.qsel-tab.on-b { background:rgba(240,147,74,0.12); border-color:rgba(240,147,74,0.4); color:var(--b1); }

/* Section accordion */
.qsel-sec { border:0.5px solid var(--border); border-radius:8px; overflow:hidden; background:var(--surface); margin-bottom:10px; }
.qsel-sec-header {
  display:flex; align-items:center; gap:12px; padding:14px 16px;
  cursor:pointer; transition:background .12s; border-left:3px solid var(--border);
  user-select:none;
}
.qsel-sec-header:hover { background:var(--surface2); }
.qsel-sec-arrow { font-size:10px; color:var(--text-mute); transition:transform .2s; flex-shrink:0; }
.qsel-sec.open .qsel-sec-arrow { transform:rotate(90deg); }
.qsel-sec-info { flex:1; min-width:0; }
.qsel-sec-name { font-size:13px; color:#e0e2ea; font-weight:500; }
.qsel-sec-sub { font-size:10px; color:var(--text-mute); margin-top:2px; }
.qsel-sec-stats { display:flex; align-items:center; gap:10px; flex-shrink:0; }
.qsel-sec-ring { position:relative; width:28px; height:28px; }
.qsel-sec-ring svg { width:100%; height:100%; }
.qsel-sec-ring-text { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:7px; color:var(--text-dim); }
.qsel-sec-empty-badge { font-size:9px; color:var(--text-mute); }
.qsel-sec-bar { width:48px; height:2px; background:var(--border); border-radius:99px; overflow:hidden; }
.qsel-sec-bar-fill { height:100%; border-radius:99px; }

/* Section body (hidden by default) */
.qsel-sec-body { display:none; border-top:0.5px solid var(--border); }
.qsel-sec.open .qsel-sec-body { display:block; }

/* Topic rows inside accordion */
.qsel-topic {
  display:flex; align-items:center; gap:12px;
  padding:10px 16px 10px 32px; border-bottom:0.5px solid var(--border);
  cursor:pointer; transition:background .12s;
}
.qsel-topic:last-child { border-bottom:none; }
.qsel-topic:hover { background:var(--surface2); }
.qsel-topic.empty { opacity:0.4; cursor:default; }
.qsel-topic.empty:hover { background:transparent; }
.qsel-topic-left { flex:1; min-width:0; }
.qsel-topic-name { font-size:12px; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.qsel-topic-meta { font-size:10px; color:var(--text-mute); margin-top:2px; }
.qsel-topic-right { display:flex; align-items:center; gap:8px; flex-shrink:0; }

.qsel-score { font-size:11px; color:var(--text-mute); min-width:28px; text-align:right; }
.qsel-score.good { color:var(--grn); }
.qsel-score.mid { color:var(--a1); }

.qsel-badge { font-size:10px; padding:3px 8px; border-radius:99px; white-space:nowrap; }
.qsel-badge.new { background:rgba(91,138,245,0.1); color:var(--a1); border:0.5px solid rgba(91,138,245,0.3); }
.qsel-badge.progress { background:rgba(91,138,245,0.07); color:#4a7ad0; border:0.5px solid rgba(91,138,245,0.2); }
.qsel-badge.done { background:rgba(74,172,120,0.1); color:var(--grn); border:0.5px solid rgba(74,172,120,0.3); }
.qsel-badge.empty { background:var(--surface2); color:var(--text-mute); border:0.5px solid var(--border); }

/* Sidebar stats */
.qsel-sb-title { font-size:13px; color:#e0e2ea; font-weight:600; margin-bottom:4px; }
.qsel-sb-big { font-size:36px; font-weight:300; color:var(--text); line-height:1.1; }
.qsel-sb-big span { font-size:14px; color:var(--text-dim); font-weight:400; }
.qsel-sb-detail { font-size:10px; color:var(--text-mute); margin-top:4px; margin-bottom:20px; }
.qsel-sb-section { margin-bottom:20px; }
.qsel-sb-label { font-size:10px; color:var(--text-mute); letter-spacing:0.06em; margin-bottom:8px; }
.qsel-sb-subj-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.qsel-sb-subj-dot { width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.qsel-sb-subj-name { font-size:11px; color:var(--text-dim); flex:1; }
.qsel-sb-subj-bar { flex:1; height:3px; background:var(--surface3); border-radius:2px; overflow:hidden; max-width:100px; }
.qsel-sb-subj-bar-fill { height:100%; border-radius:2px; }
.qsel-sb-subj-pct { font-size:10px; color:var(--text-dim); min-width:30px; text-align:right; font-variant-numeric:tabular-nums; }

/* ─── Quiz Modal Overlay ─── */
.qm-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:9999;
  display:flex; align-items:center; justify-content:center; padding:20px;
}
/* Quiz modal — study-dashboard style */
.qm-overlay { align-items:center; justify-content:center; }
.qm-outer { display:flex; align-items:stretch; gap:12px; width:100%; max-width:720px; }
.qm-nav-col { display:flex; flex-direction:column; gap:8px; flex-shrink:0; }
.qm-nav-big {
  flex:1; width:48px; border-radius:8px;
  background:var(--surface); border:0.5px solid var(--border);
  color:var(--text-mute); font-size:18px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all .12s;
}
.qm-nav-big:hover { background:var(--surface2); color:var(--text); border-color:var(--border2); }
.qm-nav-big:disabled { opacity:0.15; cursor:default; }
.qm-nav-big:disabled:hover { background:var(--surface); color:var(--text-mute); }
.qm-modal {
  flex:1; min-width:0;
  background:var(--surface); border:1px solid var(--border); border-radius:12px;
  padding:24px 28px;
  box-shadow:0 8px 32px rgba(0,0,0,0.5);
}

/* ─── Quiz Play ─── */
.qp-wrap { padding: 32px 40px; max-width: 600px; margin: 0 auto; }
.qp-top-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.qp-back-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); font-size: 11px; padding: 5px 12px; cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.qp-back-btn:hover { color: var(--text); border-color: var(--text-mute); background: var(--surface); }
.qp-topic-name { flex: 1; font-size: 14px; font-weight: 500; }
.qp-counter { font-size: 12px; color: var(--text-mute); font-variant-numeric: tabular-nums; }

.qp-dots { display: flex; gap: 5px; margin-bottom: 20px; flex-wrap: wrap; }
.qp-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--surface3);
  cursor: pointer; transition: all .2s ease; border: 2px solid transparent;
}
.qp-dot:hover { transform: scale(1.25); background: var(--border2); }
.qp-dot.current { border-color: var(--a1); background: var(--surface3); }
.qp-dot.correct { background: var(--grn); border-color: var(--grn); }
.qp-dot.wrong { background: var(--red); border-color: var(--red); }

.qp-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px 28px; margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.qp-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.qp-type-badge {
  font-size: 10px; padding: 3px 10px; border-radius: 20px;
  background: var(--surface3); color: var(--text-dim); letter-spacing: 0.04em;
}
.qp-star-btn {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--surface3); transition: all .2s; line-height: 1;
}
.qp-star-btn:hover { color: var(--yel); transform: scale(1.15); }
.qp-star-btn.active { color: var(--yel); }
.qp-question {
  font-size: 15px; color: var(--text); line-height: 1.8; margin-bottom: 20px;
  white-space: pre-wrap; letter-spacing: -0.01em;
}

.qp-ox-btns { display: flex; gap: 12px; margin-bottom: 12px; }
.qp-ox-btn {
  flex: 1; padding: 16px; border: 1px solid var(--border2); border-radius: 10px;
  background: var(--surface2); color: var(--text); font-size: 20px; font-weight: 600;
  cursor: pointer; transition: all .2s ease; font-family: inherit;
}
.qp-ox-btn:not(:disabled):hover { border-color: var(--a1); background: var(--surface3); transform: translateY(-1px); }
.qp-ox-btn:disabled { cursor: default; opacity: 0.75; }

.qp-mcq-opts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.qp-mcq-btn {
  text-align: left; padding: 12px 16px; border: 1px solid var(--border2); border-radius: 10px;
  background: var(--surface2); color: var(--text); font-size: 13px; cursor: pointer;
  transition: all .2s ease; font-family: inherit; line-height: 1.6;
}
.qp-mcq-btn:not(:disabled):hover { border-color: var(--a1); background: var(--surface3); transform: translateX(2px); }
.qp-mcq-btn:disabled { cursor: default; }

.qp-opt-correct { border-color: var(--grn) !important; background: var(--grn-bg) !important; color: var(--grn) !important; }
.qp-opt-wrong { border-color: var(--red) !important; background: var(--red-bg) !important; color: var(--red) !important; }
.qp-opt-answer { border-color: var(--grn) !important; background: var(--grn-bg) !important; opacity: 0.6; }

.qp-explanation {
  font-size: 13px; color: var(--text-dim); padding: 14px 16px;
  background: var(--surface2); border-radius: 8px; margin-top: 12px; line-height: 1.7;
  border-left: 3px solid var(--border2);
}
.qp-expl-label { font-weight: 600; margin-right: 6px; }

.qp-nav { display: flex; gap: 10px; justify-content: center; }
.qp-nav-btn {
  padding: 10px 24px; border: 1px solid var(--border2); border-radius: 8px;
  background: var(--surface2); color: var(--text-dim); font-size: 12px;
  cursor: pointer; font-family: inherit; transition: all .2s;
}
.qp-nav-btn:not(:disabled):hover { border-color: var(--a1); color: var(--text); transform: translateY(-1px); }
.qp-nav-btn:disabled { opacity: 0.25; cursor: default; }
.qp-finish-btn { background: var(--a1); color: #fff; border-color: var(--a1); font-weight: 500; }
.qp-finish-btn:hover { opacity: 0.9; }
.qp-next-btn { border-color: var(--a1); color: var(--a1); }

/* ─── Quiz Result ─── */
.qr-wrap { padding: 40px; max-width: 560px; margin: 0 auto; text-align: center; }
.qr-header { margin-bottom: 28px; }
.qr-topic { font-size: 12px; margin-bottom: 6px; letter-spacing: 0.04em; }
.qr-title { font-family: 'Cormorant Garamond', serif; font-size: 28px; font-style: italic; color: var(--text); }

.qr-score-ring { position: relative; width: 140px; height: 140px; margin: 0 auto 20px; }
.qr-ring-svg { width: 100%; height: 100%; }
.qr-score-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 32px; font-weight: 300; color: var(--text);
}
.qr-score-text span { font-size: 16px; color: var(--text-dim); }

.qr-stats { display: flex; justify-content: center; gap: 32px; margin-bottom: 28px; }
.qr-stat { font-size: 13px; color: var(--text-dim); }
.qr-stat span { font-size: 20px; font-weight: 500; margin-right: 4px; }

.qr-wrong-section { text-align: left; margin-bottom: 24px; }
.qr-wrong-title { font-size: 10px; color: var(--text-mute); letter-spacing: 0.08em; margin-bottom: 12px; text-transform: uppercase; }
.qr-wrong-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 8px; border-left: 3px solid var(--red);
}
.qr-wrong-q { font-size: 13px; color: var(--text); line-height: 1.6; margin-bottom: 6px; }
.qr-wrong-ans { font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.qr-wrong-expl { font-size: 11px; color: var(--text-mute); line-height: 1.6; }
.qr-perfect { font-size: 15px; color: var(--grn); margin-bottom: 24px; letter-spacing: 0.02em; }

.qr-actions { display: flex; gap: 12px; justify-content: center; }
.qr-btn {
  padding: 11px 28px; border: 1px solid var(--border2); border-radius: 8px;
  background: var(--surface2); color: var(--text-dim); font-size: 12px;
  cursor: pointer; font-family: inherit; transition: all .2s;
}
.qr-btn:hover { border-color: var(--text-mute); color: var(--text); transform: translateY(-1px); }
.qr-btn-primary { background: var(--a1); color: #fff; border-color: var(--a1); font-weight: 500; }
.qr-btn-primary:hover { opacity: 0.9; }

/* ─── Detail panel memo ─── */
.dm-input-wrap { position:relative; }
.dm-input {
  width:100%; background:var(--surface2); border:1px dashed var(--border2); border-radius:4px;
  padding:6px 10px; font-size:10px; color:var(--text); font-family:inherit;
  resize:none; min-height:28px; max-height:80px; line-height:1.5;
  transition:border-color .12s; overflow-y:auto; outline:none;
}
.dm-input::placeholder { color:var(--text-mute); }
.dm-input:focus { border-color:var(--a1); border-style:solid; }
.dm-divider-light { border:none; border-top:1px solid var(--border); margin:6px 0; }
.dm-list { display:flex; flex-direction:column; gap:2px; }
.dm-item {
  display:flex; align-items:center; gap:6px;
  padding:4px 8px; background:var(--surface2); border-radius:4px;
  cursor:pointer; transition:background .12s; position:relative;
}
.dm-item:hover { background:var(--surface3); }
.dm-text { flex:1; font-size:11px; color:var(--text); line-height:1.5; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dm-right { flex-shrink:0; }
.dm-meta { font-size:9px; color:var(--text-mute); }
.dm-actions { display:none; gap:2px; }
.dm-item:hover .dm-meta { display:none; }
.dm-item:hover .dm-actions { display:flex; }
.dm-action-btn {
  font-size:9px; color:var(--text-mute); cursor:pointer; padding:1px 4px; border-radius:3px;
  transition:color .12s, background .12s; border:none; background:none; font-family:inherit;
}
.dm-action-btn:hover { background:var(--surface3); }
.dm-edit-btn:hover { color:var(--a1); }
.dm-del-btn:hover { color:var(--red); }

/* Inline edit mode */
.dm-item.dm-editing { background:var(--surface3); border-radius:4px; padding:8px; flex-direction:column; align-items:stretch; }
.dm-edit-textarea {
  width:100%; background:var(--surface2); border:1px solid var(--border2); border-radius:4px;
  padding:6px 8px; font-size:11px; color:var(--text); font-family:inherit;
  resize:none; line-height:1.5; min-height:32px; outline:none;
}
.dm-edit-textarea:focus { border-color:var(--a1); }
.dm-edit-actions { display:flex; gap:6px; justify-content:flex-end; margin-top:4px; }
.dm-edit-cancel {
  font-size:10px; color:var(--text-mute); cursor:pointer; padding:3px 8px; border-radius:4px;
  border:1px solid var(--border); background:none; font-family:inherit;
}
.dm-edit-cancel:hover { color:var(--text-dim); border-color:var(--border2); }
.dm-edit-save {
  font-size:10px; color:var(--a1); cursor:pointer; padding:3px 10px; border-radius:4px;
  border:1px solid var(--a1); background:none; font-family:inherit;
}
.dm-edit-save:hover { background:var(--a1); color:#fff; }

/* ─── Bottom panel toggle ─── */
.bp-toggle-btn {
  font-size:10px; color:var(--text-mute); padding:3px 10px; cursor:pointer;
  border-bottom:2px solid transparent; transition:all .12s; font-family:inherit;
}
.bp-toggle-btn:hover { color:var(--text-dim); }
.bp-toggle-btn.active { color:var(--text); border-bottom-color:var(--a1); }

/* ─── Wrong/Starred Carousel in detail panel ─── */
.qw-carousel { margin-top: 8px; }
.qw-carousel-title { font-size: 10px; color: var(--text-mute); letter-spacing: 0.06em; margin-bottom: 6px; }
.qw-track { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-behavior: smooth; }
.qw-track::-webkit-scrollbar { height: 3px; }
.qw-track::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.qw-card {
  min-width: 220px; max-width: 260px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 11px;
}
.qw-card-q { color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.qw-card-ans { font-size: 10px; color: var(--text-dim); }
.qw-card-star { color: var(--yel); font-size: 9px; float: right; }
.qw-card-wrong { border-left: 2px solid var(--red); }
.qw-card-starred { border-left: 2px solid var(--yel); }
