@font-face {
  font-family: Patrick Hand;
  src: url("fonts/PatrickHand-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  scrollbar-gutter: stable;
  --base: #f7f7fb;
  --surface: #fff;
  --surface-soft: #f0eef8;
  --ink: #211d32;
  --muted: #686479;
  --line: #e6e3ef;
  --accent: #ed765f;
  --accent-hover: #ff977f;
  --accent-ink: #271722;
  --purple: #6a4baf;
  --purple-soft: #f1eafb;
  --success: #25684f;
  --danger: #a62e42;
  --shadow: 0 8px 22px #33264f0a;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--base);
  color: var(--ink);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --base: #191624;
  --surface: #231e31;
  --surface-soft: #302941;
  --ink: #f4effa;
  --muted: #b8aec9;
  --line: #3d344c;
  --accent: #ff8a72;
  --accent-hover: #ffa28f;
  --purple: #c7adff;
  --purple-soft: #382c50;
  --success: #a1dec1;
  --danger: #ffb4be;
  --shadow: 0 8px 22px #110b1d35;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
input, textarea, select { color: var(--ink); }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--purple); text-underline-offset: .23em; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
.sr-only, .icon-library { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.theme-sun, :root[data-theme="dark"] .theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }

.app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 26px 17px 16px; z-index: 3; }
.brand { display: inline-flex; gap: 11px; align-items: center; text-decoration: none; color: var(--ink); font-weight: 760; font-size: 1.16rem; letter-spacing: -.045em; width: fit-content; }
.sidebar > .brand { margin: 0 7px 43px; }
.brand-mark { display: grid; place-items: center; width: 40px; aspect-ratio: 1; background: var(--accent); color: var(--accent-ink); border-radius: 12px; }
.brand-mark .icon { width: 23px; height: 23px; }
.side-main { display: flex; min-height: 0; flex-direction: column; flex: 1; justify-content: space-between; gap: 18px; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; scrollbar-width: thin; }
.side-nav { display: grid; gap: 5px; }
.nav-caption { color: var(--muted); font-size: .75rem; font-weight: 650; margin: 0 11px 7px; }
.side-link { display: flex; align-items: center; gap: 11px; min-height: 43px; color: var(--muted); font-weight: 620; font-size: .9rem; text-decoration: none; padding: 8px 11px; border-radius: 9px; border: 0; background: transparent; }
.side-link:hover { background: var(--surface-soft); color: var(--ink); }
.side-link.active { background: var(--purple-soft); color: var(--purple); }
.side-link .icon { width: 18px; height: 18px; }
.theme-toggle { width: 100%; }
.side-legal { display: flex; gap: 14px; font-size: .78rem; flex-wrap: wrap; }
.side-legal a { color: var(--muted); text-decoration: none; }
.side-legal a:hover { color: var(--purple); text-decoration: underline; }
.side-bottom > .side-legal { margin: 9px 10px 16px; }
.account { display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); padding: 15px 2px 0; }
.avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--purple-soft); color: var(--purple); font-weight: 750; }
.account-name { display: grid; flex: 1; min-width: 0; }
.account-name strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name small { font-size: .72rem; color: var(--muted); }

.workspace { width: min(100%, 1440px); padding: 33px clamp(24px, 3.2vw, 52px) 52px; margin: 0 auto; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 4px 0 26px; }
h1, .title-input { font-weight: 780; letter-spacing: -.055em; font-size: clamp(2.1rem, 4vw, 3.15rem); line-height: 1.08; }
.page-head p:not(.eyebrow), .auth-form > p:not(.eyebrow), .legal-page > p { color: var(--muted); margin-top: 9px; line-height: 1.55; }
.eyebrow { display: flex; align-items: center; gap: 7px; color: var(--purple); font-size: .75rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 760; margin-bottom: 9px; }
.eyebrow .icon { width: 15px; height: 15px; }
.button { min-height: 42px; padding: 9px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; font-size: .88rem; font-weight: 700; line-height: 1.23; text-decoration: none; border: 1px solid transparent; white-space: nowrap; transition: background-color 140ms, border-color 140ms, box-shadow 140ms; }
.button .icon { width: 17px; height: 17px; }
.button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 3px #35211f12; }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { color: var(--ink); border-color: var(--line); background: var(--surface); }
.button.secondary:hover:not(:disabled) { background: var(--surface-soft); }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; background: transparent; border: 0; color: var(--muted); border-radius: 8px; padding: 0; }
.icon-button:hover:not(:disabled) { background: var(--surface-soft); color: var(--ink); }
.icon-button .icon { width: 18px; height: 18px; }

