/* Self-contained: no fonts, images or styles are fetched outside the vault origin. */
/* A media query, not light-dark(): the mobile WebView floor (86) predates light-dark(). Inside
   the iframe it follows the embedder's color-scheme, same as light-dark() would. */
:root {
  color-scheme: light dark;
  --surface: #fdfbf7;
  --panel: #ffffff;
  --ink: #3d352b;
  --muted: #70675c;
  --line: #e3ddd2;
  --accent: #a5502f;
  --accent-hover: #934529;
  --accent-ink: #fff;
  --secure: #526b50;
  --secure-bg: #edf1e8;
  --danger: #a64038;
  --danger-bg: #fff0ed;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #1a1918;
    --panel: #242322;
    --ink: #eee8df;
    --muted: #b9b0a4;
    --line: #46433d;
    --accent: #e89a7f;
    --accent-hover: #f1b49d;
    --accent-ink: #241b16;
    --secure: #b3c7a1;
    --secure-bg: #282e25;
    --danger: #ffa69d;
    --danger-bg: #392724;
  }
}
* { box-sizing: border-box; }
/* Layout rules must never override the security-sensitive hidden states. */
[hidden] { display: none !important; }
body {
  margin: 0; padding: 16px 20px;
  font: 14px/1.5 'Inter', system-ui, sans-serif;
  background: var(--surface); color: var(--ink);
}
main { max-width: 560px; margin: 0 auto; }
header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
h1 { font-size: 19px; line-height: 1.3; letter-spacing: -.03em; margin: 0 0 2px; }
h2 { font-size: 15px; line-height: 1.4; margin: 0 0 6px; }
p { margin: 0 0 8px; }
header p { margin: 0; }
/* Locally embedded Material icon, tinted to match the security surface. */
.vault-mark {
  display: grid; place-items: center; flex: 0 0 40px; height: 40px; border-radius: 12px;
  background: var(--secure-bg); color: var(--secure);
}
.vault-mark svg { width: 26px; height: 26px; fill: currentColor; }
section { margin: 0 0 14px; }
section:not(.status) { padding-top: 12px; border-top: 1px solid var(--line); }
/* Keep setup, recovery and handoff focused on the current task. The normal vault
   (including the dedicated bulk-consent frame) still shows its authorization button. */
main:has(> #recovery:not([hidden]), > #recover:not([hidden]), > #receive:not([hidden]),
         > #transfer:not([hidden]), > #handover:not([hidden])) > .consent { display: none; }
.status {
  position: relative; overflow: hidden; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--secure-bg);
}
/* Quiet watermark stays behind the status only, never behind a phrase or QR. */
.status > .status-lock {
  position: absolute; pointer-events: none; fill: var(--secure); opacity: .08;
  width: 76px; height: 76px; right: 4px; top: -8px;
}
.status > * { position: relative; }
/* A stored key that blocks the task is not a "secure, all good" state. */
.status.blocking { background: var(--panel); }
.status.blocking > .status-lock { display: none; }
#key-state { font-weight: 600; margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
button, input, textarea { font: inherit; }
button {
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink);
  padding: 8px 12px; margin: 4px 6px 4px 0; line-height: 1.35; font-weight: 500;
  cursor: pointer; max-width: 100%;
}
button:hover:not(:disabled) { border-color: var(--accent); background: var(--surface); }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
/* No filter/opacity effects: the consent guard uses IntersectionObserver visibility. */
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.quiet { font-size: 12px; padding: 5px 0; border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; margin-bottom: 0; }
button.danger { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); font-weight: 600; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
textarea, input[type='file'] { display: block; width: 100%; margin: 6px 0 8px; }
textarea, #confirm-inputs input {
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink);
  padding: 8px 10px; caret-color: var(--accent);
}
textarea { resize: vertical; min-height: 74px; }
textarea::placeholder { color: var(--muted); opacity: 1; }
.field-label { font-size: 12px; font-weight: 600; }
input[type='file'] { font-size: 12px; }
input::file-selector-button { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: var(--panel); color: var(--ink); margin-right: 8px; cursor: pointer; }
/* The shape of the key-file box users already know: a button, and a place to drop the file. */
.file-drop {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px;
  margin: 6px 0 10px; padding: 4px 10px; border: 1px dashed var(--muted); border-radius: 9px;
}
#recover[aria-busy='true'] button { opacity: .55; cursor: wait; }
#phrase-words {
  font: 600 14px/1.6 ui-monospace, monospace; columns: 3; column-gap: 28px;
  margin: 10px 0; padding: 10px 12px 10px 36px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--panel);
}
#phrase-words li { padding: 2px 0; break-inside: avoid; }
#phrase-words li::marker { color: var(--muted); font-size: 11px; font-weight: 400; }
#confirm-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#confirm-inputs label { display: block; margin: 6px 0 8px; font-size: 12px; font-weight: 600; }
#confirm-inputs input { display: block; width: 100%; margin-top: 4px; font-size: 14px; }
.error { color: var(--danger); background: var(--danger-bg); border-left: 3px solid var(--danger); padding: 8px 10px; border-radius: 4px; font-weight: 500; }
details { margin: 0; border-top: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 500; font-size: 12px; color: var(--muted); }
details[open] summary { margin-bottom: 10px; color: var(--ink); }
#log { font: 12px/1.6 ui-monospace, monospace; padding-left: 20px; max-height: 200px; overflow-y: auto; overflow-wrap: anywhere; }
/* Preserve the QR's intrinsic pixel grid and white quiet zone for phone scanners. */
#receive-qr, #transfer-qr { display: block; margin: 10px auto; background: #fff; max-width: 100%; height: auto; border-radius: 4px; }
.hint { color: var(--muted); font-size: 12px; }
@media (max-width: 380px) {
  body { padding: 12px; }
  #phrase-words { columns: 2; }
  #confirm-inputs { grid-template-columns: 1fr; gap: 0; }
}
@media (forced-colors: active) {
  .vault-mark { border: 1px solid CanvasText; }
  button.primary { border-color: ButtonText; }
}
