/* Inkfolio — design system and components. */
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/figtree-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/figtree-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/figtree-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/figtree-latin-700-normal.woff2") format("woff2"); }
:root {
  --font: "Figtree", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --bg: #E7EAF1;
  --chrome: #F6F7FB;
  --surface: #FFFFFF;
  --surface-2: #EFF1F7;
  --surface-3: #E3E6EF;
  --line: rgba(20, 28, 48, .09);
  --line-strong: rgba(20, 28, 48, .17);
  --text: #121826;
  --text-2: #566074;
  --text-3: #6F7A8F;
  --accent: #2F54EB;
  --accent-2: #22D3C5;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(47, 84, 235, .12);
  --danger: #D92D4A;
  --glass: rgba(255, 255, 255, .8);
  --glass-line: rgba(20, 28, 48, .1);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .07);
  --shadow-2: 0 10px 28px -8px rgba(16, 24, 40, .22), 0 2px 6px rgba(16, 24, 40, .08);
  --shadow-3: 0 28px 70px -14px rgba(16, 24, 40, .4), 0 8px 22px rgba(16, 24, 40, .14);
  --page-shadow: 0 1px 3px rgba(16, 24, 40, .14), 0 14px 34px -10px rgba(16, 24, 40, .28);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0C0F14;
  --chrome: #13171E;
  --surface: #181D26;
  --surface-2: #1F2530;
  --surface-3: #2A313F;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .17);
  --text: #E8EBF3;
  --text-2: #A5AEC0;
  --text-3: #8791A5;
  --accent: #7C98FF;
  --accent-ink: #0B1020;
  --accent-soft: rgba(124, 152, 255, .17);
  --danger: #FF6B84;
  --glass: rgba(27, 32, 43, .82);
  --glass-line: rgba(255, 255, 255, .11);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 30px -8px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-3: 0 30px 80px -14px rgba(0, 0, 0, .75), 0 8px 24px rgba(0, 0, 0, .4);
  --page-shadow: 0 0 0 1px rgba(255, 255, 255, .05), 0 16px 44px -10px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--chrome); color: var(--text); font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
kbd { font: 600 11px/1 var(--font); padding: 3px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(47, 84, 235, .28); }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.glass { background: var(--glass); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5); border: 1px solid var(--glass-line); box-shadow: var(--shadow-2); }
.spacer { flex: 1; }
.sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 6px; flex: none; }
.vsep { width: 1px; height: 24px; background: var(--line-strong); margin: 0 6px; flex: none; align-self: center; }
.empty { color: var(--text-3); padding: 18px 16px; font-size: 13px; line-height: 1.5; }