.hero, .auth-visual { color: #fff8ff; background: radial-gradient(ellipse at 85% 20%, #573e82, transparent 58%), linear-gradient(112deg, #2b2044, #3d2d5d); overflow: hidden; position: relative; isolation: isolate; }
.hero { border-radius: 20px; min-height: 272px; display: flex; align-items: center; box-shadow: 0 13px 24px #33224f22; }
.hero-copy { padding: 29px clamp(24px, 4vw, 45px); max-width: 62%; z-index: 1; }
.hero h2, .auth-visual h2 { font-size: clamp(2.25rem, 4.5vw, 4.05rem); line-height: .99; letter-spacing: -.065em; font-weight: 785; }
.hero p, .auth-visual p { color: #e0d7ee; margin-top: 13px; line-height: 1.5; }
.hero-button { color: #fff4ff; border-color: #c9b7e46b; background: #ffffff12; margin-top: 19px; }
.hero-button:hover { background: #ffffff29; }
.hero-button:focus-visible { outline-color: #f2d7ff; }
.paper-art { position: absolute; width: 370px; height: 310px; right: clamp(0px, 6vw, 82px); top: 50%; transform: translateY(-50%); pointer-events: none; color: #ffe2a7; }
.paper-orbit { position: absolute; inset: 5% -12% 4% -4%; border-radius: 50%; border: 1px solid #baa6e249; transform: rotate(-22deg); }
.paper-orbit::before, .paper-orbit::after { content: ""; position: absolute; inset: 22px -21px; border: 1px solid #baa6e230; border-radius: 50%; }
.paper-orbit::after { inset: 44px -43px; border-color: #baa6e21b; }
.paper-under { position: absolute; top: 48px; right: 25%; width: 144px; height: 206px; background: #b7a1e7; border: 1px solid #d1c2f6; transform: rotate(19deg) translateX(26px); border-radius: 8px; box-shadow: 16px 14px 33px #120a1f71; }
.paper-front { position: absolute; top: 48px; right: 28%; width: 154px; height: 213px; border-radius: 8px; padding: 28px 15px 15px 23px; background: #fff8e8; transform: rotate(-13deg); box-shadow: 0 9px 22px #2112306e; color: #4b3d5b; }
.paper-binding { position: absolute; left: 5px; top: 17px; bottom: 17px; width: 9px; background: radial-gradient(circle, #b3aab8 2.15px, transparent 2.7px) center top / 8px 14px repeat-y; }
.paper-ink { display: block; font: 1.35rem/1 Patrick Hand, cursive; white-space: nowrap; }
.paper-swash { display: block; width: 90%; height: 9px; border-top: 3px solid #ef9a8b; border-radius: 50%; margin-top: 4px; transform: rotate(-3deg); }
.paper-ruled { display: block; height: 98px; margin-top: 6px; background: repeating-linear-gradient(transparent 0 15px, #8c80ad63 15px 16px, transparent 16px 18px); }
.paper-tick { position: absolute; font: 2rem/1 Patrick Hand, cursive; right: 20px; bottom: 15px; color: #8c64b2; transform: rotate(-7deg); }
.paper-spark, .paper-spark-small { position: absolute; top: 55px; right: 10%; }
.paper-spark .icon { width: 31px; height: 31px; stroke-width: 1.3; }
.paper-spark-small { top: auto; bottom: 61px; left: 15%; color: #ded0fd; }
.paper-spark-small .icon { width: 21px; height: 21px; stroke-width: 1.3; }

.library { margin-top: 32px; }
.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 13px; margin-bottom: 15px; }
.library-storage { color: var(--muted); font-size: .9rem; margin-bottom: 15px; line-height: 1.5; }
.library-storage a { display: inline-block; margin-left: .35em; }
.library-heading h2 { font-size: 1.35rem; font-weight: 760; letter-spacing: -.04em; display: flex; align-items: center; gap: 9px; }
.library-heading h2 span { display: inline-flex; min-width: 25px; height: 25px; align-items: center; justify-content: center; padding: 0 6px; font-size: .74rem; border-radius: 100px; color: var(--purple); background: var(--purple-soft); letter-spacing: 0; }
.library-filters { display: flex; align-items: center; gap: 8px; }
input:not([type="checkbox"]), select, textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
select { appearance: none; padding-right: 33px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.library-filters select { min-height: 39px; font-size: .85rem; }
.searchbox { height: 39px; display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); width: clamp(135px, 17vw, 240px); }
.searchbox:focus-within { outline: 2px solid var(--purple); outline-offset: 1px; }
.searchbox > input { font-size: .85rem; border: 0; outline: 0; background: transparent; padding-right: 0; }
.searchbox button { flex: none; width: 32px; height: 33px; margin: 2px; }
.docs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.doc-card { min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }
.doc-card:hover { border-color: var(--purple); }
.doc-cover { height: 128px; border-radius: 13px 13px 0 0; display: flex; justify-content: center; align-items: start; overflow: hidden; padding-top: 21px; background: #eae2f7; text-decoration: none; border-bottom: 1px solid var(--line); }
.doc-card:nth-child(3n+2) .doc-cover { background: #f4e3de; }
.doc-card:nth-child(3n+3) .doc-cover { background: #e1ebe9; }
.mini-sheet { display: block; background: #fffaf0; color: #4b3d5b; min-height: 145px; width: 136px; padding: 14px 12px; border-radius: 5px; font: 1.05rem / 1.12 Patrick Hand, cursive; transform: rotate(-5deg); box-shadow: 0 3px 12px #4a3c5e22; }
.mini-sheet div { border-bottom: 2px solid #eda798; padding-bottom: 4px; overflow: hidden; }
.mini-sheet p { font-size: .82rem; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mini-sheet span { display: block; border-bottom: 1px solid #b9a9bc; height: 13px; }
.pdf-cover img { width: 130px; height: auto; box-shadow: 0 3px 12px #4a3c5e22; }
.doc-info { display: flex; align-items: center; gap: 9px; padding: 12px 10px 12px 12px; }
.doc-type { color: var(--purple); background: var(--purple-soft); padding: 7px; border-radius: 8px; flex: none; }
.doc-type .icon { width: 17px; height: 17px; }
.doc-name { flex: 1; min-width: 0; }
.doc-name h3 { font-size: .91rem; font-weight: 720; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-name h3 a { text-decoration: none; color: var(--ink); }
.doc-name h3 a:hover { color: var(--purple); }
.doc-name p { color: var(--muted); font-size: .76rem; margin-top: 3px; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.doc-menu { position: relative; }
.doc-menu .menu { position: absolute; top: calc(100% + 3px); right: 0; z-index: 2; display: grid; min-width: 190px; padding: 5px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 7px 20px #27203121; }
.menu a, .menu button { display: block; text-decoration: none; color: var(--ink); font-size: .88rem; width: 100%; text-align: left; padding: 8px; border: 0; background: none; border-radius: 5px; white-space: nowrap; }
.menu a:hover, .menu button:hover { background: var(--surface-soft); }
.menu button.danger-text { color: var(--danger); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 23px; color: var(--muted); font-size: .88rem; }
.empty { padding: 24px; border: 1px dashed var(--line); border-radius: 14px; background: var(--surface); display: grid; justify-items: start; gap: 8px; }
.empty p { color: var(--muted); line-height: 1.45; font-size: .91rem; }
.empty h3 { font-size: 1.05rem; letter-spacing: -.02em; margin-bottom: 2px; }
.empty-start { display: flex; align-items: center; gap: 15px; }
.empty-start div { flex: 1; }
.empty-icon { display: grid; background: var(--purple-soft); place-items: center; color: var(--purple); border-radius: 11px; width: 43px; height: 43px; flex: none; }

.back-link { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; font-size: .85rem; font-weight: 650; margin-bottom: 15px; }
.back-link:hover { color: var(--purple); }
.back-link .icon { width: 15px; height: 15px; }
.editor-head { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 17px; }
.editor-title { min-width: 0; flex: 1; }
input.title-input { background: transparent; border-color: transparent; margin: 0 0 0 -9px; padding: 3px 8px 4px; text-overflow: ellipsis; height: auto; width: calc(100% + 9px); font-size: clamp(1.75rem, 3.5vw, 2.78rem); }
input.title-input:hover, input.title-input:focus { border-color: var(--line); background: var(--surface); }
.editor-title .eyebrow { margin: 0 0 2px; }
.save-status { display: flex; align-items: center; margin-top: 6px; gap: 5px; font-size: .8rem; color: var(--success); }
.save-status .icon { width: 15px; height: 15px; }
.save-status[data-state="pending"] { color: var(--muted); }
.save-status[data-state="error"] { color: var(--danger); }
.save-status:not([data-state="saved"]):is([data-state="error"], [data-state="pending"]) .icon { visibility: hidden; }
.editor-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.settings-panel { border: 1px solid var(--line); background: var(--surface); border-radius: 11px; margin: 0 0 14px; }
.settings-panel summary { display: flex; align-items: center; justify-content: space-between; padding: 11px 12px; font-size: .9rem; font-weight: 700; }
.settings-panel summary span { display: flex; align-items: center; gap: 9px; }
.settings-panel summary .icon { width: 17px; height: 17px; color: var(--purple); }
.settings-panel[open] > summary { border-bottom: 1px solid var(--line); }
.settings-panel[open] > summary > .icon { transform: rotate(180deg); }
.settings-grid { padding: 13px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.settings-grid label, .inkside-box label { display: grid; gap: 5px; font-size: .85rem; font-weight: 650; }
.inkside-box { margin: 0 13px 13px; padding: 12px; border: 1px solid var(--line); background: var(--base); border-radius: 8px; display: grid; gap: 8px; }
.inkside-box a, .inkside-box small { font-size: .86rem; }
.inkside-box small { color: var(--muted); }
.editor-mode { display: flex; gap: 4px; margin-bottom: 9px; }
.mode-button { min-height: 36px; background: transparent; border: 1px solid transparent; color: var(--muted); padding: 6px 10px; }
.mode-button[aria-pressed="true"] { color: var(--purple); background: var(--purple-soft); border-color: var(--line); }
.mode-button:hover { background: var(--surface-soft); }
.editor-grid { display: grid; gap: 13px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.editor-grid[data-editor-mode="edit"], .editor-grid[data-editor-mode="preview"] { grid-template-columns: minmax(0, 1fr); }
.editor-grid[data-editor-mode="edit"] .preview-pane, .editor-grid[data-editor-mode="preview"] .input-pane { display: none; }
.editor-pane { display: flex; flex-direction: column; min-width: 0; min-height: min(560px, 62vh); background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); overflow: hidden; }
.pane-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 13px; border-bottom: 1px solid var(--line); min-height: 47px; }
.pane-header h2 { font-size: .94rem; font-weight: 740; display: flex; align-items: center; gap: 7px; }
.pane-header h2 .icon { width: 17px; height: 17px; color: var(--purple); }
.check-label { display: flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); }
.check-label input { margin: 0; accent-color: var(--purple); }
.format-bar { display: flex; align-items: center; gap: 2px; padding: 4px 9px; border-bottom: 1px solid var(--line); }
.text-tool { font-weight: 650; font-size: 1rem; }
.bold-tool { font-weight: 800; }
.italic-tool { font-style: italic; }
.toolbar-divider { height: 17px; border-right: 1px solid var(--line); margin: 0 5px; }
.editor textarea { flex: 1; resize: vertical; min-height: 330px; border: 0; border-radius: 0; padding: 15px; font: .92rem / 1.65 "Cascadia Code", Consolas, monospace; }
.editor textarea:focus-visible { outline-offset: -2px; }
.editor-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: .76rem; padding: 9px 13px; border-top: 1px solid var(--line); }
.preview-caption { color: var(--muted); font-size: .78rem; }
.preview-area { flex: 1; max-height: min(690px, 66vh); overflow: auto; padding: clamp(12px, 2vw, 23px); background: var(--surface-soft); }
.preview-paper { min-height: 400px; aspect-ratio: 210 / 297; max-width: 615px; margin: 0 auto; padding: clamp(14px, 3vw, 27px); background: #fffcf2; color: #372b4c; font: 1.22rem/1.36 Patrick Hand, cursive; box-shadow: 0 3px 15px #33234f24; overflow-wrap: anywhere; }
.preview-paper[data-paper="a4-l"] { aspect-ratio: 297 / 210; min-height: 220px; max-width: 760px; }
.preview-paper[data-paper="a5"] { max-width: 425px; }
.preview-paper[data-template="standard"] { background-image: radial-gradient(circle, #cdc5db 0.55px, transparent 0.9px); background-size: 12px 12px; }
.preview-paper[data-preview-scale="small"] { font-size: 1.02rem; }
.preview-paper[data-preview-scale="large"] { font-size: 1.4rem; }
.preview-placeholder { color: var(--muted); }
.handwritten h1 { font: bold 1.8em/1.13 Patrick Hand, cursive; letter-spacing: -.02em; }
.handwritten :is(h2, h3, h4, h5, h6) { font-size: 1.34em; line-height: 1.2; }
.handwritten > * + * { margin-top: .54em; }
.handwritten :is(ul, ol) { padding-left: 1.28em; margin-bottom: .45em; }
.handwritten blockquote { margin-left: 0; padding-left: .75em; border-left: 2px solid #bdb0ce; }
.handwritten table { border-collapse: collapse; font-size: .88em; width: 100%; table-layout: fixed; }
.handwritten :is(th, td) { border: 1px solid #bdb0ce; padding: .26em; text-align: left; }
.handwritten pre { white-space: pre-wrap; font-size: .75em; }
.handwritten .plain-copy { white-space: pre-wrap; }
.template-preview header { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.template-preview header p { margin-top: 4px; color: var(--muted); }
.template-preview img { margin: 16px auto 0; max-height: 48vh; border: 1px solid var(--line); box-shadow: var(--shadow); }
.export-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-top: 14px; }
.export-note { display: flex; align-items: flex-start; gap: 7px; color: var(--muted); font-size: .83rem; line-height: 1.45; }
.export-note .icon { width: 16px; height: 16px; color: var(--purple); }
.extra-exports { display: flex; gap: 7px; }
.extra-exports .button { min-height: 35px; }

.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: minmax(355px, 1fr) minmax(330px, 1fr); }
.auth-main { padding: clamp(20px, 4vw, 43px); display: flex; flex-direction: column; justify-content: space-between; gap: 26px; background: var(--surface); }
.auth-head { display: flex; align-items: center; justify-content: space-between; }
.auth-form { width: min(100%, 440px); margin: auto; }
.auth-form .eyebrow { margin-bottom: 14px; }
.auth-form h1 { max-width: 460px; }
.fields { display: grid; gap: 14px; }
.auth-form .fields { margin-top: 23px; }
.field { display: grid; gap: 6px; }
.field label { font-size: .91rem; font-weight: 675; }
.password-input { display: flex; gap: 6px; }
.password-input input { flex: 1; }
.password-input .button { min-width: 94px; }
.field [data-register-error] { color: var(--danger); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field small { font-size: .81rem; color: var(--muted); line-height: 1.35; }
.field input:not([type="file"]) { min-height: 43px; }
input[type="file"] { font-size: .89rem; }
input::file-selector-button { font: inherit; background: var(--purple-soft); color: var(--purple); padding: 6px 9px; border-radius: 5px; border: 0; margin-right: 8px; cursor: pointer; }
.auth-submit { margin: 3px 0 6px; width: 100%; }
.auth-choice { font-size: .9rem; }
.auth-choice a { font-weight: 700; }
.auth-visual { align-content: end; display: grid; padding: 24px 9% max(70px, 12vh); text-align: center; }
.auth-visual .paper-art { width: min(390px, 100%); left: 50%; top: 43%; transform: translate(-50%, -56%) scale(1.19); }
.auth-visual > div:last-child { position: relative; z-index: 1; }
.auth-visual h2 { font-size: clamp(2.2rem, 5.6vw, 5rem); }
.auth-visual p { margin-inline: auto; max-width: 335px; }
.narrow-page { max-width: 900px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: clamp(14px, 3vw, 24px); box-shadow: var(--shadow); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.replacement-warning { display: grid; gap: 8px; background: var(--surface-soft); padding: 13px; border-radius: 8px; line-height: 1.45; }
.replacement-warning ul { margin: 0; padding-left: 20px; overflow-wrap: anywhere; }
.profile-sample { margin-bottom: 15px; display: grid; gap: 10px; overflow-wrap: anywhere; }
.profile-sample img { max-height: 45vh; object-fit: contain; object-position: left; }
.help-note { display: flex; gap: 9px; line-height: 1.4; font-size: .9rem; padding: 11px; color: var(--purple); background: var(--purple-soft); border-radius: 8px; }
.help-note .icon { margin-top: 1px; width: 17px; height: 17px; }
.legal-page { margin: 0 auto; padding: 30px 20px 50px; max-width: 780px; }
.legal-copy { margin-top: 20px; overflow-wrap: anywhere; line-height: 1.6; }
.legal-copy p + p { margin-top: 1em; }
.new-options, .management-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 15px; }
.new-options p, .management-info small { color: var(--muted); }
.management-section, .storage-settings { margin-top: 16px; }
.storage-settings h2 { margin-bottom: 12px; }
.management-section > header, .management-list > li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.management-section > header { justify-content: space-between; margin-bottom: 14px; }
.management-list { margin: 0; padding: 0; list-style: none; }
.management-list > li { border-top: 1px solid var(--line); padding: 12px 0; }
.management-info { min-width: 120px; flex: 1; display: grid; gap: 4px; overflow-wrap: anywhere; }
.management-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.admin-stat { display: grid; gap: 6px; text-decoration: none; color: var(--ink); }
.admin-stat strong { font-size: 2rem; color: var(--purple); }
.account-status { border-radius: 50px; background: var(--surface-soft); color: var(--muted); padding: 4px 9px; font-size: .8rem; font-weight: 700; }
.account-status.positive { color: var(--success); }
.invitation-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 150px) auto; align-items: end; gap: 10px; margin: 0 0 16px; }
.invite-code { padding: 12px; border-radius: 10px; background: var(--purple-soft); display: grid; gap: 7px; margin-bottom: 14px; }
.invite-code > div { display: flex; gap: 8px; }
.setup-page > .brand, .setup-page > form { margin-bottom: 18px; }
.bulk-tools { display: flex; gap: 7px; margin-bottom: 12px; }
.bulk-tools .danger-text { color: var(--danger); }
.doc-card { position: relative; }
.document-selection { display: grid; place-items: center; position: absolute; z-index: 1; top: 8px; left: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); width: 37px; height: 37px; border-radius: 8px; cursor: pointer; }
.document-selection input { width: 17px; height: 17px; accent-color: var(--purple); }
.export-proof { margin: 0 auto; max-width: 615px; }
.export-proof > img { width: 100%; box-shadow: var(--shadow); }
.board-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.board-toolbar .button { min-height: 34px; padding: 5px 9px; }
.board-toolbar [aria-pressed="true"] { background: var(--purple-soft); color: var(--purple); border-color: var(--purple); }
.board-toolbar label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: .85rem; }
.board-toolbar select { padding: 5px 30px 5px 8px; }
.board-sheet { position: relative; box-shadow: var(--shadow); }
.board-sheet img { width: 100%; }
.board-sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.board-sheet canvas[data-tool="erase"] { cursor: cell; }
.board-sheet canvas[data-tool="view"] { pointer-events: none; }
.board-list { list-style: none; padding: 0; margin: 0; }
.board-list li { display: flex; align-items: center; gap: 12px; padding: 14px; }
.board-list li + li { border-top: 1px solid var(--line); }
.board-list .doc-name { min-width: 0; flex: 1; }
.board-list h2 { font-size: 1rem; overflow-wrap: anywhere; }
.export-proof figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pane-header > .button { min-height: 32px; font-size: .78rem; padding: 6px 8px; }
.editor-style-fields { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; margin: 0 0 14px; }
.editor-style-fields label { display: grid; gap: 5px; min-width: 135px; max-width: 100%; font-size: .88rem; font-weight: 650; }
.editor-style-fields a { font-size: .88rem; padding: 9px 0; }
.preview-navigation { display: flex; align-items: center; gap: 3px; color: var(--muted); font-size: .85rem; }
.forward-icon { transform: rotate(180deg); }
.preview-area [data-preview-retry] { margin-top: 12px; }
.format-bar { flex-wrap: wrap; }
.handwriting-library { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form input { flex: 1; min-width: 120px; }
.invitation-note { color: var(--muted); margin: 0 0 12px; font-size: .9rem; }
.contact-message header { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; align-items: center; }
.contact-message header h2 { font-size: 1.05rem; overflow-wrap: anywhere; }
.contact-message header time { color: var(--muted); font-size: .85rem; }
.contact-message .panel-actions { margin-top: 14px; }
@media (max-width: 550px) {
  .new-options, .invitation-form { grid-template-columns: minmax(0, 1fr); }
  .management-actions { width: 100%; }
}
.alert { font-size: .88rem; line-height: 1.45; color: var(--purple); background: var(--purple-soft); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; overflow-wrap: anywhere; }
.alert.error, .alert[data-state="error"], .errorlist { color: var(--danger); }
.alert[data-state="success"] { color: var(--success); }
.toast-stack { position: fixed; z-index: 15; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: grid; width: min(400px, calc(100vw - 34px)); gap: 8px; pointer-events: none; }
.toast { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px 9px 14px; border: 1px solid var(--line); border-inline-start: 3px solid var(--purple); border-radius: 10px; box-shadow: 0 10px 32px #1611243b; background: var(--surface); color: var(--ink); font-size: .9rem; line-height: 1.4; pointer-events: auto; overflow-wrap: anywhere; animation: toast-in 160ms ease-out; }
.toast[data-state="error"] { border-inline-start-color: var(--danger); }
.toast[data-state="success"] { border-inline-start-color: var(--success); }
.toast .icon-button { flex: none; font-size: 1.3rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.app-dialog { width: min(480px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: clamp(18px, 4vw, 25px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 22px 74px #1511236b; overflow: auto; }
.app-dialog::backdrop { background: #1510208c; }
.app-dialog h2 { font-size: 1.32rem; letter-spacing: -.02em; }
.app-dialog p { color: var(--muted); line-height: 1.5; }
.app-dialog .invite-code, .app-dialog .invitation-note { margin-bottom: 0; }
.button.danger-text { color: var(--danger); }
.storage-settings > a { display: inline-flex; }
.settings-grid small { color: var(--muted); font-size: .78rem; font-weight: 400; line-height: 1.35; }
.errorlist { margin: 0; padding-left: 17px; font-size: .88rem; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .sidebar { padding-inline: 13px; }
  .paper-art { right: 10px; }
  .docs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; display: block; padding: 12px 18px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar > .brand { margin: 0 0 8px; }
  .nav-caption, .account-name, .account .avatar { display: none; }
  .side-main { flex-direction: row; align-items: center; gap: 3px; overflow: visible; }
  .side-nav, .side-bottom { display: flex; align-items: center; gap: 3px; }
  .side-nav { flex-wrap: wrap; }
  .side-bottom > .side-legal { display: none; }
  .mobile-legal { display: flex; margin-top: 28px; }
  .theme-toggle span { display: none; }
  .theme-toggle { width: auto; }
  .side-link { min-height: 36px; font-size: .82rem; gap: 5px; padding: 6px; }
  .side-link .icon { width: 15px; height: 15px; }
  .account { border: 0; padding: 0; }
  .account .icon-button { width: 31px; }
  .workspace { padding: 22px 18px 32px; }
  .editor-grid { grid-template-columns: 1fr; }
  .split-button { display: none; }
  .auth-visual .paper-art { transform: translate(-50%, -56%) scale(.92); }
}
@media (min-width: 851px) { .mobile-legal { display: none; } }
@media (max-width: 640px) {
  .page-head { align-items: flex-start; flex-direction: column; gap: 13px; margin-bottom: 18px; }
  .hero { min-height: 236px; }
  .hero-copy { max-width: 77%; padding: 21px 18px; }
  .hero-copy h2 { font-size: clamp(2rem, 9vw, 3rem); }
  .hero-copy p { font-size: .89rem; }
  .hero-button { font-size: .79rem; white-space: normal; }
  .hero .paper-art { right: -100px; transform: translateY(-52%) scale(.54); opacity: .75; }
  .library { margin-top: 23px; }
  .library-heading { flex-wrap: wrap; }
  .library-filters { width: 100%; }
  .searchbox { flex: 1; }
  .docs { gap: 10px; }
  .empty-start { flex-wrap: wrap; padding: 13px; gap: 10px; }
  .empty-start div { min-width: 170px; }
  .editor-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .editor-actions { justify-content: flex-start; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .auth-visual { display: none; }
}
@media (max-width: 410px) {
  .sidebar { padding-inline: 10px; }
  .side-nav > a { gap: 4px; font-size: .77rem; }
  .side-nav > a .icon { display: none; }
  .docs { grid-template-columns: minmax(0, 1fr); }
  .hero .paper-art { right: -129px; opacity: .63; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
  .toast { animation: none; }
}
