/* PDF Studio - core styles. Tokens first; modules use these. */
:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #18212b;
  --muted: #4a5868;
  --line: #c9d1db;
  --line-strong: #8e9bab;
  --accent: #1d4f91;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecf8;
  --danger: #b3261e;
  --ok: #1e6b3a;
  --warn: #8a5a00;
  --t-blue: #e6effa;   --b-blue: #6f95c6;   --bar-blue: #2f69b3;
  --t-gold: #fbf2dc;   --b-gold: #c9a24a;   --bar-gold: #a67b14;
  --t-green: #e5f4ea;  --b-green: #6fae84;  --bar-green: #2d7d4a;
  --t-rose: #fbe9ea;   --b-rose: #cf8288;   --bar-rose: #b23a46;
  --t-violet: #efe9fa; --b-violet: #9b85c9; --bar-violet: #6747a8;
  --t-slate: #e9edf2;  --b-slate: #8e9bab;  --bar-slate: #4a5868;
  --stage: #5d6773;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 2px 8px rgba(16, 24, 40, .06);
  --ns-bg: #ffffff; --ns-ink: #18212b; --ns-line: #8e9bab;
  --topbar-h: 56px;
  /* r367 (10/27/2026): every button looks like a button - a 2px line clearly stronger than the
     faint card line, and a fill that differs from the white sheets/panels behind it. */
  --btnline: #5f6f84;
  --btnfill: #f3f6fa;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  height: var(--vvh, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* top bar */
