/* สมุดเรนะ — one design system for the library, the editor, the panels and the sign-in page. */
:root {
  --accent: #10b155;
  --accent-ink: #0a7a3a;
  --accent-soft: #e4f6eb;
  --accent-glow: rgba(16, 177, 85, .28);
  --ink: #15181d;
  --ink-2: #3b4049;
  --muted: #747b86;
  --line: #e4e6ea;
  --line-2: #eff1f4;
  --bg: #f2f3f5;
  --panel: #ffffff;
  --chrome: rgba(255, 255, 255, .88);
  --danger: #d9473f;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 10px 28px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-3: 0 24px 60px rgba(16, 24, 40, .22);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Sukhumvit Set", "Noto Sans Thai UI", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  font-family: var(--font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
.ic { display: block; flex: none; }
#app { height: 100%; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes slide-in-left { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes slide-in-right { from { transform: translateX(100%); } to { transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .45); } 50% { box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- small shared pieces ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(26px + var(--safe-bottom)); transform: translate(-50%, 16px);
  background: rgba(21, 24, 29, .94); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14.5px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: min(92vw, 520px); text-align: center;
  box-shadow: var(--shadow-2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 18px; border-radius: 999px; font-weight: 600; font-size: 15px; transition: transform .12s, box-shadow .2s, background .2s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px var(--accent-glow); }
.btn.primary:hover { background: #0e9f4c; }
.btn.ghost { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { height: 34px; padding: 0 14px; font-size: 14px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--ink-2); transition: background .15s; }
.icon-btn:hover { background: rgba(20, 25, 35, .06); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent-ink); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(0, 0, 0, .12); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 999px; background: var(--line-2); font-size: 13.5px; color: var(--ink-2); transition: background .15s; }
.chip:hover { background: #e6e9ed; }
.chip.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.kbd { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---------- library ---------- */
.lib { display: flex; height: 100%; padding-top: var(--safe-top); background: linear-gradient(180deg, #f6f7f9 0%, #eef0f3 100%); }
.side {
  width: 268px; flex: none; margin: 14px 0 14px 14px; padding: 16px 12px 12px; border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: var(--shadow-1), 0 12px 32px rgba(16, 24, 40, .06); display: flex; flex-direction: column; gap: 2px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 14px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; box-shadow: var(--shadow-1); }
.brand b { display: block; font-size: 17px; }
.brand small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.searchbox { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; margin: 2px 2px 10px; border-radius: 12px; background: var(--line-2); color: var(--muted); }
.searchbox input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 15px; color: var(--ink); }
.sect-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; padding: 14px 12px 6px; }
.nav { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 12px; font-size: 15.5px; text-align: left; color: var(--ink-2); transition: background .15s; }
.nav:hover { background: rgba(20, 25, 35, .05); }
.nav.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.nav .count { margin-left: auto; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.nav.on .count { color: var(--accent-ink); }
.nav .fdot { width: 20px; height: 16px; border-radius: 4px 6px 6px 6px; flex: none; position: relative; }
.side .folders { overflow-y: auto; min-height: 0; flex: 1; }
.whoami { margin-top: 8px; padding: 12px; border-radius: var(--r); background: var(--line-2); display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.whoami .t { flex: 1; min-width: 0; line-height: 1.35; }
.whoami .t b { display: block; font-size: 13.5px; color: var(--ink); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.head { display: flex; align-items: center; gap: 10px; padding: 24px 30px 4px; }
.head h1 { margin: 0; font-size: 30px; font-weight: 750; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; padding: 0 30px; min-height: 22px; flex-wrap: wrap; }
.crumb button { color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.crumb button:hover { color: var(--ink); background: rgba(0, 0, 0, .04); }
.tools { display: flex; align-items: center; gap: 6px; }
.grid {
  flex: 1; overflow-y: auto; padding: 22px 30px calc(48px + var(--safe-bottom));
  display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 30px 22px; align-content: start;
}
.grid.list { grid-template-columns: 1fr; gap: 6px; }
.card { display: flex; flex-direction: column; align-items: center; gap: 9px; position: relative; animation: rise-in .28s ease-out both; }
.card .open { display: block; border-radius: 6px 12px 12px 6px; transition: transform .18s ease, filter .18s; }
.card .open:hover { transform: translateY(-4px); }
.card .open:active { transform: translateY(-1px) scale(.985); }
/* notebook covers: colour, a printed pattern, a spine, a label plate */
.cover {
  width: 136px; height: 178px; border-radius: 5px 12px 12px 5px; position: relative; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 10px 22px rgba(20, 30, 50, .18), inset 0 0 0 1px rgba(255, 255, 255, .08);
  background-color: var(--c);
}
.cover::before { content: ""; position: absolute; inset: 0; background: var(--pattern, none); }
.mobile-search { display: none; }
.cover::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, .26) 0, rgba(0, 0, 0, .1) 7px, rgba(255, 255, 255, .12) 9px, rgba(255, 255, 255, 0) 16px),
              linear-gradient(160deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, .08));
}
.cover .plate {
  position: absolute; left: 22px; right: 12px; top: 28px; z-index: 1; background: rgba(255, 255, 255, .94); border-radius: 7px;
  padding: 7px 9px; font-size: 12.5px; font-weight: 650; color: #23262b; line-height: 1.35; max-height: 58px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.cover .stitch { position: absolute; left: 12px; top: 10px; bottom: 10px; border-left: 1.5px dashed rgba(255, 255, 255, .35); z-index: 1; }
/* first-page thumbnail, with sheets behind it when the notebook has more pages */
.sheet { width: 136px; height: 178px; position: relative; }
.sheet .pg { position: absolute; inset: 0; z-index: 1; border-radius: 4px; background: #fff; overflow: hidden; box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 8px 18px rgba(20, 30, 50, .14); }
.sheet .pg img, .sheet .pg canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet.stack::before, .sheet.stack::after { content: ""; position: absolute; inset: 0; background: #fff; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.sheet.stack::before { transform: translate(6px, -5px) rotate(2deg); opacity: .7; }
.sheet.stack::after { transform: translate(3px, -2.5px) rotate(1deg); opacity: .9; }
.badge-star { position: absolute; top: 8px; right: 8px; z-index: 2; color: #ffc61a; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .35)); }
.folder { width: 160px; height: 126px; position: relative; margin-top: 46px; }
.folder svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 8px 14px rgba(20, 30, 50, .16)); overflow: visible; }
.card .title { display: flex; align-items: flex-start; gap: 2px; max-width: 168px; }
.card .name { font-weight: 650; font-size: 15px; text-align: center; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.card .menu-btn { width: 24px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); flex: none; margin-top: -1px; }
.card .menu-btn:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
.card .meta { color: var(--muted); font-size: 12.5px; margin-top: -5px; text-align: center; }
/* list view */
.grid.list .card { flex-direction: row; align-items: center; gap: 14px; padding: 8px 12px; border-radius: var(--r); background: var(--panel); box-shadow: var(--shadow-1); }
.grid.list .card .open { flex: none; }
.grid.list .cover, .grid.list .sheet { width: 40px; height: 52px; }
.grid.list .cover .plate, .grid.list .cover .stitch, .grid.list .badge-star { display: none; }
.grid.list .folder { width: 44px; height: 36px; margin: 0; }
.grid.list .card .title { max-width: none; flex: 1; align-items: center; }
.grid.list .card .name { text-align: left; -webkit-line-clamp: 1; flex: 1; }
.grid.list .card .meta { margin: 0; min-width: 150px; text-align: right; }
.grid.list .card .open:hover { transform: none; }
.empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--muted); padding: 56px 20px; font-size: 15px; line-height: 1.7; gap: 6px; }
.empty b { color: var(--ink); font-size: 18px; }
.empty .row { display: flex; gap: 10px; margin-top: 14px; }

/* ---------- menus, sheets and dialogs ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; }
.scrim.dim { background: rgba(18, 22, 30, .38); display: grid; place-items: center; padding: 20px; animation: fade-in .18s; backdrop-filter: blur(2px); }
.pop {
  position: fixed; z-index: 61; min-width: 232px; max-width: 320px; background: var(--panel); border-radius: 16px; padding: 6px;
  box-shadow: var(--shadow-3), 0 0 0 1px rgba(0, 0, 0, .04); animation: pop-in .16s ease-out; transform-origin: top right;
}
.pop .row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 10px; font-size: 15px; text-align: left; color: var(--ink-2); }
.pop .row:hover { background: var(--line-2); color: var(--ink); }
.pop .row.danger { color: var(--danger); }
.pop .row .sub { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.pop .sep { height: 1px; background: var(--line); margin: 5px 8px; }
.pop .hd { font-size: 12px; font-weight: 700; color: var(--muted); padding: 8px 12px 4px; letter-spacing: .03em; }
.pop .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; }
.pop .tile { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 16px 6px 13px; background: var(--line-2); border-radius: 13px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: background .15s, transform .12s; }
.pop .tile:hover { background: #e7eaee; }
.pop .tile:active { transform: scale(.97); }
.pop .tile .ic { color: var(--accent-ink); }
.dialog { background: #f7f8fa; border-radius: 24px; width: min(900px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-3); animation: rise-in .22s ease-out; }
.dialog.small { width: min(430px, 100%); }
.dhead { display: flex; align-items: center; padding: 14px; gap: 8px; }
.dhead h2 { flex: 1; text-align: center; margin: 0; font-size: 17px; font-weight: 700; }
.round { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); box-shadow: var(--shadow-1); flex: none; }
.round.ok { background: var(--accent); color: #fff; box-shadow: 0 6px 16px var(--accent-glow); }
.dbody { overflow-y: auto; padding: 4px 22px 24px; }
.form { background: var(--panel); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1); }
.form .f { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line-2); min-height: 52px; }
.form .f:last-child { border: 0; }
.form .f > label { width: 78px; font-weight: 650; flex: none; font-size: 14.5px; }
.form .f input[type=text], .form .f input[type=password] { flex: 1; border: 0; outline: 0; font-size: 16px; background: none; min-width: 0; }
.form select { flex: 1; border: 0; font-size: 15px; background: none; text-align: right; outline: 0; }
.sw { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
.dot { width: 28px; height: 28px; border-radius: 50%; position: relative; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .12s; flex: none; }
.dot:hover { transform: scale(1.08); }
.dot.on::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2.5px solid var(--accent); }
.dot.pat { background-size: 10px 10px; }
.toggle { width: 50px; height: 30px; border-radius: 99px; background: #d4d8de; position: relative; transition: .2s; flex: none; margin-left: auto; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: .2s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 23px; }
.seg { display: inline-flex; background: var(--line-2); border-radius: 11px; padding: 3px; gap: 2px; margin-left: auto; }
.seg button { height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13.5px; color: var(--ink-2); }
.seg button.on { background: var(--panel); box-shadow: var(--shadow-1); color: var(--ink); font-weight: 650; }
.newnb { display: grid; grid-template-columns: 290px 1fr; gap: 22px; align-items: start; }
.newnb .prev { display: flex; gap: 16px; justify-content: center; align-items: flex-end; padding: 18px 8px 8px; }
.newnb .pv { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.newnb .pv .cover, .newnb .pv .sheet { width: 120px; height: 158px; }
.sect { font-weight: 750; font-size: 17px; margin: 24px 2px 12px; }
.papers { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.paper { display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 13.5px; padding: 10px 4px 9px; border-radius: 14px; transition: background .15s; }
.paper:hover { background: rgba(0, 0, 0, .03); }
.paper.on { background: var(--accent-soft); font-weight: 650; color: var(--accent-ink); }
.paper canvas { border-radius: 3px; box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 4px 10px rgba(20, 30, 50, .1); }
.paper .dots { display: flex; gap: 7px; }
.paper .dots span { width: 15px; height: 15px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .16); position: relative; }
.paper .dots span.on::after { content: ""; position: absolute; inset: -3.5px; border-radius: 50%; border: 2px solid var(--accent); }
.tree .row { padding-left: calc(12px + var(--depth, 0) * 18px); }
.tree .row.on { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- sign-in ---------- */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #e6f7ed 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #eaf0ff 0, transparent 55%), var(--bg); overflow-y: auto; }
.gate .card2 { width: min(820px, 100%); background: var(--panel); border-radius: 28px; box-shadow: var(--shadow-3); display: grid; grid-template-columns: 1fr 300px; overflow: hidden; animation: rise-in .3s ease-out; }
.gate .info { padding: 34px 34px 28px; display: flex; flex-direction: column; gap: 14px; }
.gate .info .brand { padding: 0; }
.gate h1 { margin: 6px 0 0; font-size: 26px; letter-spacing: -.01em; }
.gate p { margin: 0; color: var(--muted); line-height: 1.65; font-size: 15px; }
.gate ol { margin: 4px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; counter-reset: s; }
.gate li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.5; color: var(--ink-2); counter-increment: s; }
.gate li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; flex: none; font-size: 13.5px; }
.gate .qrside { background: linear-gradient(180deg, #f7faf8, #eef3f0); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 28px 20px; border-left: 1px solid var(--line-2); }
.gate .qrbox { background: #fff; padding: 10px; border-radius: 18px; box-shadow: var(--shadow-2); position: relative; }
.gate .qrbox.dim canvas { filter: blur(3px); opacity: .35; }
.gate .qrbox .over { position: absolute; inset: 0; display: grid; place-items: center; }
.gate .code { font-size: 30px; font-weight: 750; letter-spacing: .14em; font-variant-numeric: tabular-nums; color: var(--ink); }
.gate .timer { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.gate .status { font-size: 14px; color: var(--accent-ink); font-weight: 600; display: flex; align-items: center; gap: 8px; min-height: 22px; }
.gate .alt { margin-top: auto; font-size: 13.5px; color: var(--muted); }
.gate .alt button { color: var(--accent-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.gate .tokenrow { display: flex; gap: 8px; }
.gate .tokenrow[hidden] { display: none; }
.gate .tokenrow input { flex: 1; height: 40px; border-radius: 12px; border: 1px solid var(--line); padding: 0 12px; font-size: 15px; outline: 0; }

/* ---------- editor ---------- */
.ed { display: flex; flex-direction: column; height: 100%; background: #e9ebee; }
.ed .top {
  background: var(--chrome); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  padding-top: var(--safe-top); flex: none; z-index: 10; box-shadow: 0 1px 0 rgba(16, 24, 40, .08), 0 4px 16px rgba(16, 24, 40, .05);
}
.ed .bar { display: flex; align-items: center; gap: 4px; padding: 7px 10px; min-height: 58px; }
.ed .grp { display: flex; align-items: center; gap: 2px; }
.ed .grp.mid { flex: 1; justify-content: center; }
.ed .doc { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 30vw; }
.ed .doc .tt { min-width: 0; text-align: left; padding: 3px 8px; border-radius: 9px; }
.ed .doc .tt:hover { background: rgba(0, 0, 0, .05); }
.ed .doc b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed .doc small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; }
.vsep { width: 1px; height: 26px; background: var(--line); margin: 0 6px; flex: none; }
.tb { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: var(--ink-2); position: relative; transition: background .15s, color .15s, transform .1s; flex: none; }
.tb:hover { background: rgba(20, 25, 35, .06); }
.tb:active { transform: scale(.94); }
.tb.on { background: var(--accent-soft); color: var(--accent-ink); }
.tb:disabled { opacity: .32; }
.tb .ink { position: absolute; left: 50%; bottom: 5px; width: 16px; height: 3.5px; border-radius: 2px; transform: translateX(-50%); box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .15); }
.sub {
  position: absolute; left: 50%; transform: translateX(-50%); top: 10px; z-index: 9; display: flex; align-items: center; gap: 3px;
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(12px); border-radius: 18px; padding: 6px 8px; box-shadow: var(--shadow-2), 0 0 0 1px rgba(0, 0, 0, .03);
  max-width: calc(100% - 20px); overflow-x: auto; scrollbar-width: none; animation: pop-in .16s ease-out;
}
.sub::-webkit-scrollbar { display: none; }
.sub:empty { display: none; }
.sub .o { min-width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; padding: 0 6px; color: var(--ink-2); flex: none; }
.sub .o:hover { background: var(--line-2); }
.sub .o.on { background: var(--accent-soft); color: var(--accent-ink); }
.sub .o.txt { padding: 0 12px; font-size: 14px; display: flex; gap: 7px; white-space: nowrap; }
.sub .vs { width: 1px; height: 26px; background: var(--line); margin: 0 5px; flex: none; }
.sub .c { width: 30px; height: 30px; border-radius: 50%; margin: 0 2px; flex: none; position: relative; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); transition: transform .12s; }
.sub .c:hover { transform: scale(1.08); }
.sub .c.on::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2.5px solid var(--accent); }
.sub .w { width: 42px; height: 40px; display: grid; place-items: center; border-radius: 11px; flex: none; }
.sub .w:hover { background: var(--line-2); }
.sub .w.on { background: var(--accent-soft); }
.sub .w i { display: block; width: 22px; border-radius: 4px; background: var(--ink-2); }
.sub .t { width: 44px; height: 30px; border-radius: 5px; flex: none; margin: 0 2px; position: relative; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.sub .t.on::after { content: ""; position: absolute; inset: -4px; border-radius: 8px; border: 2.5px solid var(--accent); }
.sub label.cpick { width: 30px; height: 30px; border-radius: 50%; flex: none; margin: 0 2px; position: relative; overflow: hidden; cursor: pointer;
  background: conic-gradient(#f44, #fd4, #4d4, #4dd, #44f, #d4d, #f44); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); }
.sub label.cpick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.stage { position: relative; flex: 1; min-height: 0; }
.scroller { position: absolute; inset: 0; overflow: auto; scrollbar-gutter: stable; touch-action: none; -webkit-user-select: none; user-select: none; }
.pages { position: relative; margin: 0 auto; padding: 76px 0 140px; transform-origin: 0 0; min-width: 100%; }
.page { position: relative; margin: 0 auto 28px; background: #fff; border-radius: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 10px 30px rgba(20, 30, 50, .11); }
.page canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.page textarea {
  position: absolute; z-index: 3; border: 1.5px dashed var(--accent); background: rgba(255, 255, 255, .55); outline: 0; resize: none; border-radius: 4px;
  padding: 0; margin: 0; line-height: 1.45; overflow: hidden; transform-origin: 0 0; white-space: pre-wrap; word-break: break-all; font-family: var(--font);
}
.pill-float {
  position: absolute; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); z-index: 8; pointer-events: none;
  background: rgba(21, 24, 29, .82); color: #fff; font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 99px;
  opacity: 0; transition: opacity .3s; font-variant-numeric: tabular-nums; backdrop-filter: blur(6px);
}
.pill-float.show { opacity: 1; }
.selmenu { position: absolute; z-index: 7; display: flex; gap: 2px; background: #1c2027; color: #fff; padding: 4px; border-radius: 14px; box-shadow: 0 10px 26px rgba(0, 0, 0, .28); animation: pop-in .14s ease-out; white-space: nowrap; }
.selmenu button { padding: 8px 12px; border-radius: 10px; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.selmenu button:hover { background: rgba(255, 255, 255, .12); }
.selmenu button.ai { background: linear-gradient(135deg, #12b856, #1ea7a0); }
.drawer {
  position: absolute; left: 0; top: 0; bottom: 0; width: 220px; background: rgba(247, 248, 250, .97); backdrop-filter: blur(14px); z-index: 11; overflow-y: auto;
  padding: 14px 12px 30px; box-shadow: 6px 0 26px rgba(20, 30, 50, .14); display: flex; flex-direction: column; gap: 16px; align-items: center; animation: slide-in-left .2s ease-out;
}
.drawer .pt { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.drawer .pt canvas { box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 4px 12px rgba(20, 30, 50, .12); border-radius: 2px; background: #fff; transition: transform .15s; }
.drawer .pt:hover canvas { transform: translateY(-2px); }
.drawer .pt.on canvas { outline: 3px solid var(--accent); outline-offset: 3px; }
.drawer .pt.on { color: var(--accent-ink); }
.drawer .add { width: 150px; height: 60px; border-radius: 12px; border: 2px dashed #cfd4da; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; font-size: 14px; }
.drawer .add:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- side panel: ask AI, voice ---------- */
.panel {
  position: absolute; right: 12px; top: 12px; bottom: 12px; width: min(400px, calc(100% - 24px)); z-index: 12; background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(16px); border-radius: 22px; box-shadow: var(--shadow-3), 0 0 0 1px rgba(0, 0, 0, .04); display: flex; flex-direction: column;
  animation: slide-in-right .22s ease-out; overflow: hidden;
}
.panel .ph { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px 18px; }
.panel .ph h3 { margin: 0; font-size: 17px; flex: 1; display: flex; align-items: center; gap: 8px; }
.panel .ph h3 .ic { color: var(--accent-ink); }
.panel .pb { flex: 1; overflow-y: auto; padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.panel .pf { padding: 12px 14px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 10px; }
.panel .snap { border-radius: 14px; background: #f4f5f7; padding: 8px; display: flex; justify-content: center; }
.panel .snap img { max-width: 100%; max-height: 190px; border-radius: 8px; display: block; box-shadow: var(--shadow-1); background: #fff; }
.panel .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.panel textarea.q { width: 100%; min-height: 64px; max-height: 160px; resize: vertical; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: 15px; outline: 0; line-height: 1.5; }
.panel textarea.q:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.panel .row2 { display: flex; align-items: center; gap: 10px; }
.panel .row2 .grow { flex: 1; font-size: 13.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.panel .toggle.sm { width: 42px; height: 26px; margin-left: 0; }
.panel .toggle.sm::after { width: 20px; height: 20px; }
.panel .toggle.sm.on::after { left: 19px; }
.qa { display: flex; flex-direction: column; gap: 8px; }
.qa .q { align-self: flex-end; max-width: 88%; background: var(--accent-soft); color: #08532a; padding: 9px 13px; border-radius: 16px 16px 4px 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; }
.qa .a { background: #f4f5f7; padding: 12px 14px; border-radius: 16px 16px 16px 4px; font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.qa .a .final { display: block; margin-top: 8px; padding: 8px 11px; border-radius: 10px; background: #fff; border: 1.5px solid var(--accent); font-weight: 650; }
.qa .acts { display: flex; gap: 6px; }
.qa .wait { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 6px 2px; }
.rec { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0 4px; }
.rec .big { width: 84px; height: 84px; border-radius: 50%; background: #e5484d; color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px rgba(229, 72, 77, .35); transition: transform .12s; }
.rec .big:active { transform: scale(.96); }
.rec .big.on { animation: pulse 1.4s infinite; border-radius: 26px; }
.rec .time { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec .meter { width: 70%; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.rec .meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #f5b400, #e5484d); transition: width .08s; }
.recs { display: flex; flex-direction: column; gap: 8px; }
.recs .r { background: #f6f7f9; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.recs .r .top2 { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.recs .r .top2 b { color: var(--ink); }
.recs .r .txt { font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; }
.recs .r .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.55; }
.warn { font-size: 13.5px; color: #8a5a00; background: #fff6db; border-radius: 12px; padding: 10px 12px; line-height: 1.5; }

/* ---------- small screens ---------- */
.bottom-nav { display: none; }
@media (max-width: 820px) {
  .side { display: none; }
  .mobile-search { display: grid; }
  .lib { flex-direction: column; }
  .head { padding: 16px 16px 2px; }
  .head h1 { font-size: 25px; }
  .crumb { padding: 0 16px; }
  .grid { padding: 16px 16px 30px; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 24px 12px; }
  .cover, .sheet { width: 112px; height: 146px; }
  .cover .plate { left: 18px; top: 20px; font-size: 11.5px; }
  .folder { width: 128px; height: 100px; margin-top: 36px; }
  .card .title { max-width: 130px; }
  .grid.list .card .meta { display: none; }
  .bottom-nav { display: flex; justify-content: space-around; padding: 6px 0 calc(6px + var(--safe-bottom)); background: rgba(255, 255, 255, .92); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  .bottom-nav .nav { flex-direction: column; gap: 2px; font-size: 12px; padding: 6px 14px; width: auto; }
  .bottom-nav .nav .count { display: none; }
  .newnb { grid-template-columns: 1fr; }
  .gate .card2 { grid-template-columns: 1fr; }
  .gate .qrside { border-left: 0; border-top: 1px solid var(--line-2); order: -1; }
  .ed .bar { flex-wrap: wrap; row-gap: 2px; padding: 5px 6px; }
  .ed .grp.mid { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .ed .grp.mid::-webkit-scrollbar { display: none; }
  .ed .doc { max-width: none; flex: 1; }
  .ed .vsep.hide-sm { display: none; }
  .tb { width: 42px; height: 42px; }
  .panel { left: 8px; right: 8px; width: auto; top: auto; height: 78%; bottom: 8px; border-radius: 22px; animation: rise-in .22s ease-out; }
}
