/* Bundle — "sealed parcel": warm ink, honey accent, the notch as signature. */

:root {
  --bg:        #efe9df;
  --panel:     #fbf8f2;
  --panel-2:   #f4eee4;
  --ink:       #1d1813;
  --muted:     rgba(29, 24, 19, 0.58);
  --line:      rgba(29, 24, 19, 0.13);
  --line-firm: rgba(29, 24, 19, 0.22);
  --accent:    #d9852b;   /* honey */
  --accent-ink:#3a2408;
  --sage:      #5d8a69;   /* "encrypted / done" */
  --danger:    #b4472f;
  --shadow:    0 1px 2px rgba(29,24,19,.06), 0 12px 40px rgba(29,24,19,.10);
  --radius:    18px;
  --notch:     20px;      /* size of the corner notch */
  --maxw:      560px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14110d;
    --panel:     #1f1a14;
    --panel-2:   #271f17;
    --ink:       #f1e9dc;
    --muted:     rgba(241, 233, 220, 0.60);
    --line:      rgba(241, 233, 220, 0.13);
    --line-firm: rgba(241, 233, 220, 0.24);
    --accent:    #e7993f;
    --accent-ink:#241402;
    --sage:      #82b890;
    --danger:    #e0795f;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 18px 50px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in oklab, var(--accent) 10%, transparent), transparent 60%),
    var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.font-notch {
  font-family: "Stack Sans Notch", ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "ss01";
}
.mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace; }

/* ---- shell ---- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(20px, 6vw, 44px) 20px 80px;
}
header.top {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: clamp(20px, 5vw, 34px);
}
.wordmark { font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1; }
.tagline { margin-left: auto; font-size: 13px; color: var(--muted); }

/* ---- card ---- */
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 30px);
}
.card + .card { margin-top: 18px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.card .sub { font-size: 13px; color: var(--muted); margin: 0 0 18px; }

/* ---- segmented control ---- */
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; margin-bottom: 18px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px; border-radius: 9px; cursor: pointer; transition: .15s;
}
.seg button[aria-selected="true"] {
  background: var(--panel); color: var(--ink);
  box-shadow: 0 1px 2px rgba(29,24,19,.12);
}

/* ---- dropzone ---- */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 170px; width: 100%;
  border: 1.5px dashed var(--line-firm); border-radius: 14px;
  padding: 30px 20px; text-align: center; cursor: pointer;
  transition: .15s; background: var(--panel-2);
}
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 7%, var(--panel-2)); }
.drop .big { font-size: 15px; font-weight: 600; }
.drop .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

textarea {
  width: 100%; min-height: 150px; resize: vertical;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; font: inherit; font-size: 15px;
}
textarea:focus, .drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* file picked summary */
.picked {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.picked .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked .sz { color: var(--muted); flex: none; }
.picked .x { margin-left: auto; flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }

/* ---- options ---- */
.opts { margin-top: 18px; display: grid; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row label { font-size: 14px; font-weight: 500; }
.row .desc { font-size: 12px; color: var(--muted); }
select {
  font: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line-firm); border-radius: 10px;
  background: var(--panel); color: var(--ink); cursor: pointer;
}
input[type="number"] {
  width: 84px; font: inherit; padding: 8px 10px;
  border: 1px solid var(--line-firm); border-radius: 10px;
  background: var(--panel); color: var(--ink);
}
/* switch */
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: var(--line-firm); border-radius: 999px; transition: .18s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: var(--panel); border-radius: 50%; transition: .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--sage); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- buttons ---- */
.btn {
  width: 100%; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  font-size: 15px; padding: 14px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  transition: .15s; margin-top: 20px;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-firm); margin-top: 10px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---- encrypted note ---- */
.enote {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--sage); margin-top: 14px; font-weight: 500;
}
.enote svg { flex: none; }

/* ---- progress ---- */
.prog { margin-top: 16px; }
.bar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.prog .label { font-size: 13px; color: var(--muted); margin-top: 8px; display: flex; justify-content: space-between; }

