/* Folio — app chrome. The document itself is styled inside the iframe. */

:root {
  --bg: #f2f0ea;
  --panel: #fbfaf7;
  --ink: #1b1f26;
  --muted: #666d7a;
  --line: #e0dbd0;
  --line-soft: #ebe6dc;
  --accent: #b4530a;
  --accent-ink: #fffaf4;
  --bar-solid: #fdfcfa;
  --shadow: 0 1px 2px rgba(28, 25, 20, .06), 0 18px 40px -22px rgba(28, 25, 20, .35);
  --radius: 12px;
  color-scheme: light;
}

html[data-theme="sepia"] {
  --bg: #eee2c8;
  --panel: #f8efdb;
  --ink: #372b1d;
  --muted: #7b6a53;
  --line: #ddcca9;
  --line-soft: #e7dabd;
  --accent: #9b4a11;
  --accent-ink: #fdf6ea;
  --bar-solid: #f8efdb;
  --shadow: 0 1px 2px rgba(60, 44, 22, .08), 0 18px 40px -22px rgba(60, 44, 22, .35);
}

html[data-theme="dark"] {
  --bg: #0e1116;
  --panel: #151a21;
  --ink: #e6eaf1;
  --muted: #94a0b1;
  --line: #262e39;
  --line-soft: #1d242d;
  --accent: #f0a05a;
  --accent-ink: #1a1206;
  --bar-solid: #151a21;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 24px 60px -28px rgba(0, 0, 0, .9);
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- gate ---------- */

body.is-gate {
  display: block;
  height: auto;
  min-height: 100%;
  overflow-y: auto;
  background: #fff;
}

/* ---------- app shell ---------- */

#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 14px 0 18px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 9px; }
.mark { color: var(--accent); display: flex; }
.brand-name {
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.spacer { flex: 1; }

.filechip {
  display: flex; align-items: center; gap: 8px;
  margin-left: 12px;
  max-width: 34vw;
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  color: var(--muted);
  font-size: 12.5px;
}
.filechip-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, transform .06s ease;
}
.btn:hover { background: color-mix(in srgb, var(--line-soft) 70%, var(--panel)); }
.btn:active { transform: translateY(.5px); }
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--ink); border-color: var(--muted); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: color-mix(in srgb, var(--line-soft) 90%, var(--panel));
  border-radius: 10px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.seg button:hover { color: var(--ink); }
.seg button.on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

.swatches { display: inline-flex; gap: 3px; padding: 3px; border-radius: 10px; }
.swatches button {
  width: 24px; height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
}
.swatches button span {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .18);
  display: block;
}
.swatches button[data-theme="light"] span { background: #fdfcfa; }
.swatches button[data-theme="sepia"] span { background: #f0e0bd; }
.swatches button[data-theme="dark"] span { background: #1b212a; }
.swatches button:hover { background: var(--line-soft); }
.swatches button.on { border-color: var(--line); background: var(--panel); }

/* ---------- stage ---------- */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 16px;
}
.stage.dragging::after {
  content: "Drop to open";
  position: fixed; inset: 10px;
  display: grid; place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.01em;
  z-index: 20;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.empty { flex: 1; display: grid; place-items: center; overflow: auto; }
.drop {
  width: min(720px, 100%);
  padding: clamp(28px, 5vw, 54px);
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%),
    var(--panel);
  text-align: center;
  box-shadow: var(--shadow);
}
.drop-icon { color: var(--accent); display: flex; justify-content: center; margin-bottom: 14px; }
.drop h1 {
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: clamp(22px, 3.1vw, 31px);
  line-height: 1.18;
  letter-spacing: -.02em;
  font-weight: 600;
  margin: 0 0 10px;
  text-wrap: balance;
}
.lede { margin: 0 auto 24px; max-width: 46ch; color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.lede code, .fine code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--line-soft);
  color: var(--ink);
}
.actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
.fine { margin: 22px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }

.frame-wrap {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
#frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }

/* ---------- status bar ---------- */

.status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: var(--panel);
}
.st-title {
  max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font-weight: 550;
}
.st-sep { width: 1px; height: 12px; background: var(--line); }
.st-mode { font-variant: small-caps; letter-spacing: .04em; }

/* ---------- dialogs ---------- */

dialog.sheet {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .55);
}
dialog.sheet.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(12, 14, 18, .42); backdrop-filter: blur(3px); }

.sheet-inner { padding: 4px 20px 20px; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 6px;
}
.sheet-head h2 {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", Georgia, serif;
  font-size: 17px; font-weight: 600; letter-spacing: -.01em;
}

.row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-of-type { border-bottom: 0; }
.row-label { flex: 1; font-size: 13.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.row output { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.row.actions { justify-content: flex-end; padding-top: 16px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 168px; height: 22px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
}

input.switch {
  -webkit-appearance: none; appearance: none;
  width: 40px; height: 23px; border-radius: 999px;
  background: var(--line);
  position: relative; cursor: pointer; flex: none;
  transition: background .16s ease;
}
input.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  transition: transform .16s ease;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(17px); }

/* ---------- store files ---------- */

input.text-input {
  width: 220px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
input.text-input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }

.vault-note { margin: 12px 0 4px; }
.vault-count { color: var(--muted); font-size: 12px; }

.vault-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }
.vault-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg) 35%, var(--panel));
}
.vault-item-body { flex: 1; min-width: 0; }
.vault-name {
  display: block;
  font-size: 13px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vault-meta { color: var(--muted); font-size: 11.5px; }
.vault-item .btn { height: 28px; padding: 0 10px; font-size: 12.5px; }

.vault-status { margin: 10px 0 0; min-height: 1.2em; font-size: 12.5px; color: var(--muted); }
.vault-status.is-error { color: #c0392b; }
.vault-status.is-ok { color: #1f7a4d; }

[data-theme="dark"] .vault-status.is-ok { color: #6ee7a8; }
[data-theme="dark"] .vault-status.is-error { color: #ff8a80; }

textarea#pasteArea {
  width: 100%;
  min-height: 320px;
  margin-top: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 60%, var(--panel));
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
}
textarea#pasteArea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }

:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

@media (max-width: 760px) {
  .brand-name { display: none; }
  .filechip { max-width: 26vw; margin-left: 0; }
  .seg button { padding: 5px 9px; font-size: 12px; }
  #openBtn span { display: none; }
  #openBtn { padding: 0 9px; }
  .stage { padding: 10px; }
  .status { padding: 0 12px; }
  .st-title { max-width: 18ch; }
  .swatches { display: none; }
}