.topbar {
  flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: #13294b; color: #fff;
  border-bottom: 2px solid #0b1a31;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; cursor: pointer; background: rgba(255,255,255,.08); border: 2px solid #6f8fbf; border-radius: 8px; color: #fff; padding: 2px 6px 2px 2px; } /* r367: the home button carries words on a wide screen, so it is a bordered button too */
.brand img { width: 28px; height: 28px; border-radius: 6px; }
.brand small { font-weight: 500; opacity: .85; }
.docname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .92; font-size: 14px; }
.topbar .btn { border-color: #6f8fbf; }
.topbar .btn.ghost { color: #fff; background: rgba(255,255,255,.1); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,.12); }
.topbar .iconbtn { color: #fff; border-color: transparent; background: transparent; }
.topbar .iconbtn:hover { background: rgba(255,255,255,.12); }

/* tabs */
.tabs { flex: 0 0 auto; display: flex; gap: 4px; padding: 6px 10px 0; background: #dfe5ee; border-bottom: 2px solid #b6c1cf; overflow-x: auto; }
.tab { /* btn-look-ok: top segmented tab nav - navigation, the active tab is a raised white tab */ border: 1.5px solid transparent; border-bottom: 0; background: transparent; padding: 8px 14px; border-radius: 8px 8px 0 0; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--panel); color: var(--accent); border-color: #b6c1cf; margin-bottom: -2px; border-bottom: 2px solid var(--panel); }
.tab:disabled { opacity: .45; cursor: default; }

main { flex: 1 1 auto; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; display: none; overflow: auto; }
.screen.on { display: block; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 2px solid var(--btnline); border-radius: 8px;
  background: var(--btnfill); color: var(--ink); font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #123764; }
.btn.primary:hover { background: #173f75; }
.btn.ghost { background: var(--btnfill); } /* r367: never bare text on the sheet */
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg, .iconbtn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.iconbtn {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; color: var(--ink);
}
.iconbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* home */
.home { max-width: 1100px; margin: 0 auto; padding: 18px 16px 40px; }
.drop {
  border: 2px dashed var(--b-blue); background: var(--t-blue); border-radius: 14px;
  padding: 26px 16px; text-align: center;
}
.drop.over { background: #d3e3f7; border-color: var(--accent); }
.drop h1 { margin: 0 0 4px; font-size: 22px; }
.drop p { margin: 4px 0 14px; color: var(--muted); }
.privacy {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 10px;
  background: var(--t-green); border: 2px solid var(--b-green); color: #123d22; font-size: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.privacy svg { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 1px; color: var(--ok); }
.groups { display: grid; gap: 14px; margin-top: 18px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.group { border-radius: 12px; padding: 12px; border: 2px solid; }
.group h2 { margin: 0 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .6px; }
.group.g-edit { background: var(--t-blue); border-color: var(--b-blue); } .group.g-edit h2 { color: var(--bar-blue); }
.group.g-text { background: var(--t-gold); border-color: var(--b-gold); } .group.g-text h2 { color: #7a5a0e; }
.group.g-organize { background: var(--t-green); border-color: var(--b-green); } .group.g-organize h2 { color: var(--bar-green); }
.group.g-convert { background: var(--t-violet); border-color: var(--b-violet); } .group.g-convert h2 { color: var(--bar-violet); }
.group.g-protect { background: var(--t-rose); border-color: var(--b-rose); } .group.g-protect h2 { color: var(--bar-rose); }
.tool {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  padding: 10px 10px 10px 12px; margin: 0 0 6px; border-radius: 8px; cursor: pointer;
  background: #fff; border: 2px solid var(--btnline); border-left: 6px solid var(--bar-slate); /* r367: tool tiles are buttons - 2px clear line */
}
.tool:nth-child(odd) { background: #f8fafc; }
.g-edit .tool { border-left-color: var(--bar-blue); }
.g-text .tool { border-left-color: var(--bar-gold); }
.g-organize .tool { border-left-color: var(--bar-green); }
.g-convert .tool { border-left-color: var(--bar-violet); }
.g-protect .tool { border-left-color: var(--bar-rose); }
.tool:hover { border-color: var(--accent); }
.tool .ti { width: 34px; height: 34px; flex: 0 0 34px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.tool .ti svg { width: 20px; height: 20px; }
.tool b { display: block; font-size: 15px; }
.tool span { display: block; font-size: 13px; color: var(--muted); }

/* shared work layout */
.work { display: flex; height: 100%; min-height: 0; }
.work .side {
  flex: 0 0 300px; overflow: auto; padding: 12px;
  background: var(--t-slate); border-right: 2px solid var(--b-slate);
}
.work .stagewrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.toolbar {
  flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px; background: var(--t-blue); border-bottom: 2px solid var(--b-blue);
}
.toolbar .sep { width: 1.5px; height: 28px; background: var(--b-blue); margin: 0 4px; }
.toolbar label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.panel { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.panel h3 { margin: 0 0 8px; font-size: 15px; }
.field { display: block; margin: 0 0 10px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1.5px solid var(--line-strong); border-radius: 8px; background: #fff;
}
textarea.input { min-height: 120px; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }

/* viewer */
.ps-viewer { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--stage); padding: 16px 8px 60px; }
.ps-viewer .ps-page {
  position: relative; margin: 0 auto 16px; background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.35); outline: 1px solid #3c444d;
}
.ps-page canvas { display: block; width: 100%; height: 100%; }
.ps-page .ps-layer { position: absolute; inset: 0; }
.ps-page .ps-pno { position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%); font-size: 11px; color: #e7ebf0; }
.zoombar { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 4px; background: #fff; border: 2px solid var(--line-strong); border-radius: 10px; padding: 4px; z-index: 5; align-items: center; }
.kb-open .zoombar { display: none; } /* the keyboard is up: keep the field being typed in uncovered */
.zoombar .z { min-width: 46px; text-align: center; font-size: 13px; font-weight: 600; }

/* modal / sheet */
.ps-backdrop { position: fixed; inset: 0; background: rgba(10, 18, 30, .5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 12px; }
.ps-modal {
  background: #fff; border: 2px solid #13294b; border-radius: 14px; width: min(620px, 100%);
  max-height: calc(var(--vvh, 100dvh) - 24px); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.ps-modal header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 2px solid var(--line); background: var(--t-blue); border-radius: 12px 12px 0 0; }
.ps-modal header h2 { flex: 1; margin: 0; font-size: 17px; }
.ps-modal .mb { padding: 14px; overflow: auto; }
.ps-modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 14px; border-top: 2px solid var(--line); flex-wrap: wrap; }
@media (max-width: 640px) {
  .ps-backdrop { align-items: flex-end; padding: 0; }
  .ps-modal { width: 100%; border-radius: 14px 14px 0 0; margin-bottom: var(--kb, 0px); }
  /* r367: on a phone the one primary is filled and full width at the bottom; Cancel / Close /
     Remove sit above it at one uniform width (max 260px), centered, two sharing a row. */
  .ps-modal footer { justify-content: center; }
  .ps-modal footer .btn:not(.primary) { flex: 1 1 0; min-width: 0; max-width: 260px; }
  .ps-modal footer .btn.primary { flex: 1 1 100%; order: 9; }
}

/* menu */
.ps-menu { position: fixed; z-index: 60; background: #fff; border: 2px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; }
.ps-menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; min-height: 44px; margin: 0 0 6px; border: 2px solid var(--btnline); background: var(--btnfill); color: var(--ink); font-weight: 600; border-radius: 8px; cursor: pointer; }
.ps-menu button:last-child { margin-bottom: 0; } /* r367: each menu choice is a bordered button, not a text line */
.ps-menu button:hover { background: var(--accent-soft); }

/* toast + busy */
.ps-toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--kb, 0px)); z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(560px, calc(100% - 24px)); }
.kb-open .ps-toasts, body:has(.ps-modal) .ps-toasts { top: calc(12px + var(--vvt, 0px)); bottom: auto; }
.ps-toast { pointer-events: auto; padding: 10px 14px; border-radius: 10px; background: #13294b; color: #fff; border: 2px solid #0b1a31; box-shadow: var(--shadow); font-weight: 600; }
.ps-toast.warn { background: #6b4600; border-color: #3f2900; }
.ps-toast.err { background: var(--danger); border-color: #6e1712; }
.ps-busy { position: fixed; inset: 0; z-index: 70; background: rgba(10,18,30,.45); display: none; align-items: center; justify-content: center; }
.ps-busy.on { display: flex; }
.ps-busy.bw .box { display: none; } /* r364: the shared wheel card (busy-wheel.js) shows the words + clock instead */
.ps-busy .box { background: #fff; border: 2px solid #13294b; border-radius: 12px; padding: 18px 20px; width: min(380px, calc(100% - 32px)); text-align: center; }
.ps-busy .bar { height: 8px; background: var(--t-slate); border: 1.5px solid var(--line); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.ps-busy .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ps-busy .spin { width: 28px; height: 28px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 10px; animation: psspin 0.9s linear infinite; }
@keyframes psspin { to { transform: rotate(360deg); } }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

@media (max-width: 760px) {
  .work { flex-direction: column-reverse; }
  .work .side { flex: 0 0 auto; max-height: 42%; border-right: 0; border-top: 2px solid var(--b-slate); }
  .docname { display: none; }
  .brand small { display: none; }
  .groups { grid-template-columns: 1fr; }
  .topbar { gap: 4px; padding: 0 8px; }
  .brand > span { display: none; }
  .zoombar .iconbtn, .zoombar .btn { min-width: 44px; min-height: 44px; }
}
@media (max-width: 420px) {
  #btn-open { display: none; }
}
