:root {
  --bg: #0b0d12;
  --surface: #151922;
  --surface-2: #1d2230;
  --border: #272d3d;
  --text: #e8ebf3;
  --muted: #8a93a8;
  --accent: #7c8cff;
  --accent-text: #0b0d12;
  --danger: #ff5d6c;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark light;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --border: #dde1ec;
    --text: #12151f;
    --muted: #6a7389;
    --accent: #4256f0;
    --accent-text: #ffffff;
    --danger: #d92d3f;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 8px; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.center-text { text-align: center; padding: 32px 16px; }

#app { max-width: 640px; margin: 0 auto; padding: 0 16px calc(96px + var(--safe-b)); }

/* auth */
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 100dvh; gap: 12px; padding: 24px 0; }
.logo { font-size: 56px; }
#register-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }

/* inputs + buttons */
input, textarea, select {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label > input, label > textarea, label > select { margin-top: 6px; color: var(--text); font-size: 16px; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 14px 18px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:not(:disabled):active { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { max-width: 360px; padding: 18px; font-size: 18px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.row { display: flex; gap: 10px; margin: 10px 0; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; padding: 14px 0 8px; background: linear-gradient(var(--bg) 80%, transparent); }
.bar select { font-weight: 600; }
.icon { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 12px; width: 52px; font-size: 22px; cursor: pointer; }
.search { padding-bottom: 12px; }

/* list */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; display: block; width: 100%; text-align: left; color: inherit; font: inherit;
}
.card:active { background: var(--surface-2); }
.card .k { font-weight: 650; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; word-break: break-all; }
.card .n { color: var(--muted); font-size: 13px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.fab {
  position: fixed; right: 20px; bottom: calc(20px + var(--safe-b)); width: 60px; height: 60px; border-radius: 20px;
  border: 0; background: var(--accent); color: var(--accent-text); font-size: 32px; line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35); cursor: pointer;
}
.fab:active { transform: scale(0.94); }

/* bottom sheets */
dialog.sheet {
  border: 0; padding: 12px 20px calc(20px + var(--safe-b)); background: var(--surface); color: var(--text);
  width: 100%; max-width: 640px; margin: auto auto 0; border-radius: 24px 24px 0 0;
  max-height: 92dvh; overflow-y: auto;
}
dialog.sheet::backdrop { background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: up 0.22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto 14px; }
.valuebox { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 12px 0; }
.valuebox code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; word-break: break-all; white-space: pre-wrap; }
#c-input { margin: 8px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: 0.2s; z-index: 100; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); color: #fff; }

@media (min-width: 700px) {
  dialog.sheet { margin: auto; border-radius: 24px; }
}