/* ───────── buttons ───────── */
.btn { height: 34px; min-width: 34px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; background: transparent; font-weight: 500; white-space: nowrap; transition: background .14s, color .14s, transform .12s var(--ease), box-shadow .14s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.96); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 28px; min-width: 28px; border-radius: 8px; padding: 0 8px; }
.btn.sm.icon { width: 28px; padding: 0; }
.btn.sm .ic { width: 17px; height: 17px; }
.btn.lg { height: 46px; padding: 0 20px; border-radius: 13px; font-size: 15px; }
.btn.ghost { color: var(--text-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 16px -6px var(--accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.btn:not(.primary):not(.icon).lg, .btn.lg:not(.primary) { background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.btn.lg:not(.primary):hover { background: var(--surface-2); }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.btn:disabled { opacity: .38; pointer-events: none; }
.btn.on, .btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.zoomlabel { min-width: 56px; font-variant-numeric: tabular-nums; padding: 0 8px; }

/* ───────── layout ───────── */
#app { display: grid; grid-template-rows: 40px 46px minmax(0, 1fr); height: 100vh; height: 100dvh; }
#titlebar { display: flex; align-items: flex-end; gap: 6px; padding: 0 10px; background: var(--bg); min-width: 0; }
#titlebar > .btn { align-self: center; }
.brand { display: flex; align-items: center; gap: 9px; align-self: center; height: 32px; padding: 0 10px 0 6px; border: 0; background: transparent; color: var(--text); border-radius: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; transition: background .14s; }
.brand:hover { background: color-mix(in srgb, var(--chrome) 60%, transparent); }
.brand-stroke { stroke-dasharray: 60; stroke-dashoffset: 0; animation: draw 1.1s .15s var(--ease) both; }
#tabs { display: flex; align-items: flex-end; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; height: 34px; min-width: 120px; max-width: 220px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px; border-radius: 11px 11px 0 0; color: var(--text-2); cursor: pointer; flex: 0 1 200px; transition: background .14s, color .14s; user-select: none; }
.tab:hover { background: color-mix(in srgb, var(--chrome) 55%, transparent); }
.tab.on { background: var(--chrome); color: var(--text); font-weight: 600; }
.tab.on::before, .tab.on::after { content: ""; position: absolute; bottom: 0; width: 10px; height: 10px; background: radial-gradient(circle at var(--cx) 0, transparent 9.5px, var(--chrome) 10px); }
.tab.on::before { left: -10px; --cx: 0; }
.tab.on::after { right: -10px; --cx: 100%; }
.tico .ic { width: 16px; height: 16px; }
.tname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tclose { width: 22px; height: 22px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 6px; color: var(--text-3); opacity: 0; transition: opacity .12s, background .12s; padding: 0; }
.tab:hover .tclose, .tab.on .tclose, .tclose:focus-visible { opacity: 1; }
.tclose:hover { background: var(--surface-3); color: var(--text); }
.tclose .ic { width: 14px; height: 14px; }

#toolbar { display: flex; align-items: center; gap: 2px; padding: 0 10px; background: var(--chrome); border-bottom: 1px solid var(--line); min-width: 0; overflow-x: auto; scrollbar-width: none; }
#toolbar::-webkit-scrollbar { display: none; }
#toolbar .group { display: flex; align-items: center; gap: 2px; }
.pageinput { white-space: nowrap; flex: none; display: flex; align-items: center; gap: 6px; color: var(--text-2); padding: 0 6px; font-variant-numeric: tabular-nums; }
.pageinput input { width: 44px; height: 30px; text-align: center; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; font-weight: 600; }
.pageinput b { color: var(--text); font-weight: 600; }
#app.no-doc #toolbar .btn:not(#btn-open):not(#btn-sidebar), #app.no-doc #toolbar .pageinput { opacity: .35; pointer-events: none; }
#app.no-doc #btn-newtab { opacity: 1; }

#workspace { display: flex; min-height: 0; position: relative; }
#stage { position: relative; flex: 1; min-width: 0; background: var(--bg); overflow: hidden; }

/* ───────── sidebar ───────── */
#sidebar { width: 272px; flex: none; display: flex; flex-direction: column; background: var(--chrome); border-right: 1px solid var(--line); transition: width .26s var(--ease), border-color .26s; overflow: hidden; z-index: 20; }
#app[data-sidebar="0"] #sidebar { width: 0; border-color: transparent; }
#sidebar > * { min-width: 272px; }
.side-tabs { display: flex; gap: 2px; padding: 8px 10px 4px; }
.stab { position: relative; flex: 1; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-2); border-radius: 9px; transition: background .14s, color .14s; }
.stab:hover { background: var(--surface-3); }
.stab.on { background: var(--accent-soft); color: var(--accent); }
.stab .dot { position: absolute; top: 7px; right: calc(50% - 16px); width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 2px var(--chrome); }
.panel { display: none; flex: 1; min-height: 0; flex-direction: column; }
.panel.on { display: flex; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.panel-actions { display: flex; gap: 2px; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
#thumbs { padding: 4px 0 40px; }
.thumb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 6px; margin: 2px 10px; border-radius: 12px; cursor: pointer; transition: background .14s; }
.thumb:hover { background: var(--surface-2); }
.thumb.sel { background: var(--accent-soft); }
.thumb.dragging { opacity: .4; }
.tframe { background: #fff; border-radius: 3px; overflow: hidden; box-shadow: var(--shadow-1), 0 0 0 1px var(--line-strong); transition: box-shadow .16s; }
.tframe canvas { width: 100%; height: 100%; display: block; }
.thumb.cur .tframe { box-shadow: 0 0 0 2.5px var(--accent), var(--shadow-2); }
.tnum { font-size: 12px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.thumb.cur .tnum { color: var(--accent); font-weight: 700; }
.thumb.drop-before::before, .thumb.drop-after::after { content: ""; position: absolute; left: 10px; right: 10px; height: 3px; border-radius: 2px; background: var(--accent); }
.thumb.drop-before::before { top: -2px; } .thumb.drop-after::after { bottom: -2px; }

.otree { list-style: none; margin: 0; padding: 0 0 0 12px; }
#outline > .otree { padding: 0 8px 24px; }
.otree .otree { display: none; padding-left: 14px; }
.otree li.open > .otree { display: block; }
.orow { display: flex; align-items: center; }
.otog { width: 22px; height: 28px; flex: none; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); padding: 0; }
.otog .ic { width: 14px; height: 14px; transition: transform .16s var(--ease); }
li.open > .orow > .otog .ic { transform: rotate(90deg); }
.olink { flex: 1; text-align: left; border: 0; background: none; padding: 5px 8px; border-radius: 8px; color: var(--text); line-height: 1.3; }
.olink:hover { background: var(--surface-3); }

.searchbox { display: flex; align-items: center; gap: 4px; margin: 0 10px 8px; padding: 0 4px 0 10px; height: 38px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 11px; }
.searchbox:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbox .ic { color: var(--text-3); width: 18px; height: 18px; }
.searchbox input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 100%; }
.searchbox .count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
#search-results { padding: 0 8px 24px; }
.sres { width: 100%; display: flex; gap: 10px; align-items: baseline; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 10px; line-height: 1.35; }
.sres:hover { background: var(--surface-3); }
.sres.on { background: var(--accent-soft); }
.spg { flex: none; width: 36px; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ssn { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.ssn mark { background: rgba(255, 196, 0, .45); color: var(--text); border-radius: 3px; padding: 0 1px; }

#markup-list { padding: 0 8px 24px; }
.mgroup { display: flex; justify-content: space-between; padding: 12px 10px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.mrow { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-radius: 10px; cursor: pointer; }
.mrow:hover { background: var(--surface-3); }
.mdot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); flex: none; }
.mi .ic { width: 16px; height: 16px; color: var(--text-3); }
.mt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.mrow .btn { opacity: 0; }
.mrow:hover .btn, .mrow:focus-within .btn { opacity: 1; }

/* ───────── viewer + pages ───────── */
#viewer { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; outline: none; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
#pages { min-width: 100%; width: max-content; padding: 22px 24px 62px; touch-action: none; }
.page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: var(--page-shadow); border-radius: 2px; contain: layout style; }
.page-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cv { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.cv-hl { mix-blend-mode: multiply; }
.cv-live { will-change: contents; }
.page.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(120, 132, 165, .13) 50%, transparent 70%) 0 0 / 220% 100%; animation: shimmer 1.3s linear infinite; pointer-events: none; }
#viewer[data-tone="sepia"] .cv-pdf { filter: sepia(.55) saturate(1.15) brightness(.97); }
#viewer[data-tone="night"] .cv-pdf { filter: invert(.92) hue-rotate(180deg) contrast(.9); }
#viewer[data-tone="night"] .page { background: #1b1c20; }
#viewer[data-tone="sepia"] .page { background: #f1e7d0; }

.textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; pointer-events: none; text-size-adjust: none; transform-origin: 0 0; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre; transform-origin: 0 0; cursor: text; }
.textLayer ::selection { background: rgba(47, 84, 235, .34); }
#viewer[data-kind="select"] .textLayer span { pointer-events: auto; }
#viewer[data-kind="select"] .page-inner { user-select: none; -webkit-user-select: none; }
#viewer[data-kind="select"] .textLayer span { user-select: text; -webkit-user-select: text; }
#viewer[data-kind="hand"] .page, #viewer[data-kind="hand"] .page * { cursor: grab; user-select: none; }
#viewer.grabbing .page, #viewer.grabbing .page * { cursor: grabbing; }
#viewer[data-kind="ink"] .page, #viewer[data-kind="eraser"] .page { cursor: none; }
#viewer[data-kind="shape"] .page, #viewer[data-kind="sign"] .page { cursor: crosshair; }
#viewer[data-kind="text"] .page { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 5h6M10 5v18M7 23h6' stroke='white' stroke-width='4.5'/%3E%3Cpath d='M7 5h6M10 5v18M7 23h6' stroke='%23111827' stroke-width='2'/%3E%3Cpath d='M21 3v8M17 7h8' stroke='white' stroke-width='4.5'/%3E%3Cpath d='M21 3v8M17 7h8' stroke='%232F54EB' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E") 10 14, text; }
#viewer[data-kind="edittext"] .page { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5h6M12 5v18M9 23h6' stroke='white' stroke-width='4.5'/%3E%3Cpath d='M9 5h6M12 5v18M9 23h6' stroke='%23111827' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E") 12 14, text; }
.edit-hint { position: absolute; border: 1.5px solid var(--accent); background: rgba(47, 84, 235, .09); border-radius: 4px; pointer-events: none; }
.cover-temp { position: absolute; pointer-events: none; }

#viewer:not([data-kind="select"]) .page-inner { user-select: none; -webkit-user-select: none; }

.search-layer { position: absolute; inset: 0; pointer-events: none; }
.sh { position: absolute; background: rgba(255, 196, 0, .42); border-radius: 3px; mix-blend-mode: multiply; }
.sh.cur { background: rgba(255, 128, 0, .55); box-shadow: 0 0 0 2px rgba(255, 110, 0, .85); }
.dom-layer { position: absolute; inset: 0; pointer-events: none; }
.tbox { position: absolute; margin: 0; padding: 0; line-height: 1.25; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; pointer-events: none; min-height: 1.25em; min-width: 8px; }
.tbox.editing { pointer-events: auto; outline: 1.5px dashed var(--accent); outline-offset: 4px; background: rgba(47, 84, 235, .05); cursor: text; user-select: text; -webkit-user-select: text; }
.selbox { position: absolute; border: 1.5px solid var(--accent); border-radius: 5px; background: rgba(47, 84, 235, .045); pointer-events: none; }
.sel-handle { position: absolute; width: 13px; height: 13px; background: #fff; border: 2.5px solid var(--accent); border-radius: 50%; pointer-events: auto; touch-action: none; box-shadow: var(--shadow-1); }
.sel-handle::after { content: ""; position: absolute; inset: -9px; }
.sel-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.sel-handle.e { right: -8px; top: 50%; margin-top: -7px; cursor: ew-resize; }
.marquee { position: absolute; border: 1px solid var(--accent); background: rgba(47, 84, 235, .1); border-radius: 3px; pointer-events: none; }

#ring { position: fixed; left: 0; top: 0; z-index: 60; border-radius: 50%; pointer-events: none; will-change: transform; border: 1.5px solid rgba(20, 24, 36, .7); box-shadow: 0 0 0 1px rgba(255, 255, 255, .85); }
#ring[data-kind="ink"] { background: color-mix(in srgb, var(--ring, #111) 55%, transparent); }
#ring[data-kind="eraser"] { background: rgba(255, 255, 255, .25); border-style: dashed; }

/* floating bars */
#selbar, #selpop { position: absolute; left: 0; top: 0; z-index: 40; display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-radius: 14px; animation: pop .18s var(--ease); }
.selcount { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 0 8px; }
.swatch-btn { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); padding: 0; transition: transform .14s var(--spring); }
.swatch-btn:hover { transform: scale(1.18); }
#selpop .vsep { margin: 0 4px; height: 20px; }

/* ───────── pen tray ───────── */
#dock { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 2px; height: 56px; padding: 0 8px; border-radius: 18px; max-width: calc(100% - 20px); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; animation: rise .5s var(--ease) both; }
#dock::-webkit-scrollbar { display: none; }
.dbtn { position: relative; flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--text-2); border-radius: 13px; transition: background .14s, color .14s, transform .18s var(--spring); }
.dbtn:hover { background: var(--surface-3); color: var(--text); }
.dbtn .bar { position: absolute; left: 13px; right: 13px; bottom: 5px; height: 3px; border-radius: 3px; background: var(--tip, transparent); box-shadow: 0 0 0 1px var(--line-strong); }
.dbtn.on { background: var(--accent-soft); color: var(--accent); }
.dbtn .ic { width: 22px; height: 22px; }
#optbar { transition: opacity .22s var(--ease), translate .22s var(--ease); position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 29; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 20px; padding: 10px 18px; border-radius: 18px; max-width: calc(100% - 20px); animation: rise .28s var(--ease) backwards; }
.opt { display: flex; align-items: center; gap: 10px; }
.opt.preview-wrap { flex-direction: column; align-items: flex-start; gap: 2px; }
canvas.preview { background: var(--surface-2); border-radius: 10px; display: block; }
.pname { font-size: 12px; font-weight: 600; color: var(--text-2); padding-left: 2px; }
.olabel { font-size: 12.5px; color: var(--text-2); min-width: 0; }
.ohint { font-size: 12.5px; color: var(--text-2); max-width: 22ch; line-height: 1.3; }
.opt output { min-width: 50px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 120px; height: 22px; background: transparent; margin: 0; cursor: pointer; --pct: 50%; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--pct), var(--surface-3) var(--pct)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff; border: 1px solid var(--line-strong); box-shadow: 0 1px 4px rgba(10, 14, 28, .35); transition: transform .14s var(--spring); }
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 1px solid var(--line-strong); box-shadow: 0 1px 4px rgba(10, 14, 28, .35); }
.crow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cswatch { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--glass-solid, var(--surface)); background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); padding: 0; transition: transform .16s var(--spring), box-shadow .14s; }
.cswatch:hover { transform: scale(1.16); }
.cswatch.on { box-shadow: 0 0 0 2.5px var(--accent); }
.cswatch.custom { background: radial-gradient(circle, var(--c) 0 38%, transparent 40%), conic-gradient(#f43f5e, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #f43f5e); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 11px; border: 1px solid var(--line); }
.segb { height: 28px; padding: 0 12px; border: 0; background: transparent; border-radius: 8px; color: var(--text-2); font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; transition: background .14s, color .14s; }
.segb .ic { width: 17px; height: 17px; }
.segb.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-1); }
.tgl { height: 30px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 9px; font-weight: 500; font-size: 13px; transition: background .14s, border-color .14s; }
.tgl .ic { width: 16px; height: 16px; }
.tgl.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tgl.b { font-weight: 800; } .tgl.i { font-style: italic; }
.sel { height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 9px; }

