/* ------------------------------------------------------------------
   Notif Archive — dashboard styles
   ------------------------------------------------------------------ */
:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --surface-3: #eeece6;
  --ink: #17171c;
  --ink-2: #4a4a55;
  --muted: #7a7a86;
  --line: #e4e2db;
  --accent: #5446e8;
  --accent-ink: #ffffff;
  --accent-soft: #ecebfd;
  --bubble: #ffffff;
  --danger: #d23c3c;
  --danger-soft: #fdecec;
  --ok: #1f8a5b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 8px 24px rgba(20, 20, 30, .06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12;
    --surface: #16161c;
    --surface-2: #1b1b22;
    --surface-3: #24242d;
    --ink: #ededf2;
    --ink-2: #b9b9c6;
    --muted: #84849a;
    --line: #2a2a34;
    --accent: #8b80ff;
    --accent-ink: #0e0e12;
    --accent-soft: #24223f;
    --bubble: #1f1f27;
    --danger: #ff6b6b;
    --danger-soft: #3a1c1f;
    --ok: #4cc38a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Controls ---------- */
input:not([type="checkbox"]) {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  min-width: 0;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.btn {
  font: inherit; font-weight: 550;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .05s, filter .15s, background .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--line); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 550; cursor: pointer; padding: 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.stack { display: grid; gap: 14px; }
.narrow { max-width: 380px; }
.form-error { color: var(--danger); font-size: 13px; }
.form-error.ok { color: var(--ok); }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; }