/* ---- result (QR + link) ---- */
.qr {
  display: grid; place-items: center; padding: 18px; background: #fff;
  border-radius: 14px; border: 1px solid var(--line); width: max-content; margin: 4px auto 18px;
}
.qr img, .qr canvas { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.linkbox {
  display: flex; gap: 8px; align-items: stretch;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px;
}
.linkbox input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font-size: 13px; }
.linkbox button { flex: none; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.meta-line { font-size: 12.5px; color: var(--muted); margin-top: 14px; text-align: center; }

/* ---- pickup code (mobile -> desktop) ---- */
.pickup { margin-top: 16px; text-align: center; }
.bigcode {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 38px; font-weight: 700; letter-spacing: .18em;
  color: var(--ink); margin: 6px 0 4px; padding-left: .18em;
}
.pickup .hint { font-size: 12.5px; color: var(--muted); }

/* a compact "receive a code" row on the sender */
.receive-row { display: flex; gap: 8px; align-items: stretch; margin-top: 4px; }
.receive-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; letter-spacing: .3em;
  text-align: center; padding: 12px; border: 1px solid var(--line-firm);
  border-radius: 12px; background: var(--panel-2); color: var(--ink);
}
.receive-row input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.receive-row button { flex: none; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 12px; padding: 0 18px; cursor: pointer; }

/* ---- code gate ---- */
.gate { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.gate h1 { font-size: 40px; margin: 0 0 8px; letter-spacing: -0.025em; line-height: 1; }
.gate p { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

/* six-cell code input: a row of dots with one hidden input capturing keys */
.code { position: relative; display: flex; gap: 10px; justify-content: center; cursor: text; }
.code-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; background: transparent; font-size: 16px;
  text-align: center; letter-spacing: 2em; cursor: text;
}
.code-cell {
  width: 44px; height: 54px; border: 1.5px solid var(--line-firm); border-radius: 12px;
  background: var(--panel); display: grid; place-items: center; transition: .15s;
}
.code-cell.filled { border-color: var(--accent); }
.code-cell .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); transform: scale(0); transition: transform .12s; }
.code-cell.filled .dot { transform: scale(1); }
.code.has-focus .code-cell.next { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
.code.error .code-cell { border-color: var(--danger); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---- open page states ---- */
.center { text-align: center; padding: 8px 0; }
.filebig { font-size: 19px; font-weight: 600; margin: 6px 0 2px; word-break: break-word; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.err { color: var(--danger); font-size: 14px; font-weight: 500; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 500; opacity: 0; transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer.foot { text-align: center; margin-top: 26px; font-size: 12px; color: var(--muted); }
footer.foot a { color: var(--muted); }

/* ---- header nav ---- */
.nav { margin-left: auto; display: flex; gap: 14px; }
.navlink { background: none; border: 0; cursor: pointer; font: inherit; font-size: 13px; color: var(--muted); padding: 4px 0; }
.navlink:hover { color: var(--ink); }
.navlink:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---- history ---- */
.hist-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.ghostlink { background: none; border: 0; cursor: pointer; font: inherit; font-size: 13px; color: var(--danger); padding: 2px 0; flex: none; }
.ghostlink:hover { text-decoration: underline; }
.hist-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.hist-item:first-child { border-top: 0; }
.hist-body { min-width: 0; flex: 1; }
.hist-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.hist-actions { display: flex; gap: 8px; flex: none; }
.iconbtn { background: var(--panel-2); border: 1px solid var(--line-firm); color: var(--ink); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.iconbtn:hover { border-color: var(--accent); }
.iconbtn.danger { color: var(--danger); }
.pill { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.pill-active   { background: color-mix(in oklab, var(--sage) 22%, transparent); color: var(--sage); }
.pill-expired,
.pill-exhausted{ background: var(--panel-2); color: var(--muted); }
.pill-burned,
.pill-revoked  { background: color-mix(in oklab, var(--danger) 16%, transparent); color: var(--danger); }

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
