@font-face { font-family: 'Faruma'; src: url('/fonts/Faruma.otf') format('opentype'); font-display: swap; }
@font-face { font-family: 'Noto Sans Thaana'; src: url('/fonts/NotoSansThaana-Regular.ttf') format('truetype'); font-display: swap; }

:root {
  --accent: #7c6cf0; --accent-2: #b3a8ff; --accent-soft: #efecff; --accent-ink: #4a3dbb;
  --bg: #f6f5fb; --card: #ffffff; --ink: #1f1d2b; --muted: #6f6c80; --line: #e8e6f1;
  --good: #22a06b; --warn: #e5a50a; --bad: #e5484d;
  --radius: 18px; --shadow: 0 1px 2px rgba(30,20,80,.05), 0 6px 20px rgba(30,20,80,.06);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --thaana: 'Faruma', 'Noto Sans Thaana', 'MV Boli', sans-serif;
}
body[data-theme="mint"]  { --accent:#1fa88a; --accent-2:#8fe0cb; --accent-soft:#e3f7f1; --accent-ink:#0f6e59; }
body[data-theme="peach"] { --accent:#f0795a; --accent-2:#ffc2ad; --accent-soft:#fff0ea; --accent-ink:#b4472c; }
body[data-theme="sky"]   { --accent:#3b8cf0; --accent-2:#a9cdfc; --accent-soft:#e8f2ff; --accent-ink:#1d5fb3; }
body[data-theme="rose"]  { --accent:#e2558f; --accent-2:#f8aecb; --accent-soft:#fdeaf2; --accent-ink:#a72e63; }
body[data-theme="ocean"] { --accent:#0f8b9c; --accent-2:#86d3dc; --accent-soft:#e1f5f7; --accent-ink:#0a5d69; }
body.dark {
  --bg: #15141c; --card: #1f1e29; --ink: #ecebf3; --muted: #a09db3; --line: #2f2d3c;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, #1f1e29); --accent-ink: var(--accent-2);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body.rtl { direction: rtl; }
body.rtl, .dv, [lang="dv"] { font-family: var(--thaana), var(--font); }
.dv, [lang="dv"] { direction: rtl; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-inline-end: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand .logo { width: 36px; height: 36px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-size: 20px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--accent-soft); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.nav .ico { width: 22px; text-align: center; font-size: 17px; }
.side .spacer { flex: 1; }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; text-decoration: none; color: var(--ink); }
.me-chip:hover { background: var(--accent-soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-size: 20px; flex: none; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.topbar .grow { flex: 1; min-width: 0; }
.page { padding: 4px 28px 100px; max-width: 1200px; }
.mobile-nav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: 14px 16px; }
  .page { padding: 4px 16px 110px; }
  h1 { font-size: 22px; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 10.5px; color: var(--muted); text-decoration: none; padding: 4px 0; font-weight: 600; }
  .mobile-nav a .ico { font-size: 19px; }
  .mobile-nav a.on { color: var(--accent-ink); }
}

/* ---------- components ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); }
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gauto { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.between { justify-content: space-between; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 12px; padding: 9px 15px; font-weight: 700; cursor: pointer; background: var(--accent); color: #fff; text-decoration: none; white-space: nowrap; font-size: 14px; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--accent-soft); color: var(--accent-ink); }
.btn.plain { background: transparent; color: var(--muted); padding: 7px 10px; }
.btn.plain:hover { background: var(--accent-soft); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; width: 34px; height: 34px; border-radius: 10px; color: var(--muted); font-size: 16px; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }

input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; color: var(--muted); }
.fields { display: grid; gap: 12px; }
.fields.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .fields.two { grid-template-columns: 1fr; } }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.pill.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: #a87700; }
.pill.bad  { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
body.dark .pill.warn { color: #f5c542; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 700; font-size: 13px; }
.switch input { display: none; }
.switch .track { width: 44px; height: 24px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch .lbl-off, .switch .lbl-on { color: var(--muted); transition: color .2s; }
.switch input:not(:checked) ~ .lbl-off-after, .switch .lbl-off.act, .switch .lbl-on.act { color: var(--ink); }
.switch .lbl-on { font-family: var(--thaana); font-size: 14px; }
body.rtl .switch .track { direction: ltr; }

.lang-switch { background: var(--card); border: 1px solid var(--line); padding: 6px 10px; border-radius: 99px; }

/* list items */
.item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); background: transparent; cursor: pointer; display: grid; place-items: center; flex: none; color: #fff; font-size: 13px; padding: 0; }
.check.on { background: var(--good); border-color: var(--good); }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* subjects */
.subj { position: relative; border-radius: var(--radius); padding: 18px; color: #fff; text-decoration: none; min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); overflow: hidden; }
.subj .em { font-size: 30px; }
.subj .nm { font-weight: 800; font-size: 17px; text-shadow: 0 1px 2px rgba(0,0,0,.15); }
.subj .meta { font-size: 12px; opacity: .92; font-weight: 600; }
.subj::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.14); right: -30px; top: -40px; }
.subj.add { background: var(--card); color: var(--muted); border: 2px dashed var(--line); box-shadow: none; align-items: center; justify-content: center; cursor: pointer; font-weight: 700; }
.subj.add::after { display: none; }
.subj.add:hover { border-color: var(--accent); color: var(--accent-ink); }
.sub-hero { border-radius: var(--radius); padding: 22px; color: #fff; display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.sub-hero .em { font-size: 42px; }

.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); padding: 4px; border-radius: 14px; overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.tabs button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--accent); color: #fff; }

/* dashboard */
.hello { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px; border-radius: 22px; color: #fff; background: linear-gradient(130deg, var(--accent), var(--accent-2)); margin-bottom: 16px; overflow: hidden; position: relative; }
.hello h1 { color: #fff; }
.hello .sub { opacity: .92; font-weight: 600; }
.hello .art { font-size: 56px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--accent-soft) 0); display: grid; place-items: center; flex: none; }
.ring > div { width: 72px; height: 72px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 800; font-size: 17px; }
.count { min-width: 64px; text-align: center; border-radius: 14px; padding: 6px 8px; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.count .n { font-size: 22px; font-weight: 800; line-height: 1.1; }
.count .u { font-size: 11px; font-weight: 700; }
.count.urgent { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }

/* timetable */
.tt { display: grid; gap: 10px; }
.tt-day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 140px; display: flex; flex-direction: column; gap: 8px; }
.tt-day.today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tt-day h3 { display: flex; justify-content: space-between; align-items: center; }
.slot { border-radius: 12px; padding: 8px 10px; color: #fff; cursor: pointer; font-size: 13px; }
.slot b { display: block; font-size: 14px; }
.slot.study { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.14) 0 8px, transparent 8px 16px); }
@media (max-width: 860px) { .tt { grid-template-columns: 1fr !important; } .tt-day { min-height: 0; } }

/* notebook */
.nb { display: grid; grid-template-columns: 250px 1fr; gap: 16px; }
@media (max-width: 860px) { .nb { grid-template-columns: 1fr; } }
.tree a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; }
.tree a:hover { background: var(--accent-soft); }
.tree a.on { background: var(--accent-soft); color: var(--accent-ink); }
.tree .sub { padding-inline-start: 22px; font-weight: 500; }
.note-card { display: block; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); border-top: 5px solid var(--c, var(--accent)); }
.note-card:hover { border-color: var(--accent-2); }
.note-card .ex { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; overflow-wrap: anywhere; }
.note-card .ex.dv { font-size: 15px; }

