/* PriorStates Resume — the app chrome. Same dark base as priorstates.com; the
   pages in the preview are the template's own (white) print pages. */
:root {
  --bg: #0d1117; --bg2: #161b22; --bg3: #1c2230; --line: #30363d;
  --fg: #c9d1d9; --dim: #8b949e; --strong: #e6edf3;
  --accent: #3b82c4; --accent2: #5aa0de; --accent-fg: #fff;
  --ok: #3fb950; --warn: #f0883e; --err: #f85149;
  --add-bg: #12351f; --add-fg: #7ee29b; --del-bg: #3d1618; --del-fg: #ffa198;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); display: flex; flex-direction: column; font: 13px/1.4 var(--font); overflow: hidden; }
a { color: var(--accent2); }
button, select, input, textarea { font: inherit; color: inherit; }
button, select { background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; }
button:hover, select:hover { border-color: var(--accent2); }
button:disabled { cursor: default; opacity: .45; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.primary:hover { background: var(--accent2); }
button.on { background: var(--bg3); border-color: var(--accent2); color: var(--strong); }

/* ---------- top bar */
.top { align-items: center; background: var(--bg2); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 12px; }
.brand { align-items: center; color: var(--dim); display: flex; gap: 6px; margin-right: 6px; text-decoration: none; white-space: nowrap; }
.brand img { height: 20px; width: 20px; }
.brand b { color: var(--strong); }
.pill { background: #3a2a00; border-radius: 9px; color: #f2cc60; font-size: 11px; padding: 1px 7px; }
#doc { max-width: 240px; }
#pages { background: var(--bg3); border-radius: 10px; color: var(--strong); font-weight: 600; padding: 3px 9px; white-space: nowrap; }
#pages.changed { background: #4a2e00; color: #ffc680; }
#commit.dirty::after { color: var(--warn); content: " ●"; }
#status { color: var(--dim); margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
#status.ok { color: var(--ok); } #status.err { color: var(--err); } #status.busy { color: var(--warn); }
.spacer { flex: 1; }

/* menus */
details.menu { position: relative; }
details.menu > summary { background: var(--bg2); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; list-style: none; padding: 5px 10px; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { border-color: var(--accent2); }
details.menu .items { background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 12px 30px rgba(0,0,0,.45); display: flex; flex-direction: column; left: 0; min-width: 210px; padding: 5px; position: absolute; top: calc(100% + 4px); z-index: 20; }
details.menu .items button { background: none; border: 0; border-radius: 6px; text-align: left; }
details.menu .items button:hover { background: var(--bg3); }
details.menu .items hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* ---------- panes */
.tabs { display: none; }
main { display: flex; flex: 1; min-height: 0; }
#left { display: flex; flex-direction: column; min-width: 260px; width: 40%; }
.CodeMirror { background: var(--bg); color: var(--fg); flex: 1; font: 13px/1.55 var(--mono); height: auto; }
.CodeMirror-gutters { background: var(--bg); border-right: 1px solid var(--line); }
.CodeMirror-linenumber { color: #4b5563; }
.CodeMirror-cursor { border-left-color: var(--strong); }
.CodeMirror-selected, .CodeMirror-focused .CodeMirror-selected { background: #264f78 !important; }
.cm-s-default .cm-header { color: #79c0ff; } .cm-s-default .cm-strong { color: var(--strong); }
.cm-s-default .cm-variable-2, .cm-s-default .cm-variable-3 { color: #c9d1d9; } .cm-s-default .cm-keyword { color: #ff7b72; }
.cm-s-default .cm-link, .cm-s-default .cm-url { color: #7ee787; } .cm-s-default .cm-comment { color: #a5d6ff; }
.cm-s-default .cm-quote { color: var(--dim); } .cm-s-default .cm-em { color: #e3b341; }
.cm-flash { background: #4d3f00; }
#divider { background: var(--line); cursor: col-resize; flex: none; width: 5px; }
#divider:hover { background: var(--accent2); }
#right { flex: 1; min-width: 260px; position: relative; }
#right iframe { border: 0; height: 100%; inset: 0; position: absolute; width: 100%; background: #2a303b; }
/* The back frame stays "visible" under the front one: Chrome pauses rendering in
   hidden cross-origin (sandboxed) frames, and paged.js needs it to paginate. */
#right iframe { z-index: 1; }
#right iframe.back { z-index: 0; }
#hint { bottom: 8px; color: #aab4c0; font-size: 11.5px; left: 0; pointer-events: none; position: absolute; right: 0; text-align: center; z-index: 2; text-shadow: 0 1px 2px #000; }

/* ---------- side panel (AI / History) */
#side { background: var(--bg2); border-left: 1px solid var(--line); display: none; flex: none; flex-direction: column; width: 400px; min-width: 300px; }
#side.show { display: flex; }
.pane { display: none; flex: 1; flex-direction: column; min-height: 0; }
.pane.show { display: flex; }
.bar { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 6px; padding: 8px 10px; }
.bar b { color: var(--strong); margin-right: auto; }
.bar small { color: var(--dim); }
#chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 10px 0; }
#chips button { border-radius: 12px; font-size: 12px; padding: 2px 9px; }
#msgs { flex: 1; overflow: auto; padding: 10px; }
.msg { border-radius: 9px; margin: 0 0 10px; padding: 8px 10px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { background: #1d2a3d; margin-left: 30px; }
.msg.bot { background: var(--bg); border: 1px solid var(--line); }
.msg.err { background: #2d1416; color: var(--del-fg); }
.msg code { background: var(--bg3); border-radius: 3px; font-family: var(--mono); font-size: .92em; padding: 0 3px; }
.msg .note { color: var(--dim); display: block; font-size: 12px; font-style: italic; margin-top: 4px; }
.empty { color: var(--dim); padding: 22px 12px; text-align: center; line-height: 1.5; }
.setup { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; margin: 10px; padding: 10px 12px; line-height: 1.5; }
.setup b { color: var(--strong); }
.prop { background: var(--bg2); border: 1px solid #2f4a6b; border-radius: 9px; margin-top: 8px; white-space: normal; }
.prop .head { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 6px; padding: 6px 8px; }
.prop .head span { color: var(--dim); font-size: 12px; margin-right: auto; }
.diff { font: 11.5px/1.45 var(--mono); max-height: 340px; overflow: auto; padding: 4px 0; }
.diff div { padding: 0 8px; white-space: pre-wrap; }
.diff .add { background: var(--add-bg); color: var(--add-fg); }
.diff .del { background: var(--del-bg); color: var(--del-fg); }
.diff .chg { border-left: 3px solid #2f4a6b; }
.diff ins { background: var(--add-bg); color: var(--add-fg); text-decoration: none; }
.diff del { background: var(--del-bg); color: var(--del-fg); }
.diff .gap { color: var(--dim); text-align: center; }
#askbox { border-top: 1px solid var(--line); padding: 8px 10px; }
#ask { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; min-height: 64px; padding: 6px 8px; resize: vertical; width: 100%; }
#ask:focus { border-color: var(--accent2); outline: none; }
#askbox .row { align-items: center; display: flex; gap: 6px; margin-top: 6px; }
#askbox .row small { color: var(--dim); margin-right: auto; }
#hist { flex: 1; overflow: auto; }
.ver { border-bottom: 1px solid var(--line); cursor: pointer; padding: 8px 12px; }
.ver:hover { background: var(--bg3); }
.ver.sel { background: #1d2a3d; }
.ver .sub { color: var(--strong); font-weight: 600; }
.ver .meta { color: var(--dim); font-size: 12px; margin-top: 2px; }
.tag { background: #2b1f47; border-radius: 8px; color: #d2a8ff; font-size: 11px; margin-left: 5px; padding: 0 6px; }
.tag.now { background: #4a2e00; color: #ffc680; }
#verdiff { border-top: 1px solid var(--line); display: none; flex-direction: column; max-height: 55%; }
#verdiff.show { display: flex; }
#verdiff .head { align-items: center; display: flex; gap: 6px; padding: 6px 10px; }
#verdiff .head span { color: var(--dim); font-size: 12px; margin-right: auto; }
#verdiff .diff { flex: 1; max-height: none; }

/* ---------- settings dialog */
dialog { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; color: var(--fg); max-height: 90vh; max-width: min(640px, calc(100vw - 32px)); padding: 0; width: 640px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog .dhead { align-items: center; border-bottom: 1px solid var(--line); display: flex; padding: 10px 14px; }
dialog .dhead b { color: var(--strong); flex: 1; font-size: 15px; }
dialog .dbody { overflow: auto; padding: 4px 16px 14px; max-height: calc(90vh - 52px); }
dialog h3 { color: var(--strong); font-size: 13.5px; margin: 16px 0 6px; }
dialog p, dialog li { color: var(--dim); line-height: 1.5; }
dialog textarea, dialog input[type=password], dialog input[type=text] { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; width: 100%; }
dialog textarea { font: 12.5px/1.5 var(--mono); min-height: 150px; resize: vertical; }
.opt { align-items: flex-start; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; display: flex; gap: 9px; margin: 6px 0; padding: 9px 11px; }
.opt:has(input:checked) { border-color: var(--accent2); background: #152235; }
.opt.off { cursor: default; opacity: .55; }
.opt b { color: var(--strong); }
.opt small { color: var(--dim); display: block; line-height: 1.45; margin-top: 2px; }
.opt input[type=radio] { margin-top: 3px; }
.keyrow { display: flex; gap: 6px; margin-top: 7px; }
#aitest { color: var(--dim); margin-left: 8px; }

/* ---------- phones: one pane at a time */
@media (max-width: 820px) {
  .top { gap: 5px; padding: 6px 10px; }
  .brand span.long { display: none; }
  #doc { max-width: 150px; }
  #status { flex-basis: 100%; margin-left: 0; max-width: none; order: 10; }
  .tabs { background: var(--bg2); border-bottom: 1px solid var(--line); display: flex; }
  .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; flex: 1; padding: 8px 0; }
  .tabs button.on { border-bottom-color: var(--accent2); color: var(--strong); }
  #divider { display: none; }
  #left, #right, #side { display: none !important; width: 100% !important; min-width: 0; border: 0; }
  body[data-view=edit] #left { display: flex !important; }
  body[data-view=preview] #right { display: block !important; }
  body[data-view=side] #side { display: flex !important; }
  #histToggle, #aiToggle { display: none; }
}
[hidden] { display: none !important; }