/* ───────── menus + popovers ───────── */
#menu-root > * { position: fixed; left: 0; top: 0; z-index: 200; opacity: 0; }
#menu-root > .in { opacity: 1; animation: pop .16s var(--ease); }
.menu { min-width: 220px; padding: 6px; border-radius: 14px; }
.mitem { width: 100%; display: flex; align-items: center; gap: 10px; padding: 0 10px; height: 34px; border: 0; background: transparent; border-radius: 9px; text-align: left; transition: background .1s; }
.mitem:hover, .mitem:focus-visible { background: var(--accent-soft); outline: 0; }
.mitem.on .mic { color: var(--accent); }
.mitem.danger { color: var(--danger); }
.mitem:disabled { opacity: .4; }
.mic { width: 20px; display: grid; place-items: center; color: var(--text-2); }
.mic .ic { width: 18px; height: 18px; }
.mlabel { flex: 1; }
.msep { height: 1px; background: var(--line); margin: 5px 6px; }
.mhead { padding: 8px 10px 3px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.cpop { padding: 12px; border-radius: 16px; width: 232px; }
.cgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cgrid .cswatch { width: 24px; height: 24px; }
.ccustom { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.ccustom input { width: 44px; height: 28px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: none; cursor: pointer; }

#tooltip { position: fixed; left: 0; top: 0; z-index: 500; display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 9px; background: #10151F; color: #fff; font-size: 12.5px; font-weight: 500; pointer-events: none; box-shadow: var(--shadow-2); white-space: nowrap; animation: fade .12s; }
#tooltip kbd { background: rgba(255, 255, 255, .15); color: #fff; border: 0; }
[data-theme="dark"] #tooltip { background: #2E3648; }

#toasts { position: fixed; left: 50%; top: 98px; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 13px; background: #121826; color: #fff; font-weight: 500; box-shadow: var(--shadow-3); opacity: 0; transform: translateY(10px) scale(.97); transition: opacity .22s, transform .3s var(--spring); }
[data-theme="dark"] .toast { background: #2A3142; }
.toast.in { opacity: 1; transform: none; }
.tdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tdot.ok { background: #2DD4BF; } .tdot.err { background: #FF6B84; }
.tact { border: 0; background: rgba(255, 255, 255, .16); color: #fff; height: 26px; padding: 0 10px; border-radius: 8px; font-weight: 600; }

/* ───────── palette + modal ───────── */
#palette { position: fixed; inset: 0; z-index: 250; display: grid; place-items: start center; padding-top: 12vh; background: rgba(8, 11, 20, .38); opacity: 0; transition: opacity .16s; }
#palette.in { opacity: 1; }
.palette-box { width: min(620px, calc(100vw - 24px)); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-3); transform: translateY(-8px) scale(.985); transition: transform .24s var(--ease); }
#palette.in .palette-box { transform: none; }
.palette-in { display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 56px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.palette-in input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); height: 100%; }
#palette-list { max-height: min(52vh, 440px); overflow-y: auto; padding: 8px; }
.pitem { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 11px; cursor: pointer; }
.pitem.on { background: var(--accent-soft); }
.pic { color: var(--text-2); display: grid; }
.pitem.on .pic { color: var(--accent); }
.ptitle { flex: 1; font-weight: 500; }
.pgroup { font-size: 12px; color: var(--text-3); }

.modal-back { position: fixed; inset: 0; z-index: 260; display: grid; place-items: center; padding: 16px; background: rgba(8, 11, 20, .45); opacity: 0; transition: opacity .18s; }
.modal-back.in { opacity: 1; }
.modal { width: min(440px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; border-radius: 22px; box-shadow: var(--shadow-3); transform: translateY(10px) scale(.98); transition: transform .28s var(--ease); background: var(--surface); backdrop-filter: none; }
.modal.wide { width: min(600px, 100%); }
.modal-back.in .modal { transform: none; }
.mtitle { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 22px; }
.mtitle h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.mbody { padding: 8px 22px 6px; overflow: auto; color: var(--text-2); }
.mbody p { margin-bottom: 12px; line-height: 1.5; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px 18px; }
.field { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface-2); outline: 0; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sigpad { display: block; width: 100%; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface-2); touch-action: none; cursor: crosshair; }
.sigtools { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; padding-bottom: 12px; }
.keys h3 { font-size: 12px; font-weight: 700; color: var(--text-3); margin: 14px 0 6px; }
.krow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text); }
#dropzone { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 18%, rgba(8, 11, 20, .55)); backdrop-filter: blur(6px); pointer-events: none; animation: fade .15s; }
.dz-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 38px 56px; border: 2px dashed var(--accent-ink); border-radius: 28px; color: #fff; background: rgba(8, 11, 20, .35); }
.dz-card .ic { width: 38px; height: 38px; transform: rotate(180deg); } .dz-card b { font-size: 20px; } .dz-card span { opacity: .8; }

/* ───────── home ───────── */
#home { position: absolute; inset: 0; overflow: auto; display: flex; justify-content: center; padding: clamp(24px, 6vh, 64px) clamp(16px, 4vw, 40px) 56px; background: radial-gradient(900px 420px at 30% -120px, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%), var(--bg); }
.home-inner { width: min(1040px, 100%); }
.home-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(20px, 4vw, 48px); align-items: center; }
.home-copy { display: flex; flex-direction: column; gap: 14px; }
.home-copy h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.08; font-weight: 700; letter-spacing: -.028em; max-width: 16ch; text-wrap: balance; }
.home-copy > p { color: var(--text-2); font-size: 16px; max-width: 44ch; line-height: 1.55; text-wrap: pretty; }
.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.dropcard { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 250px; padding: 24px; border: 2px dashed var(--line-strong); border-radius: 24px; background: color-mix(in srgb, var(--surface) 55%, transparent); color: var(--text-2); text-align: center; transition: border-color .18s, background .18s, transform .25s var(--spring); }
.dropcard:hover, .dropcard:focus-visible { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.dropcard b { color: var(--text); font-size: 17px; margin-top: 6px; }
.hero-mark { width: 96px; height: 96px; filter: drop-shadow(0 14px 22px rgba(20, 30, 70, .22)); }
.hero-ink { stroke-dasharray: 190; stroke-dashoffset: 0; animation: draw 1.6s .25s var(--ease) both; }
.home-recent { margin-top: clamp(32px, 6vh, 56px); }
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.recent-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.recent-tools { display: flex; align-items: center; gap: 8px; }
.searchbox.mini { margin: 0; height: 34px; width: 230px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 16px; }
.rcard { position: relative; display: flex; flex-direction: column; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; cursor: pointer; transition: transform .24s var(--spring), box-shadow .2s, border-color .2s; box-shadow: var(--shadow-1); }
.rcard:hover, .rcard:focus-visible { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.rthumb { height: 160px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; color: var(--text-3); }
.rthumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.rmeta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; min-width: 0; }
.rmeta b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rmeta span { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmeta .rago { color: var(--text-2); }
.rdel { position: absolute; top: 8px; right: 8px; background: var(--glass); opacity: 0; }
.rcard:hover .rdel, .rcard:focus-within .rdel { opacity: 1; }
@media (max-width: 760px) { .home-top { grid-template-columns: 1fr; } .dropcard { min-height: 170px; } .searchbox.mini { width: 100%; } .recent-tools { width: 100%; } }

/* ───────── motion ───────── */
@keyframes draw { from { stroke-dashoffset: 190; } to { stroke-dashoffset: 0; } }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pop { from { opacity: 0; scale: .96; } to { opacity: 1; scale: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ───────── small screens ───────── */
@media (max-width: 860px) {
  #sidebar { position: absolute; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow-3); max-width: 88vw; }
  #sidebar > * { min-width: 0; width: min(272px, 88vw); }
  #app[data-sidebar="0"] #sidebar { box-shadow: none; }
  .brand-name { display: none; }
  #btn-fit-width, #btn-fit-page, #btn-fullscreen, #btn-redo { display: none; }
  .keys { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  #titlebar { padding: 0 6px; }
  #toolbar .sep { margin: 0 2px; }
  .btn.primary span { display: none; }
  .btn.primary { padding: 0; width: 34px; }
  #optbar { bottom: 88px; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; border-radius: 16px; }
  .opt.slider input { width: 90px; }
}

#optbar.away { opacity: 0; translate: 0 12px; pointer-events: none; }