.editor-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; gap: 3px; padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 70px; background: var(--card); z-index: 3; align-items: center; }
.toolbar button { border: 0; background: transparent; min-width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-weight: 700; color: var(--ink); padding: 0 8px; }
.toolbar button:hover { background: var(--accent-soft); }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.toolbar .hl { width: 22px; height: 22px; min-width: 22px; border-radius: 50%; padding: 0; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); }
.note-title { border: 0 !important; box-shadow: none !important; font-size: 24px; font-weight: 800; padding: 18px 22px 6px !important; background: transparent !important; }
.editor { min-height: 55vh; padding: 10px 22px 40px; outline: none; font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.editor.dv, .note-title.dv { font-size: 18px; line-height: 1.9; }
.editor img { max-width: 100%; border-radius: 12px; margin: 8px 0; display: block; }
.editor h1 { font-size: 26px; margin: 16px 0 6px; }
.editor h2 { font-size: 21px; margin: 14px 0 6px; color: var(--accent-ink); }
.editor h3 { font-size: 17px; margin: 12px 0 4px; }
.editor blockquote { border-inline-start: 4px solid var(--accent); margin: 8px 0; padding: 6px 14px; background: var(--accent-soft); border-radius: 8px; }
.editor:empty::before { content: attr(data-ph); color: var(--muted); }
body.dark .editor mark, body.dark .editor [style*="background-color"] { color: #1f1d2b; }

/* files */
.file { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.file .fi { width: 46px; height: 54px; border-radius: 10px; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); flex: none; overflow: hidden; }
.file .fi img { width: 100%; height: 100%; object-fit: cover; }
.file .grow { flex: 1; min-width: 0; }
.file .nm { font-weight: 700; overflow-wrap: anywhere; }
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* scan */
.scan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .scan-grid { grid-template-columns: 1fr; } }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 92px; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.scan-text { min-height: 320px; font-size: 15px; line-height: 1.7; }
.scan-text.dv { font-size: 17px; }

/* flashcards */
.flash { perspective: 1200px; height: 280px; cursor: pointer; max-width: 560px; margin: 0 auto; }
.flash .in { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flash.flip .in { transform: rotateY(180deg); }
.flash .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 22px; display: grid; place-items: center; padding: 28px; text-align: center; font-size: 21px; font-weight: 700; box-shadow: var(--shadow); overflow-wrap: anywhere; overflow: auto; }
.flash .front { background: var(--card); border: 1px solid var(--line); }
.flash .back { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; transform: rotateY(180deg); }
.flash .tag { position: absolute; top: 14px; left: 18px; font-size: 12px; opacity: .7; font-weight: 700; }

/* timer */
.timer { font-size: 54px; font-weight: 800; text-align: center; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,15,40,.45); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--card); border-radius: 22px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1000px, 100%); }
.modal.full { width: min(1200px, 100%); height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; gap: 10px; }
.modal-b { padding: 8px 20px 20px; }
.modal.full .modal-b { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
.viewer { flex: 1; width: 100%; border: 0; border-radius: 12px; background: #fff; min-height: 300px; }
.viewer-img { max-width: 100%; margin: 0 auto; display: block; border-radius: 12px; }

#toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: #1f1d2b; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: fade .2s; max-width: 90vw; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .art { background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth .art h1 { font-size: 44px; color: #fff; }
.auth .art ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; font-weight: 600; font-size: 16px; }
.auth .form { display: grid; place-items: center; padding: 32px 16px; }
.auth .box { width: min(400px, 100%); }
.err { color: var(--bad); font-weight: 600; font-size: 14px; min-height: 20px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth .art { padding: 28px 20px; } .auth .art h1 { font-size: 32px; } .auth .art ul { display: none; } }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0; font-size: 18px; background: var(--card); }
.swatch.on { box-shadow: 0 0 0 3px var(--accent); }
.progress { height: 8px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.kbd-hint { font-size: 12px; color: var(--muted); padding: 4px 10px; }
.search-hit mark { background: #ffe680; color: #1f1d2b; border-radius: 3px; }

@media (max-width: 600px) { .topbar .btn > span { display: none; } .topbar .btn { padding: 9px 11px; } }
@media print {
  .side, .topbar, .mobile-nav, #toast, .modal-bg, .btn, .icon-btn { display: none !important; }
  .shell { display: block; } .page { padding: 0; } body { background: #fff; } .card { box-shadow: none; break-inside: avoid; }
}

/* timetable grid (days across, numbered periods down) */
.ttg-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.ttg { display: grid; gap: 4px; }
.ttg-day { text-align: center; font-size: 26px; font-weight: 500; padding: 6px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ttg-day.today { color: var(--accent-ink); font-weight: 800; }
.ttg-p { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 92px; }
.ttg-p b { font-size: 26px; font-weight: 500; line-height: 1.1; }
.ttg-p span { font-size: 13px; color: var(--ink); white-space: nowrap; }
.ttg-slot { display: flex; flex-direction: column; gap: 3px; }
.ttg-c { flex: 1; min-height: 92px; border-radius: 6px; background: #c9c9cc; color: #111; padding: 6px 7px 5px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.05); overflow: hidden; }
.ttg-c b { font-size: 30px; font-weight: 500; text-align: center; line-height: 1.15; margin-top: 8px; overflow-wrap: anywhere; }
.ttg-c b.dv { font-size: 18px; }
.ttg-c span { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttg-c:hover { filter: brightness(.95); }
.ttg-c.empty { background: transparent; box-shadow: inset 0 0 0 1px var(--line); border-radius: 0; }
.ttg-c.empty:hover { background: var(--accent-soft); }
.ttg-c.study { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 8px, transparent 8px 16px); }
.ttg-c.now { box-shadow: 0 0 0 3px var(--accent); }
body.dark .ttg-c:not(.empty) { background: #4a4958; color: #f1f0f7; }
@media (max-width: 700px) {
  .ttg-wrap { padding: 4px; margin: 0 -8px; }
  .ttg { gap: 3px; }
  .ttg-day { font-size: 20px; }
  .ttg-p { min-height: 70px; }
  .ttg-p b { font-size: 20px; }
  .ttg-p span { font-size: 10px; }
  .ttg-c { min-height: 70px; padding: 4px; }
  .ttg-c b { font-size: 20px; margin-top: 4px; }
  .ttg-c span { font-size: 11px; }
}

/* ---------- presentations & posters ---------- */
.cpage { position: relative; overflow: hidden; flex: none; }
.cpage ul { margin: 0; padding-inline-start: 1.15em; }
.cpage li { margin: .25em 0; }
.cpage li::marker { color: currentColor; }
.cmini { overflow: hidden; flex: none; pointer-events: none; border-radius: 6px; }
.cel { position: absolute; }
.cel .tx { width: 100%; min-height: inherit; outline: none; overflow-wrap: anywhere; white-space: pre-wrap; }
.cel .tx ul { white-space: normal; }
.ed-stage-wrap .cel { cursor: move; touch-action: none; }
.ed-stage-wrap .cel .tx[contenteditable=true] { cursor: text; background: rgba(255,255,255,.08); }
.ed-stage-wrap .cel:hover { outline: 2px dashed rgba(124,108,240,.6); outline-offset: 2px; }
.ed-stage-wrap .cel.sel { outline: 3px solid #7c6cf0; outline-offset: 2px; }
.cel .h { position: absolute; width: 22px; height: 22px; background: #fff; border: 3px solid #7c6cf0; border-radius: 50%; display: none; z-index: 5; }
.cel.sel .h { display: block; }
.cel .h.se { right: -11px; bottom: -11px; cursor: nwse-resize; }
.cel .h.e { right: -11px; top: calc(50% - 11px); cursor: ew-resize; }
.cel .h.s { bottom: -11px; left: calc(50% - 11px); cursor: ns-resize; }
.img-ph { width: 100%; height: 100%; border: 4px dashed rgba(127,127,127,.55); background: rgba(127,127,127,.12); display: flex; flex-direction: column; align-items: center; justify-content: center; color: rgba(90,90,90,.9); font: 600 26px var(--font); gap: 6px; }
.img-ph div { font-size: 64px; }
.ed-top { margin-bottom: 8px; }
.ed-tools .ed-bar { position: static; border: 1px solid var(--line); border-radius: 14px; gap: 4px; }
.ed-bar .tb { border: 0; background: transparent; min-width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-weight: 700; color: var(--ink); padding: 0 9px; white-space: nowrap; }
.ed-bar .tb:hover, .ed-bar .tb.on { background: var(--accent-soft); color: var(--accent-ink); }
.ed-bar select, .ed-bar input[type=number] { padding: 6px 8px; border-radius: 9px; height: 34px; }
.ed-bar input[type=color] { width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; }
.cdot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; flex: none; }
.cdot.on { box-shadow: 0 0 0 2px var(--accent); }
.ed { display: grid; grid-template-columns: 180px 1fr; gap: 14px; align-items: start; }
.ed.poster { grid-template-columns: 1fr; }
.ed-thumbs { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 240px); overflow-y: auto; padding: 4px; position: sticky; top: 80px; }
.ed-thumb { position: relative; border-radius: 8px; cursor: pointer; padding: 3px; border: 2px solid transparent; }
.ed-thumb.on { border-color: var(--accent); }
.ed-thumb .n { position: absolute; left: -2px; top: -2px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; font-weight: 800; padding: 0 5px; z-index: 2; }
.ed-stage-wrap { min-width: 0; }
#edStage { margin: 0 auto; box-shadow: 0 10px 40px rgba(20,10,60,.18); border-radius: 4px; overflow: visible; }
.ed.poster #edStage { margin: 0 auto; }
@media (max-width: 860px) {
  .ed { grid-template-columns: 1fr; }
  .ed-thumbs { flex-direction: row; max-height: none; overflow-x: auto; position: static; order: 2; }
  .ed-thumb { flex: none; }
  .ed-thumbs .btn { width: auto !important; flex: none; }
}
.tpl-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.tpl-opt { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 12px; color: var(--ink); }
.tpl-opt.on, .tpl-opt:hover { border-color: var(--accent); }
.tpl-opt.add { justify-content: center; min-width: 120px; min-height: 100px; color: var(--muted); border-style: dashed; }
.dd { position: relative; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 30; min-width: 210px; display: flex; flex-direction: column; }
.dd-menu.hidden { display: none; }
.dd-menu button { border: 0; background: transparent; text-align: start; padding: 10px 12px; border-radius: 10px; font-weight: 600; cursor: pointer; color: var(--ink); }
.dd-menu button:hover { background: var(--accent-soft); }
.present { position: fixed; inset: 0; background: #000; z-index: 100; display: grid; place-items: center; cursor: pointer; }
.present-bar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; background: rgba(0,0,0,.55); color: #fff; border-radius: 99px; padding: 6px 10px; opacity: .25; transition: opacity .2s; font-weight: 700; }
.present-bar:hover { opacity: 1; }
.present-bar button { background: transparent; border: 0; color: #fff; font-size: 20px; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.present-bar button:hover { background: rgba(255,255,255,.15); }

/* ---------- Ask AI ---------- */
.chat { display: grid; grid-template-columns: 260px 1fr; gap: 16px; height: calc(100vh - 120px); min-height: 480px; }
.chat-list { overflow-y: auto; }
.chat-row { display: flex; flex-direction: column; padding: 9px 10px; border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px; }
.chat-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row:hover, .chat-row.on { background: var(--accent-soft); }
.chat-main { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.chat-head { padding: 10px 12px; border-bottom: 1px solid var(--line); gap: 8px; }
.chat-back { display: none; text-decoration: none; }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-hello { text-align: center; margin: auto; max-width: 560px; padding: 20px 0; }
.chat-hello h2 { margin: 8px 0 4px; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg.me { justify-content: flex-end; }
.msg .b { padding: 11px 15px; border-radius: 18px; max-width: min(720px, 85%); overflow-wrap: anywhere; line-height: 1.6; }
.msg.me .b { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.ai .b { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg .av { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; flex: none; font-size: 18px; }
.msg-imgs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.msg-imgs img { width: 140px; max-height: 180px; object-fit: cover; border-radius: 12px; cursor: zoom-in; border: 2px solid rgba(255,255,255,.4); }
.md p { margin: 0 0 .6em; } .md p:last-of-type { margin-bottom: 0; }
.md h2, .md h3, .md h4 { margin: .7em 0 .35em; font-size: 16px; } .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md ul, .md ol { margin: .3em 0 .7em; padding-inline-start: 1.3em; }
.md li { margin: .2em 0; }
.md code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.md pre { background: #1f1d2b; color: #f1f0f7; padding: 12px; border-radius: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; color: inherit; }
.md .dv, .msg .b.dv { font-size: 17px; }
.msg-tools { display: flex; gap: 2px; margin: 8px -8px -6px; opacity: .7; }
.msg-tools:hover { opacity: 1; }
.chat-compose { border-top: 1px solid var(--line); padding: 10px 12px; }
.chat-compose textarea { min-height: 44px; max-height: 180px; resize: none; flex: 1; }
.chat-compose .thumbs img { width: 70px; height: 70px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: bounce 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.caret { display: inline-block; width: 8px; height: 1em; background: var(--accent); vertical-align: text-bottom; animation: blink 1s steps(2) infinite; margin-inline-start: 2px; }
@keyframes blink { 50% { opacity: 0; } }
@media (max-width: 860px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 190px); }
  .chat .chat-list { display: none; }
  .chat.list-mode .chat-list { display: block; }
  .chat.list-mode .chat-main { display: none; }
  .chat-back { display: inline-grid; }
  .msg .b { max-width: 88%; }
}

/* prize themes (won in Study Quest) */
body[data-theme="gold"]   { --accent:#d4a017; --accent-2:#f6d365; --accent-soft:#fdf5dc; --accent-ink:#8a6508; }
body[data-theme="galaxy"] { --accent:#6d3fe0; --accent-2:#e86fd2; --accent-soft:#efe8ff; --accent-ink:#4a23a8; }
body[data-theme="coral"]  { --accent:#ff6f61; --accent-2:#4fd1c5; --accent-soft:#ffeceb; --accent-ink:#c2453a; }
body[data-theme="forest"] { --accent:#2f8f4e; --accent-2:#a3d977; --accent-soft:#e6f4ea; --accent-ink:#1e6436; }

/* ---------- Study Quest ---------- */
.qstats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin-bottom: 14px; }
.qstat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); }
.qstat .qi { font-size: 28px; }
.qstat b { font-size: 18px; }
@media (max-width: 700px) { .qstats { grid-template-columns: 1fr 1fr; } }
.qcard { border-top: 5px solid var(--accent); }
.qcard.completed { border-top-color: var(--good); }
.qweek { display: flex; gap: 6px; }
.qday { flex: 1; text-align: center; border-radius: 10px; padding: 6px 0; background: var(--bg); border: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.qday span { display: block; color: var(--muted); font-size: 12px; }
.qday b { display: block; height: 18px; }
.qday.done { background: var(--accent); color: #fff; border-color: var(--accent); }
.qday.done span { color: rgba(255,255,255,.85); }
.qday.today { box-shadow: 0 0 0 2px var(--accent); }
.qmap { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 18px 4px 6px; }
.qnode { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 74px; cursor: pointer; }
.qnode span { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--bg); border: 3px solid var(--line); font-size: 16px; }
.qnode em { font-style: normal; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.qnode.done span { background: var(--good); border-color: var(--good); color: #fff; }
.qnode.now span { background: var(--accent); border-color: var(--accent); color: #fff; animation: pulse 1.6s infinite; }
.qnode.wait span { border-color: var(--accent); color: var(--accent-ink); }
.qnode.locked { cursor: default; opacity: .6; }
.qnode.boss span { width: 56px; height: 56px; font-size: 28px; }
.qnode.boss.now span { background: var(--bad); border-color: var(--bad); }
.qpath { flex: 1 0 18px; height: 4px; background: var(--line); border-radius: 4px; margin-bottom: 22px; min-width: 18px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
.qsteps { display: flex; gap: 6px; margin: 10px 0 14px; flex-wrap: wrap; }
.qsteps span { padding: 5px 12px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--muted); }
.qsteps span.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.qsteps span.ok { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); border-color: transparent; }
.qlesson { font-size: 16px; line-height: 1.7; }
.qlesson.dv, .qlesson[dir=rtl] { font-size: 18px; }
.qkeys { background: var(--accent-soft); border-radius: 14px; padding: 12px 16px; margin-top: 12px; }
.qkeys ul { margin: 6px 0 0; padding-inline-start: 1.2em; }
.qq { border: 1.5px solid var(--line); border-radius: 14px; padding: 12px; }
.qq.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 6%, transparent); }
.qq.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 5%, transparent); }
.qfb { margin-top: 8px; }
.qfb:empty { display: none; }
.qopt { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer; font-weight: 600; }
.qopt:hover { border-color: var(--accent-2); }
.qopt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.qboss { border: 2px solid color-mix(in srgb, var(--bad) 50%, transparent); }
.lvl { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; color: var(--ink); }
.lvl.on { border-color: var(--accent); background: var(--accent-soft); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.badge { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 8px; text-align: center; display: flex; flex-direction: column; gap: 2px; opacity: .55; }
.badge.got { opacity: 1; border-color: var(--accent-2); box-shadow: var(--shadow); }
.badge .bi { font-size: 38px; }
.badge span { font-size: 11px; color: var(--muted); }
.badge.trophy { background: linear-gradient(160deg, #fff7d6, var(--card)); }
body.dark .badge.trophy { background: linear-gradient(160deg, #3a3216, var(--card)); }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -30px; font-style: normal; font-size: 22px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(420px) rotate(260deg); opacity: 0; } }
.modal { position: relative; }
.newbadge { margin: 10px auto; padding: 12px; border-radius: 16px; background: var(--accent-soft); max-width: 260px; }
.mystery { margin: 14px auto 0; cursor: pointer; }
.mystery .box { font-size: 64px; display: inline-block; animation: wiggle 1.2s infinite; }
.mystery .box.open { animation: pop .5s forwards; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes pop { to { transform: scale(1.6); opacity: 0; } }
.spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; display: inline-block; animation: rot .8s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }

.pw { position: relative; display: block; }
.pw input { padding-inline-end: 44px; }
.pw .icon-btn { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); }
.codein { font-size: 28px !important; letter-spacing: 10px; text-align: center; font-weight: 800; }
