:root {
  --bg: #f3eee4;
  --canvas: #fbf8f2;
  --surface: #fffdf8;
  --surface-2: #eadfce;
  --text: #3b332d;
  --muted: #665b52;
  --quiet: #6f6258;
  --accent: #a94f35;
  --accent-strong: #873b29;
  --accent-text: #ffffff;
  --line: #d5c7b8;
  --line-soft: color-mix(in srgb, var(--line) 62%, transparent);
  --danger: #a33d47;
  --gold: #d69a43;
  --green: #7e9f7b;
  --sage: #91a98f;
  --teal: #5f8f89;
  --sun: #f2c66d;
  --app-height: 100dvh;
  --viewport-top: 0px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px), var(--tg-content-safe-area-inset-left, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px), var(--tg-content-safe-area-inset-right, 0px));
  font-family: "Avenir Next", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body { min-height: var(--app-height); font-size: 15px; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select, [contenteditable="plaintext-only"] { font-size: 16px; }
button { min-width: 44px; min-height: 44px; border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .58; box-shadow: none !important; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [contenteditable="plaintext-only"]:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; }
.format-pills input:focus-visible + span, .revision-change input:focus-visible + .revision-check { outline: 3px solid var(--accent-strong); outline-offset: 3px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.access-gate { width: 100%; min-height: 100%; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 50% 18%, #f1bd7b38, transparent 30%), var(--bg); }
.access-card { width: min(100%, 420px); padding: 34px 28px; text-align: center; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: 0 20px 60px #4d37221a; }
.access-mark { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 22px; border-radius: 18px; color: #fff; background: var(--accent-strong); font-size: 24px; font-weight: 760; }
.access-card .eyebrow { margin-bottom: 12px; }
.access-card h1 { font-size: 30px; }
.access-card > p:last-child { margin: 16px auto 0; max-width: 290px; color: var(--muted); line-height: 1.55; }

.app-shell { width: 100%; min-width: 0; height: var(--app-height); transform: translateY(var(--viewport-top)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: radial-gradient(circle at 92% 2%, #f1bd7b2e, transparent 24%), radial-gradient(circle at -7% 21%, #8fb4a82b, transparent 30%), var(--bg); isolation: isolate; }
.app-shell::before { content: ""; position: fixed; z-index: -1; inset: 0; pointer-events: none; opacity: .22; background: radial-gradient(circle at 11% 14%, #fff 0 1px, transparent 2px), radial-gradient(circle at 76% 23%, #cfaa7b 0 1px, transparent 2px); background-size: 46px 46px, 68px 68px; mask-image: linear-gradient(to bottom, #000, transparent 42%); }
.topbar { min-height: calc(92px + var(--safe-top)); padding: calc(17px + var(--safe-top)) max(20px, var(--safe-right)) 12px max(20px, var(--safe-left)); display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.title-lockup { min-width: 0; }
.eyebrow { margin: 0 0 8px; color: var(--accent-strong); font-size: 9px; line-height: 1; letter-spacing: .19em; font-weight: 760; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: 31px; line-height: 1; font-weight: 760; }
h2 { font-size: 26px; font-weight: 740; }
.view-summary { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.2; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--text); }
.icon-button.primary { display: grid; background: var(--accent); color: var(--accent-text); border-color: transparent; box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 28%, transparent); }
.workspace { min-width: 0; min-height: 0; overflow: hidden; }
.view { display: none; width: 100%; min-width: 0; height: 100%; }
.view.active { display: block; animation: view-arrive .32s cubic-bezier(.2,.8,.2,1) both; }
.view-scroll { width: 100%; min-width: 0; height: 100%; overflow-x: hidden; overflow-y: auto; touch-action: pan-y pinch-zoom; padding-bottom: 120px; }
.view-scroll, .editor-scroll, .message-scroll, .sheet-card { scrollbar-width: none; }
.view-scroll::-webkit-scrollbar, .editor-scroll::-webkit-scrollbar, .message-scroll::-webkit-scrollbar, .sheet-card::-webkit-scrollbar { display: none; }

.studio-hero { position: relative; min-height: 128px; margin: 2px max(20px, var(--safe-right)) 14px max(20px, var(--safe-left)); overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(112px, .78fr); border: 1px solid #ffffff8c; border-radius: 30px 30px 30px 12px; background: linear-gradient(135deg, #f7cdb7 0%, #ef9f7d 48%, #d97b61 100%); box-shadow: 0 22px 48px #b8735528, inset 0 1px #ffffff9e; isolation: isolate; animation: hero-arrive .52s cubic-bezier(.16,1,.3,1) both; }
.studio-hero::before { content: ""; position: absolute; left: -42px; bottom: -60px; width: 160px; height: 120px; border-radius: 50%; background: #f5d78e99; transform: rotate(18deg); }
.studio-hero::after { content: ""; position: absolute; top: -54px; right: 74px; width: 108px; height: 108px; border: 1px solid #fff7; border-radius: 50%; }
.hero-copy { position: relative; z-index: 3; align-self: center; padding: 21px 0 20px 20px; }
.hero-label { display: block; margin-bottom: 9px; color: #704738; font-size: 8px; font-weight: 780; letter-spacing: .17em; }
.hero-copy strong { display: block; color: #49332b; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 22px; line-height: 1.02; font-weight: 600; letter-spacing: -.025em; }
.hero-copy p { margin: 10px 0 0; color: #704d40; font-size: 9px; line-height: 1.35; }
.hero-copy p span { font-weight: 760; }
.hero-art { position: relative; z-index: 2; min-width: 0; }
.hero-orbit { position: absolute; width: 124px; height: 124px; top: 14px; right: 6px; border: 1px solid #fff8; border-radius: 50%; animation: orbit-breathe 5s ease-in-out infinite; }
.hero-page { position: absolute; display: grid; align-content: start; gap: 7px; padding: 14px 12px; border: 1px solid #fff; background: #fffaf0; box-shadow: 0 13px 30px #7a3d2c2d; }
.hero-page i { display: block; height: 2px; border-radius: 2px; background: #d9cfc1; }
.hero-page i:nth-of-type(2) { width: 72%; }
.hero-page i:nth-of-type(3) { width: 88%; }
.hero-page-back { width: 82px; height: 104px; top: 22px; right: 47px; border-radius: 12px 12px 18px 12px; transform: rotate(-12deg); background: #dfe9dc; }
.hero-page-front { width: 88px; height: 110px; top: 30px; right: 14px; border-radius: 14px 14px 14px 23px; transform: rotate(9deg); animation: page-float 4.6s ease-in-out infinite; }
.hero-page-front b { margin-bottom: 3px; color: var(--teal); font: 600 21px "Iowan Old Style", Georgia, serif; }
.hero-marker { position: absolute; z-index: 4; width: 14px; height: 88px; top: 50px; right: 100px; border-radius: 8px 8px 4px 4px; background: #5f8f89; box-shadow: 0 8px 18px #365d5938; transform: rotate(36deg); animation: marker-float 4.2s ease-in-out infinite; }
.hero-marker::before { content: ""; position: absolute; left: 2px; right: 2px; top: 7px; height: 18px; border-radius: 4px; background: #f2c66d; }
.hero-marker i { position: absolute; left: 3px; right: 3px; bottom: -8px; height: 12px; clip-path: polygon(0 0, 100% 0, 50% 100%); background: #e8d7bd; }
.hero-dot { position: absolute; z-index: 5; border-radius: 50%; background: var(--sun); box-shadow: 0 4px 12px #926b3340; }
.hero-dot-one { width: 10px; height: 10px; top: 18px; right: 18px; }
.hero-dot-two { width: 6px; height: 6px; bottom: 18px; right: 119px; background: #fff5db; }

.search-wrap { padding: 0 max(20px, var(--safe-right)) 14px max(20px, var(--safe-left)); }
.search-field { height: 48px; padding: 0 14px; display: flex; align-items: center; gap: 10px; border: 1px solid #e5d8ca; border-radius: 17px; background: #fffaf4d9; color: var(--muted); box-shadow: 0 10px 28px #886c5120, inset 0 1px #ffffff; backdrop-filter: blur(12px); }
.search-field span { font-family: Georgia, serif; font-size: 19px; transform: rotate(-18deg); }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }
.search-field:focus-within { border-color: color-mix(in srgb, var(--accent) 54%, var(--line)); background: var(--surface); }
.stage-rail { width: 100%; min-width: 0; display: flex; gap: 8px; padding: 0 max(20px, var(--safe-right)) 18px max(20px, var(--safe-left)); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.stage-rail::-webkit-scrollbar, .quick-prompts::-webkit-scrollbar, .format-pills::-webkit-scrollbar { display: none; }
.stage { flex: 0 0 auto; height: 40px; min-height: 40px; display: flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid transparent; border-radius: 20px; background: #fffaf061; color: var(--muted); font-size: 11px; transition: color .2s ease, background .2s ease, transform .2s ease; }
.stage i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 10%, transparent); }
.stage b { min-width: 18px; height: 18px; display: grid; place-items: center; border-radius: 9px; background: color-mix(in srgb, var(--text) 6%, transparent); font-size: 9px; }
.stage.active { color: #6d3b2c; background: #f1b79e; border-color: #e9a98f; box-shadow: 0 9px 22px #b66e5225, inset 0 1px #ffffff91; }
.stage[data-status="inbox"] i { color: var(--gold); }
.stage[data-status="selected"] i { color: var(--accent-strong); }
.stage[data-status="ready"] i { color: var(--green); }
.stage[data-status="published"] i { color: var(--muted); }
.section-heading { min-height: 38px; padding: 0 max(22px, var(--safe-right)) 8px max(22px, var(--safe-left)); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 9px; letter-spacing: .17em; text-transform: uppercase; font-weight: 730; }
.text-button { padding: 0 8px; background: transparent; color: var(--accent-strong); font-size: 11px; }

.materials-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 0 max(20px, var(--safe-right)) 24px max(20px, var(--safe-left)); }
.plan-list { display: grid; gap: 0; padding: 0 max(20px, var(--safe-right)) 24px max(20px, var(--safe-left)); }
.material-card { position: relative; width: 100%; min-width: 0; padding: 0; overflow: hidden; text-align: left; border: 1px solid #e8dbcd; border-radius: 26px 26px 26px 12px; background: var(--surface); box-shadow: 0 17px 40px #82694e1e, inset 0 1px #ffffff; transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease, border-color .2s ease; animation: card-arrive .42s cubic-bezier(.16,1,.3,1) both; }
.material-card:nth-child(2) { animation-delay: .05s; }
.material-card:nth-child(3) { animation-delay: .1s; }
.material-card:nth-child(4) { animation-delay: .15s; }
.material-card:active { transform: scale(.975) rotate(-.35deg); border-color: #e4a48b; box-shadow: 0 8px 22px #82694e20; }
.material-card:only-child { grid-column: 1 / -1; min-height: 158px; display: grid; grid-template-columns: 35% 65%; }
.material-card:only-child .card-art { height: 100%; min-height: 158px; }
.material-card:only-child .card-art::before { left: 20px; top: 37px; }
.material-card:only-child .card-content { align-self: center; padding: 20px 17px; }
.material-card:only-child h3 { min-height: auto; font-size: 19px; }
.material-card:only-child p { max-width: 165px; -webkit-line-clamp: 3; font-size: 12px; }
.card-art { position: relative; height: 112px; display: block; overflow: hidden; background: linear-gradient(145deg, #dce8db, #aac2ae); }
.card-art::before { content: ""; position: absolute; width: 84px; height: 105px; left: 25px; top: 20px; border: 1px solid #ffffffd1; border-radius: 12px 12px 20px 12px; background: repeating-linear-gradient(to bottom, #fffaf1 0 13px, #d9d0c2 14px 15px); box-shadow: 0 12px 24px #5b725c2c; transform: rotate(-9deg); }
.card-art::after { content: ""; position: absolute; width: 72px; height: 72px; right: -18px; bottom: -20px; border-radius: 50%; border: 12px solid #f3c66d99; }
.card-art > span { position: absolute; z-index: 2; right: 11px; top: 10px; width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid #ffffffc4; border-radius: 50%; background: #fff9e4c9; color: #5f7563; font: 700 11px "Avenir Next", sans-serif; box-shadow: 0 6px 16px #5f68552b; backdrop-filter: blur(8px); }
.material-card[data-format="reel"] .card-art { background: linear-gradient(145deg, #f4c4ae, #e78968); }
.material-card[data-format="reel"] .card-art::before { background: linear-gradient(#fff9ef, #f8e2d8); transform: rotate(8deg); }
.material-card[data-format="reel"] .card-art::after { border-color: #7ea29e8f; }
.material-card[data-format="carousel"] .card-art { background: linear-gradient(145deg, #c3dcda, #76a8a3); }
.material-card[data-format="carousel"] .card-art::before { box-shadow: 12px 9px 0 #e9c3aa, 0 12px 24px #4f77722c; }
.material-card[data-format="carousel"] .card-art::after { border-color: #f3cf7fba; }
.material-card[data-format="post"] .card-art { background: linear-gradient(145deg, #f3dca6, #d8aa5e); }
.material-card[data-format="post"] .card-art::before { background: repeating-linear-gradient(to bottom, #fffaf0 0 12px, #d7c8ad 13px 14px); }
.material-card[data-format="post"] .card-art::after { border-color: #d97e6182; }
.material-card[data-format="story"] .card-art { background: linear-gradient(145deg, #d8c6d9, #a584a5); }
.material-card[data-format="story"] .card-art::before { transform: rotate(-2deg); background: linear-gradient(150deg, #fff8ed, #f0ddd1); }
.material-card[data-format="story"] .card-art::after { border-color: #7fa6a0a6; }
.material-card[data-stage="selected"] .card-art { box-shadow: inset 0 3px var(--accent-strong); }
.material-card[data-stage="ready"] .card-art { box-shadow: inset 0 3px var(--green); }
.material-card[data-stage="published"] .card-art { filter: saturate(.55); }
.card-content { min-width: 0; display: block; padding: 13px 13px 15px; }
.card-kicker { display: flex; min-width: 0; gap: 5px; margin-bottom: 8px; color: var(--accent-strong); font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.card-kicker span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-kicker span:last-child { margin-left: auto; color: var(--muted); }
.material-card h3 { margin: 0 0 7px; min-height: 39px; font-size: 16px; line-height: 1.2; font-weight: 720; letter-spacing: -.018em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.material-card p { margin: 0; color: color-mix(in srgb, var(--text) 58%, var(--muted)); font-size: 11px; line-height: 1.42; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-arrow { position: absolute; z-index: 3; right: 10px; bottom: 9px; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #f6f7f3; color: var(--muted); font-size: 11px; }
.materials-list > .empty-state { grid-column: 1 / -1; }
.empty-state { position: relative; margin: 12px 0; padding: 46px 24px 42px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); text-align: center; color: var(--muted); }
.empty-state::before { content: ""; display: block; width: 2px; height: 32px; margin: 0 auto 18px; background: var(--gold); box-shadow: 0 0 20px color-mix(in srgb, var(--gold) 38%, transparent); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 19px; font-weight: 730; }
.empty-state p { max-width: 270px; margin: 0 auto; line-height: 1.55; font-size: 13px; }

.intro-card { margin: 0 max(20px, var(--safe-right)) 16px max(20px, var(--safe-left)); padding: 18px 0; display: flex; gap: 14px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); background: transparent; }
.intro-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); font-size: 18px; }
.intro-card strong { display: block; margin-bottom: 4px; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 17px; }
.intro-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.empty-action { margin-top: 4px; padding: 0 18px; min-width: 156px; }
.plan-card { width: 100%; display: grid; grid-template-columns: 52px 1fr 20px; gap: 12px; align-items: center; padding: 16px 4px; text-align: left; border: 0; border-top: 1px solid var(--line-soft); border-radius: 0; background: transparent; }
.plan-card:last-child { border-bottom: 1px solid var(--line-soft); }
.plan-date { text-align: center; color: var(--gold); }
.plan-date strong { display: block; font-family: "Iowan Old Style", Georgia, serif; font-size: 24px; line-height: 1; font-weight: 600; }
.plan-date small { font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
.plan-copy strong { display: block; margin-bottom: 4px; font-family: "Iowan Old Style", Georgia, serif; font-size: 16px; }
.plan-copy small { color: var(--muted); }

.capture-fab { position: fixed; z-index: 20; right: max(20px, var(--safe-right)); bottom: calc(88px + var(--safe-bottom)); height: 50px; padding: 0 18px; display: none; align-items: center; gap: 8px; border: 1px solid #ef9c7e; border-radius: 25px 25px 25px 10px; background: linear-gradient(135deg, #ee9b79, var(--accent)); color: #fffaf3; font-size: 13px; font-weight: 740; box-shadow: 0 16px 36px #b5664936, inset 0 1px #ffffff70; transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease; animation: fab-arrive .46s .18s cubic-bezier(.16,1,.3,1) both; }
.capture-fab:active { transform: scale(.96); box-shadow: 0 8px 20px #b5664930; }
.capture-fab span { font-size: 18px; font-weight: 400; }
.bottom-nav { min-height: calc(66px + var(--safe-bottom)); margin: 0 max(16px, var(--safe-right)) calc(10px + var(--safe-bottom)) max(16px, var(--safe-left)); padding: 5px 12px; display: flex; justify-content: space-around; border: 1px solid #e0d3c5; border-radius: 34px 34px 34px 16px; background: #fffaf0e8; box-shadow: 0 18px 44px #846b5026, inset 0 1px #ffffff; backdrop-filter: blur(18px) saturate(125%); }
.nav-item { position: relative; min-width: 82px; display: grid; place-items: center; align-content: center; gap: 4px; border-radius: 24px; background: transparent; color: #6f6258; transition: color .2s ease, background .2s ease, transform .2s ease; }
.nav-item::after { content: ""; position: absolute; top: 8px; width: 34px; height: 34px; z-index: -1; border-radius: 14px 14px 14px 7px; background: transparent; transform: scale(.7) rotate(-5deg); transition: background .22s ease, transform .28s cubic-bezier(.16,1,.3,1); }
.nav-item small { font-size: 9px; letter-spacing: .02em; }
.nav-icon { width: 23px; height: 23px; display: grid; place-items: center; }
.nav-icon svg { width: 22px; height: 22px; }
.nav-item.active { color: #8a4936; transform: translateY(-1px); }
.nav-item.active::after { background: #f2c1ab; transform: scale(1) rotate(-5deg); box-shadow: 0 6px 16px #b8735725, inset 0 1px #ffffff9e; }
.nav-item.active .nav-icon { animation: nav-pop .34s cubic-bezier(.16,1,.3,1); }
.nav-hermes, .hermes-glyph { display: grid; place-items: center; border: 1px solid currentColor; font-family: "Iowan Old Style", Georgia, serif; font-weight: 600; }
.nav-hermes { border-radius: 7px; font-size: 12px; }

.chat-layout { height: 100%; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0 max(16px, var(--safe-right)) 10px max(16px, var(--safe-left)); }
.assistant-identity, .assistant-context { display: flex; align-items: center; gap: 12px; padding: 9px 4px 14px; border-bottom: 1px solid var(--line-soft); }
.hermes-glyph { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 14px 14px 14px 7px; color: #4f7772; background: #dce9e4; box-shadow: inset 0 1px #ffffffa8, 0 7px 18px #56766f18; }
.assistant-identity strong, .assistant-context strong { display: block; margin-bottom: 2px; font-family: "Iowan Old Style", Georgia, serif; font-size: 17px; font-weight: 600; }
.assistant-identity small, .assistant-context small { color: var(--muted); font-size: 11px; }
.message-scroll { min-height: 0; overflow-y: auto; touch-action: pan-y pinch-zoom; display: grid; align-content: start; gap: 10px; padding: 15px 3px; }
.message { max-width: 91%; padding: 12px 14px; border-radius: 16px; white-space: pre-wrap; line-height: 1.5; }
.message.user { justify-self: end; background: #e9a98f; color: #55382e; border-bottom-right-radius: 5px; box-shadow: 0 8px 24px #a7614720; }
.message.assistant { justify-self: start; background: var(--surface); border: 1px solid var(--line-soft); border-bottom-left-radius: 5px; }
.message-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; white-space: normal; }
.message-actions button { height: 42px; min-height: 42px; padding: 0 12px; border-radius: 12px; font-size: 10px; font-weight: 720; }
.review-answer { background: #e9a98f; color: #55382e; box-shadow: inset 0 1px #ffffff8f; }
.copy-answer { border: 1px solid var(--line); background: #fff8ee; color: var(--accent-strong); }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: end; gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 20px 20px 20px 9px; background: var(--surface); box-shadow: 0 12px 34px #80674d20, inset 0 1px #ffffff; }
.composer textarea { width: 100%; max-height: 104px; resize: none; overflow-y: auto; padding: 8px; border: 0; outline: 0; background: transparent; line-height: 1.35; }
.composer button { width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: var(--accent-text); font-size: 20px; box-shadow: inset 0 1px #ffffff2c; }

.editor-screen { position: fixed; z-index: 60; inset: var(--viewport-top) 0 auto; height: var(--app-height); display: grid; grid-template-rows: auto auto minmax(0, 1fr); background: linear-gradient(90deg, #e9a68714, transparent 52px), var(--canvas); animation: editor-arrive .34s cubic-bezier(.2,.8,.2,1) both; }
.editor-topbar { min-height: calc(68px + var(--safe-top)); padding: calc(11px + var(--safe-top)) max(14px, var(--safe-right)) 11px max(14px, var(--safe-left)); display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 11px; border-bottom: 1px solid var(--line-soft); }
.editor-state { min-width: 0; }
.editor-state span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); font-size: 10px; font-weight: 740; letter-spacing: .1em; text-transform: uppercase; }
.editor-state small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.done-button { height: 42px; min-height: 42px; padding: 0 15px; border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent); border-radius: 21px; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent-strong); font-size: 11px; font-weight: 750; }
.editor-modes { height: 52px; display: grid; grid-template-columns: 1fr 1fr; padding: 4px 18px 0; }
.editor-modes button { position: relative; background: transparent; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; font-weight: 720; letter-spacing: .03em; }
.editor-modes button::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: -1px; height: 2px; background: transparent; }
.editor-modes button.active { color: var(--text); }
.editor-modes button.active::after { background: var(--accent-strong); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); }
.editor-content { min-height: 0; }
.editor-pane { display: none; height: 100%; min-height: 0; }
.editor-pane.active { display: block; }
.text-pane { min-height: 0; }
.editor-scroll { height: 100%; min-height: 0; overflow-y: auto; touch-action: pan-y pinch-zoom; padding: 19px max(22px, var(--safe-right)) calc(34px + var(--safe-bottom)) max(34px, calc(var(--safe-left) + 14px)); }
.document-head { position: relative; }
.document-head::before { content: ""; position: absolute; left: -15px; top: 2px; bottom: -34px; width: 2px; border-radius: 2px; background: var(--gold); box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 30%, transparent); }
.title-editor { width: 100%; min-height: 60px; padding: 0 0 14px; border: 0; border-bottom: 1px solid var(--line-soft); outline: 0; background: transparent; color: var(--text); font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 29px; line-height: 1.13; font-weight: 600; letter-spacing: -.025em; }
.document-rule { min-height: 38px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .13em; }
.editor-body { min-height: 56vh; overflow: visible; padding: 12px 1px 36px; white-space: pre-wrap; overflow-wrap: anywhere; color: color-mix(in srgb, var(--text) 94%, #fff); font-size: 17px; line-height: 1.72; outline: 0; caret-color: var(--accent-strong); }
.editor-body:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.metadata { margin-top: 10px; border: 1px solid var(--line-soft); border-radius: 16px; background: color-mix(in srgb, var(--surface) 82%, transparent); }
.metadata summary { min-height: 56px; padding: 12px 15px; display: flex; flex-direction: column; justify-content: center; cursor: pointer; list-style: none; }
.metadata summary::-webkit-details-marker { display: none; }
.metadata summary span { font-size: 12px; font-weight: 720; }
.metadata summary small { margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .03em; }
.metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 12px 12px; }
.metadata-grid label, .metadata-field { display: grid; gap: 6px; color: var(--muted); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.metadata-grid input, .metadata-grid select, .tag-trigger { width: 100%; min-width: 0; height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: var(--canvas); }
.tag-trigger { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: var(--text); text-align: left; text-transform: none; letter-spacing: 0; }
.tag-trigger > span { min-width: 0; display: flex; gap: 5px; overflow: hidden; }
.tag-trigger i { flex: 0 0 auto; max-width: 96px; overflow: hidden; padding: 4px 7px; border-radius: 11px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); font-size: 10px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.tag-trigger em { color: var(--muted); font-size: 12px; font-style: normal; }
.tag-trigger b { flex: 0 0 auto; color: var(--accent-strong); font-size: 19px; font-weight: 500; }
.danger-button { width: calc(100% - 24px); margin: 0 12px 12px; border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent); border-radius: 12px; background: transparent; color: var(--danger); font-size: 11px; }
.editor-tail { padding: 24px 0 7px; text-align: center; color: var(--quiet); font: italic 12px "Iowan Old Style", Georgia, serif; }
.assistant-pane.active { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; padding: 0 max(16px, var(--safe-right)) calc(9px + var(--safe-bottom)) max(16px, var(--safe-left)); }
.quick-prompts { display: flex; gap: 8px; padding: 10px 0; overflow-x: auto; }
.quick-prompts button { flex: 0 0 auto; padding: 0 12px; border: 1px solid var(--line); border-radius: 20px; background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--muted); font-size: 10px; }

.sheet { position: fixed; z-index: 80; inset: 0; height: var(--app-height); transform: translateY(var(--viewport-top)); display: grid; align-items: end; }
.sheet-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; background: #59483e80; backdrop-filter: blur(7px); animation: backdrop-in .2s ease both; }
.sheet-card { position: relative; width: 100%; max-height: calc(var(--app-height) - 8px); overflow-y: auto; touch-action: pan-y pinch-zoom; padding: 8px max(20px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(20px, var(--safe-left)); border: 1px solid var(--line); border-bottom: 0; border-radius: 30px 30px 0 0; background: linear-gradient(180deg, #f8d7c754, transparent 140px), var(--surface); box-shadow: 0 -24px 70px #5e493b38; animation: sheet-rise .38s cubic-bezier(.16,1,.3,1) both; }
.sheet-card.compact { padding-top: 24px; }
.sheet-handle { width: 40px; height: 3px; margin: 0 auto 18px; border-radius: 4px; background: var(--line); }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.capture-field { display: grid; gap: 9px; color: var(--muted); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.capture-field textarea { width: 100%; resize: none; padding: 16px; border: 1px solid var(--line); border-radius: 16px; outline: 0; background: var(--canvas); line-height: 1.58; text-transform: none; letter-spacing: 0; box-shadow: inset 0 1px #ffffff07; }
.capture-field textarea:focus { border-color: color-mix(in srgb, var(--accent) 54%, var(--line)); }
.format-pills { display: flex; gap: 8px; margin: 18px 0; padding: 0; border: 0; overflow-x: auto; }
.format-pills legend { width: 100%; margin-bottom: 8px; color: var(--muted); font-size: 9px; letter-spacing: .11em; text-transform: uppercase; }
.format-pills label { flex: 0 0 auto; }
.format-pills input { position: absolute; opacity: 0; pointer-events: none; }
.format-pills span { height: 42px; padding: 0 13px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 21px; color: var(--muted); font-size: 11px; }
.format-pills input:checked + span { background: color-mix(in srgb, var(--accent) 11%, transparent); border-color: color-mix(in srgb, var(--accent) 62%, var(--line)); color: var(--text); }
.tags-card { max-height: min(var(--app-height), 640px); }
.tags-help { margin: -8px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.tag-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.tag-option { min-width: 0; height: 48px; padding: 0 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); border-radius: 16px 16px 16px 7px; background: var(--canvas); color: var(--text); text-align: left; }
.tag-option span { min-width: 0; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.tag-option b { flex: 0 0 auto; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent-strong); font-size: 12px; }
.tag-option.selected { border-color: color-mix(in srgb, var(--accent) 65%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.tag-option.selected b { background: var(--accent); color: #fff; }
.add-tag-button { height: 46px; margin-top: 14px; }
.new-tag-form { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--canvas) 90%, transparent); }
.new-tag-form > label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 9px; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
.new-tag-form > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.new-tag-form input { min-width: 0; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.new-tag-form .primary-button { width: auto; height: 46px; padding: 0 16px; box-shadow: none; }
.tags-done { margin-top: 14px; }
.primary-button, .secondary-button, .destructive-button { width: 100%; height: 50px; border-radius: 25px; font-size: 12px; font-weight: 750; }
.primary-button { background: var(--accent); color: var(--accent-text); box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 24%, transparent), inset 0 1px #ffffff2c; }
.confirm-copy { color: var(--muted); line-height: 1.55; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.conflict-actions { display: grid; gap: 10px; margin-top: 18px; }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.destructive-button { background: var(--danger); color: #fff; }
.danger-text { color: var(--danger); }
.revision-card { padding-top: 8px; }
.revision-summary { margin: -4px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.revision-list { max-height: min(43vh, 390px); overflow-y: auto; display: grid; gap: 10px; padding: 2px 1px 12px; scrollbar-width: none; }
.revision-list::-webkit-scrollbar { display: none; }
.revision-change { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 7px 9px; padding: 13px; border: 1px solid var(--line); border-radius: 18px 18px 18px 8px; background: #fffbf5; transition: opacity .18s ease, border-color .18s ease; }
.revision-change input { position: absolute; opacity: 0; pointer-events: none; }
.revision-check { grid-row: 1; width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid #df9e84; border-radius: 8px 8px 8px 4px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; }
.revision-number { align-self: center; color: var(--text); font-size: 11px; font-weight: 760; }
.revision-before, .revision-after { grid-column: 1 / -1; display: grid; gap: 5px; padding: 10px 11px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; }
.revision-before { background: #f7e5df; color: #765247; }
.revision-after { background: #e6efe4; color: #456044; }
.revision-before small, .revision-after small { font-size: 8px; font-weight: 780; letter-spacing: .12em; text-transform: uppercase; opacity: .72; }
.revision-change:has(input:not(:checked)) { opacity: .48; border-style: dashed; }
.revision-change:has(input:not(:checked)) .revision-check { background: transparent; color: transparent; }
.revision-empty { padding: 22px 16px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.5; }
.revision-insert { margin: 4px 0 13px; padding: 13px; border-radius: 16px; background: #f2eadf; }
.revision-insert > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 9px; font-weight: 730; letter-spacing: .07em; text-transform: uppercase; }
.revision-insert > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.revision-insert .secondary-button { height: 44px; }
#apply-revision:disabled { opacity: .42; box-shadow: none; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(88px + var(--safe-bottom)); max-width: calc(100% - 40px); transform: translate(-50%, 12px) scale(.97); padding: 10px 10px 10px 15px; display: flex; align-items: center; gap: 10px; border: 1px solid #d6c5b6; border-radius: 20px 20px 20px 9px; background: #fff8ec; color: var(--text); font-size: 11px; font-weight: 720; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .28s cubic-bezier(.16,1,.3,1); box-shadow: 0 14px 38px #765d4730; }
.toast button { min-width: auto; min-height: 36px; padding: 0 10px; border-radius: 12px; background: #e9a98f; color: #55382e; font-size: 10px; font-weight: 780; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
body.keyboard-active .bottom-nav, body.keyboard-active .capture-fab { visibility: hidden; }

@keyframes view-arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes hero-arrive { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes card-arrive { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fab-arrive { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes sheet-rise { from { opacity: .7; transform: translateY(34px); } to { opacity: 1; transform: translateY(0); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes editor-arrive { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes nav-pop { 0% { transform: translateY(2px) scale(.86); } 70% { transform: translateY(-1px) scale(1.08); } 100% { transform: translateY(0) scale(1); } }
@keyframes page-float { 0%, 100% { transform: rotate(9deg) translateY(0); } 50% { transform: rotate(7deg) translateY(-4px); } }
@keyframes marker-float { 0%, 100% { transform: rotate(36deg) translateY(0); } 50% { transform: rotate(34deg) translateY(-3px); } }
@keyframes orbit-breathe { 0%, 100% { transform: scale(1); opacity: .72; } 50% { transform: scale(1.035); opacity: 1; } }

@media (hover: hover) {
  .material-card:hover { transform: translateY(-3px); box-shadow: 0 22px 48px #82694e27; }
  .capture-fab:hover { transform: translateY(-2px); box-shadow: 0 19px 40px #b5664940; }
  .stage:hover { transform: translateY(-1px); }
}

@media (min-width: 760px) and (min-height: 600px) {
  .app-shell { max-width: 1180px; margin: 0 auto; border-left: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
  .topbar { padding-left: 34px; padding-right: 34px; }
  .icon-button.primary { display: grid; }
  .materials-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .bottom-nav { position: fixed; left: 50%; bottom: 18px; width: 360px; min-height: 62px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 31px; padding: 5px 16px; }
  .nav-item::after { top: -6px; }
  .capture-fab { right: 30px; bottom: 28px; }
  .editor-screen { padding: 30px; background: #5d4c43c7; }
  .editor-topbar, .editor-content { width: min(1120px, 100%); margin: 0 auto; background: var(--bg); }
  .editor-topbar { border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; padding: 11px 16px; min-height: 68px; }
  .editor-modes { display: none; }
  .editor-content { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .75fr); min-height: 0; border: 1px solid var(--line); border-radius: 0 0 24px 24px; overflow: hidden; background: var(--bg); }
  .editor-pane, .editor-pane.active { display: block; }
  .text-pane { border-right: 1px solid var(--line); }
  .assistant-pane, .assistant-pane.active { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; padding: 0 16px 12px; }
  .sheet-card { max-width: 620px; margin: 0 auto; border-radius: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