/* ---------- Boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background:
    radial-gradient(circle at 72% 28%, #fff 0 3px, transparent 3.5px),
    linear-gradient(135deg, var(--accent), #c04bd8);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.brand-lg { font-size: 17px; margin-bottom: 22px; }
.brand-lg .brand-mark { width: 32px; height: 32px; border-radius: 10px; }

/* ---------- Auth ---------- */
.auth {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, var(--accent-soft), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 32px; box-shadow: var(--shadow);
}
.auth-card h1 { margin-bottom: 6px; }
.auth-card > .muted { margin-bottom: 24px; }
.auth-switch { margin-top: 18px; text-align: center; color: var(--muted); }
.auth-foot { margin-top: 18px; font-size: 12.5px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; height: 100dvh; }
.rail {
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface);
}
.rail .brand { padding: 4px 10px 18px; }
.rail-item {
  display: flex; align-items: center; gap: 12px;
  font: inherit; font-weight: 520; color: var(--ink-2);
  padding: 9px 10px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; text-align: left;
}
.rail-item:hover { background: var(--surface-3); color: var(--ink); }
.rail-item.active { background: var(--accent-soft); color: var(--accent); }
.rail-spacer { flex: 1; }
.rail-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-top: 1px solid var(--line); margin-top: 8px;
}
.rail-user-meta { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.rail-user-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rail-user-meta span { font-size: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 650; font-size: 13px;
  color: #fff; background: var(--accent);
}
.view { min-width: 0; min-height: 0; overflow: hidden; }

/* ---------- Inbox ---------- */
.view-inbox { display: flex; }
.inbox { flex: 1; display: grid; grid-template-columns: minmax(300px, 380px) 1fr; min-height: 0; }
.list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.pane-head { padding: 18px 16px 10px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
.stat b { display: block; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; color: var(--muted); }
.search input { width: 100%; padding-left: 36px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  font: inherit; font-size: 12.5px; font-weight: 520; white-space: nowrap;
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }

.conv-list { flex: 1; overflow-y: auto; padding: 6px; }
.conv {
  display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center;
  width: 100%; text-align: left; font: inherit; color: inherit;
  padding: 10px; border-radius: 12px; border: 0; background: transparent; cursor: pointer;
}
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--accent-soft); }
.conv-avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 650; font-size: 15px; color: #fff;
}
.conv-main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.conv-sub { display: flex; align-items: center; gap: 8px; }
.conv-preview { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-app { font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--surface-3); padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.conv-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.thread-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head {
  display: flex; align-items: center; gap: 10px;
  min-height: 64px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.thread-head:empty, .thread-title:empty { visibility: hidden; }
.thread-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thread-title .conv-avatar { width: 36px; height: 36px; border-radius: 10px; font-size: 14px; }
.thread-title > div > strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-title > div { min-width: 0; }
.thread-title > div > span { font-size: 12px; color: var(--muted); }
.back-btn { display: none; }
.thread { flex: 1; overflow-y: auto; padding: 20px clamp(16px, 4vw, 48px) 32px; display: flex; flex-direction: column; gap: 6px; }
.day-sep {
  align-self: center; margin: 14px 0 6px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px;
}
.bubble {
  align-self: flex-start; max-width: min(640px, 82%);
  background: var(--bubble); border: 1px solid var(--line);
  border-radius: 16px 16px 16px 6px; padding: 9px 13px 7px;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.02);
}
.bubble.outgoing { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-color: transparent; border-radius: 16px 16px 6px 16px; }
.bubble.outgoing .meta { color: inherit; opacity: .7; }
.bubble mark { background: #ffe58a; color: #17171c; border-radius: 3px; padding: 0 1px; }
.bubble .sender { display: block; font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.bubble .meta { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.placeholder { margin: auto; text-align: center; max-width: 320px; display: grid; gap: 8px; justify-items: center; }
.placeholder-art {
  width: 72px; height: 72px; border-radius: 22px; margin-bottom: 8px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--accent), #c04bd8) border-box;
  border: 2px dashed transparent;
  opacity: .8;
}
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty.error { color: var(--danger); }

/* skeleton loaders */
.skel { height: 60px; margin: 4px 6px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Pages (keys, account, users) ---------- */
.page { overflow-y: auto; padding: 32px clamp(16px, 4vw, 48px) 48px; }
.page > * { max-width: 820px; }
.page-head { margin-bottom: 22px; }
.page-head p { margin-top: 6px; max-width: 560px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; display: grid; gap: 14px;
}
.row-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-form input { flex: 1 1 180px; }
.new-key { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 10px; }
.key-box { display: flex; gap: 8px; align-items: center; }
.key-box code { flex: 1; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; white-space: nowrap; font-size: 13px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); }
.table-list { display: grid; }
.trow {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.trow:first-child { border-top: 0; padding-top: 0; }
.trow-main { min-width: 0; display: grid; gap: 2px; }
.trow-main strong { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.trow-main span { font-size: 12.5px; color: var(--muted); }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.danger-zone .btn { justify-self: start; }

/* ---------- Toast & dialog ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px;
  font-weight: 520; box-shadow: var(--shadow); z-index: 50; max-width: calc(100% - 32px);
  animation: rise .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
.dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(420px, calc(100% - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(10, 10, 15, .45); }
.dialog form { display: grid; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 64px 1fr; }
  .rail { padding: 14px 8px; align-items: center; }
  .rail .brand { padding: 4px 0 14px; }
  .brand-text, .rail-item span, .rail-user-meta { display: none; }
  .rail-item { justify-content: center; width: 44px; height: 44px; padding: 0; }
  .rail-user { flex-direction: column; padding: 10px 0 0; }
}
@media (max-width: 680px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail {
    order: 2; flex-direction: row; justify-content: space-around; align-items: center;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line);
  }
  .rail .brand, .rail-spacer, .rail-user .avatar { display: none; }
  .rail-user { border: 0; margin: 0; padding: 0; }
  .inbox { grid-template-columns: 1fr; }
  .inbox .thread-pane { display: none; }
  .inbox.show-thread .list-pane { display: none; }
  .inbox.show-thread .thread-pane { display: flex; }
  .back-btn { display: inline-grid; }
  .thread-head { padding: 10px 12px; }
  .page { padding: 22px 16px 32px; }
  .auth-card { padding: 24px; }
}
