/* The Grey Swan Studio: the site's dark style for the frame, a calm page to write on */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 18px; border-radius: 999px;
  border: 1px solid #3A352D; background: transparent; color: var(--ink); font: inherit; font-size: 0.92rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--gold); }
.btn:focus-visible, .link-btn:focus-visible, .tool:focus-visible, .choice:focus-visible, .oi:focus-visible, .ptab:focus-visible, .note-go:focus-visible, .note-fix:focus-visible, .paper-open:focus-visible, .input:focus-visible, .tool-select:focus-visible { outline: 2px solid #E2B885; outline-offset: 2px; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #141517; font-weight: 500; }
.btn-gold:hover { background: #E2B885; border-color: #E2B885; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-small { min-height: 34px; padding: 0 13px; font-size: 0.85rem; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 2px solid #E2B885; outline-offset: 2px; }
.link-btn { background: none; border: 0; padding: 8px 4px; color: var(--muted); font: inherit; font-size: 0.92rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }
.input { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--ink); font: inherit; font-size: 1rem; }
.input:focus { border-color: var(--gold); outline: none; }
.status { color: var(--muted); font-size: 0.88rem; }

/* header */
.studio-head { max-width: 1440px; margin: 0 auto; padding: 16px 28px 0; }
.studio-head-row { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; }
.studio-brand { display: flex; align-items: center; gap: 12px; margin-right: auto; color: #E2B885; text-decoration: none; font-family: var(--caps); letter-spacing: 3px; font-size: 0.95rem; }
.studio-brand img { width: 40px; height: auto; }
.studio-nav { display: flex; flex-wrap: wrap; gap: 22px; font-size: 0.92rem; }
.studio-nav a { color: var(--ink); text-decoration: none; }
.studio-nav a[aria-current] { color: #E2B885; }
.studio-tabs { margin: 10px 0 0; }
.masthead-account { margin-left: 0; }

/* home */
.studio-home, .studio-setup { max-width: 860px; margin: 0 auto; padding: 40px 28px 72px; }
.home-h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2.2rem, 5vw, 3.2rem); margin: 10px 0 8px; }
.home-lead { color: var(--muted); font-size: 1.05rem; line-height: 1.65; max-width: 680px; margin: 0; }
.home-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 26px 0 36px; }
.home-h2 { font-family: var(--caps); font-weight: 400; color: var(--gold); letter-spacing: 3px; font-size: 0.85rem; text-transform: uppercase; margin: 0 0 12px; }
.papers { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.paper-card { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px 4px 4px; }
.paper-card:hover { border-color: #4A4035; }
.paper-open { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: none; border: 0; color: var(--ink); font: inherit; padding: 14px 16px; cursor: pointer; border-radius: 10px; }
.paper-kind { font-size: 0.75rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); }
.paper-title { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; line-height: 1.2; }
.paper-when { font-size: 0.85rem; color: var(--muted); }
.home-empty p { color: var(--muted); }
.privacy-note { margin-top: 40px; font-size: 0.88rem; line-height: 1.6; color: var(--muted); border-top: 1px solid var(--line); padding-top: 18px; }

/* setup */
.setup-track { height: 3px; background: #22252A; border-radius: 3px; margin-bottom: 36px; }
.setup-track div { height: 3px; background: var(--gold); border-radius: 3px; width: 0; transition: width .5s ease; }
.setup-box { display: flex; flex-direction: column; gap: 16px; max-width: 580px; }
.setup-h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2.2rem, 5vw, 3rem); margin: 0; }
.setup-lead, .setup-help { color: var(--muted); font-size: 1.02rem; line-height: 1.65; margin: 0; }
.setup-kicker { margin: 0; font-size: 0.85rem; color: #9A948A; }
.setup-q { font-family: var(--serif); font-weight: 500; font-size: clamp(1.8rem, 4vw, 2.3rem); line-height: 1.15; margin: 0; }
.cheer { margin: 0; color: #9DBF7A; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 0.98rem; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 18px; color: var(--ink); font: inherit; font-size: 1.02rem; cursor: pointer; transition: border-color .15s, transform .15s; }
.choice:hover { border-color: var(--gold); transform: translateY(-1px); }
.choice.on { border-color: var(--gold); background: #1E1B17; }
.choice small { color: var(--muted); font-size: 0.86rem; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }

/* editor frame */
.ed-bar { position: sticky; top: 0; z-index: 5; background: #131518; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); margin-top: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 28px; }
.ed-doc { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.ed-doc .back { padding: 0; font-size: 0.82rem; align-self: flex-start; }
.ed-title { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; line-height: 1.2; max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-saved { font-size: 0.8rem; color: #9A948A; }
.ed-saved.bad { color: var(--must); }
.ed-tools { flex: 0 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.tool { min-width: 38px; min-height: 38px; padding: 0 9px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: #D6D1C8; font: inherit; font-size: 0.92rem; cursor: pointer; }
.tool:hover { background: #1C1F23; border-color: var(--line); }
.tool-word { font-size: 0.86rem; }
.tool-sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; }
.tool-select { width: auto !important; flex: none; min-height: 38px; background: transparent; color: #D6D1C8; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 0.86rem; padding: 0 8px; margin-right: 4px; }
.tool-select option { background: #17191C; }
.ed-out { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-status { flex-basis: 100%; font-size: 0.85rem; color: var(--muted); }
.ed-status:empty { display: none; }
.ed-body { max-width: 1440px; margin: 0 auto; padding: 24px 28px 80px; display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.ed-outline { flex: 1 1 200px; max-width: 230px; min-width: 0; position: sticky; top: 108px; }
.ed-main { flex: 999 1 560px; min-width: 0; display: flex; justify-content: center; }
.ed-panel { flex: 1 1 290px; max-width: 330px; min-width: 0; position: sticky; top: 108px; max-height: calc(100vh - 128px); overflow: auto; }
body.focus .ed-outline, body.focus .ed-panel { display: none; }
.side-h { margin: 0 0 8px 10px; font-family: var(--caps); letter-spacing: 3px; font-size: 0.72rem; color: var(--gold); text-transform: uppercase; }
.outline { list-style: none; margin: 0; padding: 0; }
.oi { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; color: #D6D1C8; font: inherit; font-size: 0.88rem; padding: 7px 10px; cursor: pointer; }
.oi:hover { background: #1C1F23; color: var(--ink); }
.oi.sub { padding-left: 30px; font-size: 0.82rem; color: var(--muted); }
.ol-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-meta { font-size: 0.75rem; color: #8F8A82; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; border: 1.5px solid #5A544C; }
.dot.s-done { background: #9DBF7A; border-color: #9DBF7A; }
.dot.s-part { background: linear-gradient(90deg, #E2B885 50%, transparent 50%); border-color: #E2B885; }
.oi.sub .dot { visibility: hidden; }
.side-foot { margin: 14px 10px 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.82rem; line-height: 1.6; color: #9A948A; }
.field-badge { margin: 10px; font-size: 0.78rem; color: #E2B885; border: 1px dashed var(--gold); border-radius: 7px; padding: 5px 8px; }

/* the page */
.sheet { width: 100%; max-width: 780px; background: #17191C; border: 1px solid var(--line); border-radius: 6px; padding: 64px 72px 90px;
  font-family: 'Literata', Georgia, serif; font-size: 17px; line-height: 1.75; color: #DAD5CC; caret-color: #E2B885; outline: none; }
.sheet p { margin: 0 0 12px; }
.sheet .kicker { font-family: var(--sans); font-size: 0.72rem; letter-spacing: 2px; color: var(--gold); margin: 0 0 4px; user-select: none; }
.sheet h1 { font-family: var(--serif); font-weight: 600; font-size: 2.3rem; line-height: 1.15; color: var(--ink); margin: 0 0 12px; }
.sheet .authors { font-size: 0.92rem; color: #B5AFA5; margin: 0 0 4px; }
.sheet h2 { font-family: var(--serif); font-weight: 600; font-size: 1.65rem; color: var(--ink); margin: 34px 0 8px; }
.sheet h3 { font-family: 'Literata', Georgia, serif; font-style: italic; font-weight: 400; font-size: 1.02rem; color: var(--ink); margin: 20px 0 4px; }
.sheet ul, .sheet ol { margin: 0 0 12px; padding-left: 26px; }
.sheet p[data-hint]:empty::before, .sheet p[data-hint]:has(> br:only-child)::before { content: attr(data-hint); color: #7D776F; font-family: var(--sans); font-size: 0.9rem; pointer-events: none; }
.sheet .blank { color: #E2B885; border-bottom: 1.5px dashed #8C7150; background: rgba(226, 184, 133, .07); border-radius: 2px; padding: 0 1px; cursor: text; }
.sheet .cite { color: #E2B885; font-family: var(--sans); font-size: 0.7em; vertical-align: super; line-height: 0; padding: 0 1px; user-select: all; }
.sheet .caption { font-family: var(--sans); font-size: 0.9rem; color: #CFC9BF; margin-top: 18px; }
.sheet table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.88rem; margin: 4px 0 14px; }
.sheet th, .sheet td { border-bottom: 1px solid #34312C; padding: 6px 8px; text-align: left; min-width: 3em; vertical-align: top; }
.sheet th { color: var(--ink); font-weight: 500; border-bottom-color: #4A443B; }
.sheet .refs-h { user-select: none; }
.sheet .refs-out { font-size: 0.92rem; line-height: 1.6; color: #CFC9BF; user-select: text; }
.sheet .refs-out ol { padding-left: 26px; }
.sheet .refs-empty { font-family: var(--sans); font-size: 0.88rem; color: #7D776F; }
.flash { animation: flash 1.8s ease; border-radius: 3px; }
@keyframes flash { 0%, 40% { background: rgba(226, 184, 133, .32); } 100% { background: transparent; } }

/* panel */
.ptabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.ptab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-size: 0.9rem; padding: 10px 2px; cursor: pointer; }
.ptab[aria-selected="true"] { color: #E2B885; border-bottom-color: var(--gold); }
.count { font-size: 0.75rem; color: #141517; background: var(--gold); border-radius: 999px; padding: 0 6px; margin-left: 3px; }
.count:empty { display: none; }
.panel-lead, .panel-foot { font-size: 0.86rem; line-height: 1.55; color: var(--muted); margin: 0 0 10px; display: block; }
.panel-foot { margin-top: 12px; color: #8F8A82; }
.notes, .refs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.note { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.note:hover { border-color: #5A4A35; }
.note-go { flex: 1; display: flex; gap: 10px; text-align: left; background: none; border: 0; color: #D6D1C8; font: inherit; font-size: 0.86rem; line-height: 1.5; padding: 11px 12px; cursor: pointer; }
.note-go b { font-weight: 500; color: var(--ink); }
.note-icon { color: #E2B885; flex: none; }
.note.bad .note-icon { color: var(--must); }
.note-fix { flex: none; align-self: center; margin-right: 10px; background: transparent; border: 1px solid #5A4A35; border-radius: 999px; color: #E2B885; font: inherit; font-size: 0.8rem; padding: 4px 11px; cursor: pointer; }
.calm { color: var(--muted); font-size: 0.88rem; padding: 8px 2px; }
.good { font-size: 0.82rem; color: #9DBF7A; margin: 10px 0 0; }
.good:empty { display: none; }
.ref-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.ref-buttons { display: flex; gap: 10px; align-items: center; }
.ref-card { display: flex; flex-direction: column; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 0.84rem; line-height: 1.5; color: #D6D1C8; }
.ref-card .btn { align-self: flex-start; }
.ref-card.bad { border-color: #6A3A33; }
.ref-card.muted { color: var(--muted); }
.ref-actions { display: flex; gap: 10px; align-items: center; }
.bad-text { color: var(--must); font-weight: 500; }
.gold { color: #E2B885; }
#ref-results:not(:empty) { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); background: #1C1F23; border: 1px solid var(--gold); color: var(--ink);
  border-radius: 999px; padding: 11px 20px; font-size: 0.9rem; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .ed-outline, .ed-panel { position: static; max-width: none; max-height: none; flex-basis: 100%; }
  .ed-outline { order: 2; } .ed-panel { order: 3; }
  .ed-outline .outline { display: flex; flex-wrap: wrap; gap: 2px; }
  .oi.sub { display: none; }
}
@media (max-width: 640px) {
  .studio-head, .ed-bar, .ed-body, .studio-home, .studio-setup { padding-left: 16px; padding-right: 16px; }
  .sheet { padding: 32px 22px 60px; font-size: 16px; }
  .sheet h1 { font-size: 1.8rem; }
  .ed-title { max-width: 24ch; }
}
@media (prefers-reduced-motion: reduce) { .choice, .setup-track div, .toast { transition: none; } .flash { animation: none; } }

.sheet .cite.ay { vertical-align: baseline; font-size: 0.92em; font-family: inherit; color: #E2B885; line-height: inherit; }
.sheet .refs-out .ay-list p { padding-left: 2em; text-indent: -2em; margin: 0 0 8px; }
.style-pick { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.style-pick .tool-select { width: 100% !important; }

/* panel tools */
.ptabs { flex-wrap: wrap; gap: 4px 14px; }
.tool-box { border-bottom: 1px solid var(--line); padding: 4px 0 14px; margin-bottom: 8px; }
.tool-box > summary { cursor: pointer; list-style: none; font-weight: 500; color: var(--ink); padding: 10px 0; display: flex; justify-content: space-between; }
.tool-box > summary::-webkit-details-marker { display: none; }
.tool-box > summary::after { content: "+"; color: var(--gold); }
.tool-box[open] > summary::after { content: "–"; }
.tool-box > summary:focus-visible { outline: 2px solid #E2B885; outline-offset: 2px; }
.tool-box .field { font-size: 0.86rem; color: var(--muted); margin-top: 10px; }
.tool-box .input, .tool-box select.input { font-size: 0.9rem; padding: 9px 11px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; color: #D6D1C8; margin: 10px 0 0; }
.check-row input { accent-color: #C69F70; width: 16px; height: 16px; }
.var-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-top: 8px; }
.var-list .check-row { margin: 6px 0; }
.var-list small { color: #8F8A82; margin-left: auto; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.mini-q { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.mini-q p { margin: 0; font-size: 0.86rem; color: var(--muted); }
.mini-choice { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: #D6D1C8; font: inherit; font-size: 0.86rem; cursor: pointer; }
.mini-choice:hover, .mini-choice.on { border-color: var(--gold); color: var(--ink); }
.mini-choice:focus-visible { outline: 2px solid #E2B885; outline-offset: 2px; }
.answer { background: #1E1B17; border: 1px solid #5A4A35; border-radius: 12px; padding: 12px; margin-top: 10px; font-size: 0.86rem; line-height: 1.55; color: #D6D1C8; }
.answer b { color: var(--ink); font-weight: 500; }
.answer code { font-family: var(--sans); color: #E2B885; }
.finding { display: flex; gap: 9px; font-size: 0.85rem; line-height: 1.5; color: #D6D1C8; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.finding b { font-weight: 500; color: var(--ink); }
.finding .i { flex: none; }
.finding .i.ok { color: #9DBF7A; } .finding .i.warn { color: #E2B885; } .finding .i.bad { color: var(--must); }
.fig-preview { position: relative; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #0E0F11; }
.fig-preview canvas { display: block; width: 100%; height: auto; }
.journal { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 0.84rem; line-height: 1.5; color: #D6D1C8; }
.journal.caution { border-color: #6A3A33; }
.journal b { font-weight: 500; color: var(--ink); font-size: 0.92rem; }
.journal .links { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.8rem; }
.journal .links a { color: #E2B885; }
.tag-ok { color: #9DBF7A; } .tag-warn { color: #E2B885; } .tag-bad { color: var(--must); }
.letter-text { width: 100%; min-height: 320px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font: 0.88rem/1.6 var(--sans); padding: 12px; resize: vertical; margin-top: 10px; }
.sheet .tnote { font-family: var(--sans); font-size: 0.82rem; color: #A9A49B; margin-top: -6px; }
