:root {
  --canvas: #f7f7f5;
  --surface: #fff;
  --ink: #20201f;
  --ink-soft: #64645e;
  --ink-faint: #6b6b66;
  --line: #e5e5e0;
  --line-strong: #d8d8d3;
  --indigo: #5746e8;
  --indigo-ink: #4938d0;
  --indigo-soft: #eeeaff;
  --amber: #9a6207;
  --amber-soft: #fdf3e3;
  --green: #2f7d47;
  --green-soft: #e9f5ec;
  --red: #aa302b;
  --red-soft: #fbecec;
  --shadow: 0 10px 30px rgba(26, 26, 25, 0.06);
  --radius: 16px;
  --focus: 3px solid #a89bff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-synthesis: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--indigo-ink); }
:focus-visible { outline: var(--focus); outline-offset: 2px; }
.skip {
  position: absolute; left: -999px; top: 8px;
}
.skip:focus { left: 8px; background: #fff; padding: 8px 12px; z-index: 10; }

.app { min-height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand strong { font-size: 16px; }
.brand span, .muted, .hint { color: var(--ink-soft); }
.hint { font-size: 12px; line-height: 1.6; color: var(--ink-faint); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.main { width: 100%; max-width: 1320px; margin: 0 auto; padding: 20px 40px 36px; }
.wallet-main { max-width: 1320px; }
@media (max-width: 700px) { .main { padding: 12px 20px 25px; } }

.lede { margin: 0; color: var(--ink-soft); max-width: 40rem; }
.toolbar-actions { flex: 1; justify-content: flex-end; min-width: min(100%, 280px); }

.wallet-layout {
  display: grid;
  gap: 20px;
  align-items: start;
}
@media (min-width: 900px) {
  .wallet-layout { grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr); }
}

.hero { padding: 48px 0 24px; }
.hero h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.03em; }
.hero p { color: var(--ink-soft); max-width: 38rem; margin: 0 0 12px; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

label, .label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 8px; }
input[type="text"], input[type="email"], input[type="search"], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 9px;
  background: #fff; padding: 11px 12px; font-size: 14px; line-height: 1.25;
}
textarea { min-height: 88px; resize: vertical; }
.dialog textarea { min-height: 72px; }
.dialog-actions {
  position: sticky; bottom: 0; background: #fff;
  padding-top: 14px; margin-top: 14px; border-top: 1px solid var(--line);
}
.field { margin-bottom: 16px; }

.btn, button.btn {
  appearance: none; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 10px 14px; font-weight: 500; font-size: 13px; line-height: 1.4; cursor: pointer;
}
.btn:hover { border-color: #bbb6dc; background: #faf9ff; }
.btn:hover { background: #f3f2ee; }
button.btn-primary, .btn-primary {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
}
button.btn-primary:hover, .btn-primary:hover { background: #4338ca; }
.btn-danger { color: var(--red); border-color: #e8c4c2; }
.btn-danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { border-color: transparent; background: transparent; }
.linkish { background: none; border: 0; color: var(--indigo); padding: 0; font-weight: 600; cursor: pointer; }

.toolbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { flex: 1; min-width: 160px; }
.toolbar .search { padding: 9px 12px; }

.cards { display: grid; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.card.selected { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.card h2 { font-size: 16px; margin: 0; overflow-wrap: anywhere; }
.card p { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
.select-row {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--indigo); margin: 0;
}
.select-row input { width: 18px; height: 18px; accent-color: var(--indigo); }
.overflow { position: relative; display: flex; margin-left: auto; flex-shrink: 0; }
.overflow-trigger { width: 34px; height: 34px; margin: -8px -4px 0 0; padding: 0; display: grid; place-items: center; border-radius: 999px; }
.overflow-trigger .dots { width: 3px; height: 3px; border-radius: 50%; background: currentColor; box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor; }

.preview-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
@media (min-width: 900px) {
  .preview-panel { position: sticky; top: 84px; }
}
.preview-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.preview-head .hint { margin: 4px 0 0; }
.preview-actions { justify-content: flex-start; }

.empty, .banner, .notice, .error, .success {
  border-radius: 12px; padding: 14px 16px; margin: 12px 0;
}
.banner, .notice { background: var(--indigo-soft); color: var(--indigo-ink); }
.demo-banner {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid #efd3a3;
  font-weight: 700;
  text-align: center;
  margin: 0 0 16px;
}
.demo-banner-bar {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  margin: 0;
  padding: 12px 16px;
}
.empty { background: #fff; border: 1px dashed var(--line-strong); color: var(--ink-soft); }
.error { background: var(--red-soft); color: var(--red); }
.success { background: var(--green-soft); color: var(--green); }

.overlay {
  position: fixed; inset: 0; background: #27233366;
  display: flex; align-items: flex-end; justify-content: center; padding: 12px; z-index: 20;
}
@media (min-width: 720px) { .overlay { align-items: center; } }
.dialog {
  width: min(600px, 100%); max-height: calc(100dvh - 32px); overflow: hidden; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 0; box-shadow: 0 25px 80px #0002;
}
.dialog h2 { margin: 0 0 8px; font-size: 19px; }
.dialog-head { padding: 22px 24px; border-bottom: 1px solid var(--line); display: flex; gap: 15px; align-items: flex-start; justify-content: space-between; flex-shrink: 0; }
.dialog-head h2 { margin: 0; }
.dialog-head .hint { margin: 7px 0 0; }
.dialog-head .hint:empty { display: none; }
.dialog-close { border: 0; background: none; padding: 0 5px; margin-top: -2px; font-size: 21px; line-height: 1.3; color: var(--ink-faint); cursor: pointer; border-radius: 10px; }
.dialog-close:hover { color: var(--ink); }
.dialog-body { padding: 24px; overflow: auto; min-height: 0; font-size: 13px; line-height: 1.6; }
.dialog-body input[type="file"] { font-size: 13px; }
.dialog-body .empty { font-size: 13px; }
.preview {
  width: 100%; min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.45; white-space: pre-wrap;
}
#toast {
  position: fixed; right: 16px; bottom: 16px; max-width: min(360px, calc(100% - 32px));
  background: #1a1a19; color: #fff; padding: 12px 14px; border-radius: 12px;
  opacity: 0; transform: translateY(8px); transition: 0.2s ease; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.landing-list { margin: 16px 0 0; padding-left: 18px; color: var(--ink-soft); }
.account { font-size: 13px; color: var(--ink-soft); margin-right: 6px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 0.3: types, compartments, guard, decks, history ---------- */
.pills { gap: 6px; }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card.is-draft { border-style: dashed; border-color: #efd3a3; }
.card .meta { font-size: 12px; color: var(--ink-faint); }
.tags { gap: 6px; }
.tag { background: none; border: 0; padding: 0; color: var(--indigo); font-size: 12px; font-weight: 500; cursor: pointer; }
.tag:hover { text-decoration: underline; }

.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.chips { gap: 6px; }
.chip-check input { accent-color: var(--indigo); margin: 0; width: 13px; height: 13px; }
.decks { gap: 8px; }
.decks select {
  appearance: none;
  width: auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 10px 32px 10px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: 999px;
  box-shadow: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2320201f' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.label.inline { display: inline; margin: 0; }

.drafts {
  background: #faf4e7; color: #80622e;
  border-radius: 9px; padding: 12px; margin: 0 0 20px; font-size: 12px; line-height: 1.6;
}
.drafts .linkish { color: var(--indigo); }

.warnings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.warning { border-radius: 9px; padding: 10px 12px; font-size: 12px; line-height: 1.6; }
.warning-info { background: var(--indigo-soft); color: #544498; }
.warning-warn { background: #faf4e7; color: #80622e; }
.warning-block { background: var(--red-soft); color: var(--red); font-weight: 600; }
#target-select { margin-bottom: 6px; font-size: 13px; padding: 8px 10px; }

.guard { border-radius: 9px; padding: 12px; margin: 0 0 16px; font-size: 13px; line-height: 1.5; }
.guard-warn { background: var(--amber-soft); border: 1px solid #efd3a3; color: var(--amber); }
.guard-block { background: var(--red-soft); border: 1px solid #e8c4c2; color: var(--red); }
.guard .hint { color: inherit; opacity: 0.85; margin: 4px 0 8px; }
.guard-list { margin: 0 0 10px; padding-left: 18px; font-size: 13px; }
.guard-list code { font-size: 12px; background: rgba(255,255,255,0.6); padding: 1px 4px; border-radius: 4px; }
.guard-ok { color: var(--green); }

.type-row { gap: 8px; align-items: stretch; }
.type-row .choice { flex: 1; min-width: 150px; cursor: pointer; }
.type-row .choice small { color: var(--ink-soft); font-weight: 400; }
.type-row input { margin-top: 3px; accent-color: var(--indigo); }
textarea.tall { min-height: 180px; }
.more { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 16px 0; }
.more summary { cursor: pointer; font-weight: 500; font-size: 13px; }
.more[open] summary { margin-bottom: 14px; }
.dialog .field label { margin-bottom: 4px; }
.package {
  white-space: pre-wrap; overflow-wrap: anywhere; background: #f6f5f8; padding: 12px;
  font-size: 12px; max-height: 260px; overflow: auto; border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.versions { display: grid; gap: 8px; margin: 12px 0; }
.version { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.version summary { cursor: pointer; font-weight: 500; font-size: 13px; }
.version .package { margin: 10px 0; }
.receipts { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-soft); }
.dialog h3 { font-size: 14px; margin: 18px 0 8px; }
.dialog p { margin: 0 0 10px; }
.dialog .field > .hint, .dialog textarea + .hint, .dialog input + .hint { margin: 8px 0 0; }
.dialog pre.package { margin: 6px 0 10px; }
.hero strong { color: var(--ink); }
input[type="date"] { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; padding: 11px 12px; font-size: 14px; min-height: 44px; }

.signin-link { display: inline-block; margin-top: 10px; text-decoration: none; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 0; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-faint); }
