:root { --bg: #fff; --soft: #f6f7f9; --ink: #111; --muted: #666; --line: #dcdfe5; --blue: #1f4fd8; --bad: #a1271c; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; line-height: 1.2; margin: 0; }
a { color: var(--blue); }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 14px; } .bad { color: var(--bad); }
.pad { padding: 8px 16px; margin: 0; }
code, pre { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

header.top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
header.top .brand { font: 700 19px Georgia, serif; color: var(--ink); text-decoration: none; }
header.top .tag { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }

button, .btn { font: 600 15px/1 -apple-system, "Segoe UI", sans-serif; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: 11px 16px; cursor: pointer; text-decoration: none; display: inline-block; }
button.ghost, .btn.ghost { background: #fff; color: var(--ink); }
button.small, .btn.small { font-size: 13px; padding: 8px 11px; }
button.link { background: none; border: 0; color: var(--blue); padding: 4px 0; font-weight: 500; text-decoration: underline; }
button:focus-visible, a:focus-visible, .drop:focus-within { outline: 3px solid #8fb0ff; outline-offset: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

/* home */
main.home, div.home { max-width: 720px; margin: 0 auto; padding: 56px 16px 72px; }
.home h1 { font-size: clamp(30px, 6vw, 42px); margin: 0 0 10px; }
.home h2 { font-size: 20px; margin: 36px 0 10px; }
.lead { font-size: 18px; margin: 0 0 24px; }
.drop { display: block; border: 1.5px dashed #b8bec9; border-radius: 14px; padding: 34px 20px; text-align: center; cursor: pointer; font-size: 17px; }
.drop span { display: block; margin-top: 6px; }
.drop.over { border-color: var(--blue); background: #f3f6ff; }
ul.files { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
ul.files li { border-bottom: 1px solid var(--line); padding: 14px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center; }
ul.files .name { font-weight: 600; overflow-wrap: anywhere; }
ul.files .meta { grid-column: 1 / -1; font-size: 14px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.foot { margin-top: 36px; }
.chip { display: inline-block; font: 700 11px/1 -apple-system, "Segoe UI", sans-serif; letter-spacing: .07em; text-transform: uppercase; border-radius: 999px; padding: 5px 9px; color: #fff; background: var(--blue); vertical-align: middle; }

/* workspace */
body.ws { height: 100vh; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; }
.tabs a { flex: 0 1 220px; min-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--soft); }
.tabs a[aria-current="page"] { background: #fff; border-color: var(--ink); font-weight: 600; }
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.split > section { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.viewpane { border-right: 1px solid var(--line); background: var(--soft); }
.viewhead { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px; }
.viewhead h2 { font-size: 17px; overflow-wrap: anywhere; }
.viewhead p { margin: 2px 0 0; }
#pdfFrame { flex: 1; width: 100%; border: 0; min-height: 0; }
.docview { flex: 1; min-height: 0; overflow: auto; padding: 22px; }
.docview .page { background: #fff; border: 1px solid var(--line); border-radius: 6px; max-width: 780px; margin: 0 auto; padding: 34px 40px; }
.docview .page p { margin: 0 0 12px; overflow-wrap: anywhere; }
.docview .page p.h { font: 700 20px Georgia, serif; margin: 18px 0 10px; }
.docview .page pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.cell { max-width: 900px; margin: 0 auto 12px; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; }
.cell .n { font: 12px/1.9 ui-monospace, Menlo, monospace; color: var(--muted); text-align: right; }
.cell pre { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cell.md pre { border-color: transparent; background: transparent; font: 15px/1.55 -apple-system, "Segoe UI", sans-serif; }
.cell .out { grid-column: 2; }
.cell .out pre { border-style: dashed; color: #333; }
.cell .out img { max-width: 100%; background: #fff; }
.empty { margin: auto; padding: 24px; max-width: 46ch; text-align: center; color: var(--muted); }
.writepane { overflow: auto; padding: 16px; }
.writepane h2 { font-size: 20px; margin: 0 0 10px; }
#boxWrap { min-height: 120px; margin: 4px 0 10px; }
.signedtext { white-space: pre-wrap; border-left: 3px solid var(--blue); padding: 2px 0 2px 14px; margin: 10px 0 14px; overflow-wrap: anywhere; }
table.kv { border-collapse: collapse; width: 100%; font-size: 14px; margin: 0 0 14px; }
table.kv td { border-top: 1px solid #eee; padding: 7px 0; vertical-align: top; overflow-wrap: anywhere; }
table.kv td:first-child { color: var(--muted); padding-right: 12px; width: 34%; }
@media (max-width: 900px) { body.ws { height: auto; } .split { grid-template-columns: minmax(0, 1fr); } .viewpane { height: 62vh; border-right: 0; border-bottom: 1px solid var(--line); } }
