:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8b93a3;
  --accent: #d4a73a;
  --accent-ink: #1a1405;
  --danger: #e5534b;
  --ok: #3fb68b;
  --high: #e5534b;
  --medium: #d4a73a;
  --low: #5b6577;
  --radius: 12px;
  --tabbar: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8; --panel: #ffffff; --panel-2: #eef0f4; --line: #dde1e8;
    --text: #161a22; --muted: #5f6878; --accent: #a87b12; --accent-ink: #fff;
    --low: #9aa3b2;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

header.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
header.top h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 650; letter-spacing: .2px; }
main { max-width: 860px; margin: 0 auto; padding: 14px 16px 24px; }

nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
nav.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 550;
}
nav.tabbar a svg { width: 24px; height: 24px; }
nav.tabbar a.active { color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chip.small { padding: 5px 11px; font-size: 13px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 620; overflow-wrap: anywhere; }
.card .body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); margin-top: 6px; }
.card .body.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.pin { color: var(--accent); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; font-weight: 550; min-height: 38px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13.5px; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 6px; cursor: pointer; display: inline-flex; }
.icon-btn svg { width: 20px; height: 20px; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); z-index: 9;
  width: 56px; height: 56px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }

label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=url], input[type=search], textarea, select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none; font-size: 16px; /* 16px stops iOS zooming on focus */
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 180px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14.5px; }
.search { margin-bottom: 12px; }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--panel); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet h2 { margin: 0 0 14px; font-size: 18px; }

.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin-top: 8px; overflow-wrap: anywhere; user-select: all;
}
.badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 650;
  padding: 2px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}

.login { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; text-align: center; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 14px; }
.login h1 { font-size: 22px; margin: 0 0 22px; }
.login form { text-align: left; }
.err { color: var(--danger); font-size: 14px; margin: 8px 0; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }

/* calendar */
.cal-day { margin: 18px 0 8px; font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.ev {
  display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: start;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.ev:first-of-type { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.ev-group { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ev-group .ev:last-child { border-bottom: 0; }
.ev .t { font-variant-numeric: tabular-nums; font-weight: 600; }
.ev .name { font-weight: 550; overflow-wrap: anywhere; }
.ev .nums { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.ev .nums b { color: var(--text); font-weight: 600; }
.ev.past { opacity: .55; }
.ev.next { box-shadow: inset 3px 0 0 var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.high { background: var(--high); } .dot.medium { background: var(--medium); } .dot.low { background: var(--low); }
.ccy { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-right: 6px; }
.banner {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px;
}
.banner .big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.filters { display: grid; gap: 4px; margin-bottom: 4px; }

table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
section.settings h2 { font-size: 15px; margin: 22px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 84px);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 550;
}
