/* =========================================================================
   Smart Calendar - dark, dense, keyboard friendly
   ========================================================================= */
:root {
  --bg: #0e1117;
  --panel: #131922;
  --panel-2: #1a2230;
  --panel-3: #202a3a;
  --line: #26303f;
  --line-soft: #1e2734;
  --text: #e6edf7;
  --muted: #8b9ab1;
  --muted-2: #64748b;
  --accent: #6ea8fe;
  --accent-dim: #2a4a7a;
  --danger: #ff7b72;
  --warn: #f2b45f;
  --ok: #56d364;
  --radius: 10px;
  --hour-h: 56px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2c3849; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4a60; background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------- shell ---- */
.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); height: 100vh; }

.rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(150deg, #6ea8fe, #8b5cf6);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #08101d;
}
.brand-name { font-weight: 700; letter-spacing: -.2px; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted-2); letter-spacing: .3px; }

.rail-section { padding: 10px 12px 4px; }
.rail-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted-2); padding: 0 6px 8px; font-weight: 700;
}
.rail-title button {
  background: none; border: none; color: var(--muted); font-size: 15px;
  line-height: 1; padding: 2px 5px; border-radius: 6px;
}
.rail-title button:hover { background: var(--panel-3); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 8px; padding: 7px 11px; font-size: 13px; font-weight: 500;
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: #33415a; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #4d8dfa, #3b78e0);
  border-color: #4d8dfa; color: #fff; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 4px 14px -6px #3b78e0;
}
.btn-primary:hover { background: linear-gradient(180deg, #5b98ff, #4682ea); border-color: #5b98ff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: #4a2a2c; background: #2a1a1d; }
.btn-danger:hover { background: #3a2124; border-color: #6d3739; }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }

.rail .new-task { margin: 2px 12px 14px; }

.bucket {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px; color: var(--muted); font-size: 13px; text-align: left;
}
.bucket:hover { background: var(--panel-2); color: var(--text); }
.bucket.active { background: var(--panel-2); color: var(--text); border-color: #2b3a52; }
.bucket .swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.bucket .count {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--panel-3); color: var(--muted);
  padding: 1px 7px; border-radius: 20px; min-width: 22px; text-align: center;
}
.bucket.active .count { background: var(--accent-dim); color: #cfe0ff; }
.bucket .count.hot { background: #4a2a2c; color: #ffb4af; }

.group-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; border-radius: 8px;
  padding: 7px 10px; color: var(--muted); font-size: 13px; text-align: left;
}
.group-row:hover { background: var(--panel-2); color: var(--text); }
.group-row.off { opacity: .42; }
.group-row .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.group-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row .count { margin-left: auto; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.group-row .g-edit {
  opacity: 0; margin-left: 2px; background: none; border: none; color: var(--muted-2);
  font-size: 13px; padding: 0 2px; border-radius: 4px;
}
.group-row:hover .g-edit { opacity: 1; }
.group-row .g-edit:hover { color: var(--text); }

.empty-note { color: var(--muted-2); font-size: 12px; padding: 6px 12px 10px; line-height: 1.5; }
.rail-foot { margin-top: auto; padding: 14px 18px 0; font-size: 11px; color: var(--muted-2); line-height: 1.6; }
.rail-foot kbd {
  font-family: var(--mono); font-size: 10px; background: var(--panel-3);
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; color: var(--muted);
}

/* ----------------------------------------------------------- toolbar ---- */
.stage { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #141b25, #111721);
  flex: none; min-height: 60px;
}
.tb-nav { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); font-size: 14px; line-height: 1;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.tb-label { font-size: 17px; font-weight: 650; letter-spacing: -.3px; min-width: 0; }
.tb-label .sub { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.tb-spacer { flex: 1; }

.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button {
  border: none; background: none; color: var(--muted); font-size: 12.5px;
  padding: 5px 12px; border-radius: 7px; font-weight: 550;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3); }

.search { position: relative; }
.search input {
  width: 190px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px 7px 30px; font-size: 13px; outline: none;
}
.search input:focus { border-color: var(--accent-dim); background: #16202d; }
.search input::placeholder { color: var(--muted-2); }
.search::before {
  content: "⌕"; position: absolute; left: 10px; top: 50%; transform: translateY(-52%);
  color: var(--muted-2); font-size: 15px; pointer-events: none;
}

.view { flex: 1; overflow: auto; min-height: 0; position: relative; }

/* -------------------------------------------------------- month view ---- */
.month { display: flex; flex-direction: column; height: 100%; }
.weekhead {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line); flex: none;
}
.weekhead div {
  padding: 8px 10px; font-size: 11px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--muted-2);
}
.weekhead div.we { color: #5b6b83; }
.month-grid {
  flex: 1; display: grid; grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(var(--weeks, 6), minmax(74px, 1fr));
  min-height: 0;
}
.day-cell {
  border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  padding: 5px 6px; display: flex; flex-direction: column; gap: 3px;
  min-width: 0; overflow: hidden; position: relative;
  transition: background .1s;
}
.day-cell:nth-child(7n) { border-right: none; }
.day-cell:hover { background: #131a24; }
.day-cell.dim { background: #0b0f15; }
.day-cell.dim .day-num { color: #3d4859; }
.day-cell.we { background: #101720; }
.day-cell.we.dim { background: #0b0f15; }
.day-cell.today { background: #14203280; box-shadow: inset 0 0 0 1px #2d4a72; }
.day-cell.drop { background: #1b2d47; box-shadow: inset 0 0 0 1px var(--accent); }
.day-num {
  font-size: 12px; font-weight: 600; color: var(--muted);
  width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%;
  font-variant-numeric: tabular-nums; flex: none;
}
.day-cell.today .day-num { background: var(--accent); color: #06101f; }
.day-items { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.more { font-size: 10.5px; color: var(--muted-2); padding-left: 4px; }

/* chips */
.chip {
  --c: var(--accent);
  display: flex; align-items: center; gap: 5px; width: 100%;
  background: color-mix(in srgb, var(--c) 14%, #131a24);
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  border-left: 2.5px solid var(--c);
  border-radius: 5px; padding: 2px 5px; font-size: 11.5px; text-align: left;
  color: var(--text); overflow: hidden; cursor: pointer;
  transition: filter .1s;
}
.chip:hover { filter: brightness(1.28); }
.chip.done { opacity: .48; }
.chip.done .chip-title { text-decoration: line-through; }
.chip.blocked { border-left-style: dashed; }
.chip.dragging { opacity: .4; }
.chip.overdue { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, #131a24); }
.chip-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 10.5px; flex: none; }
.chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-lock { margin-left: auto; font-size: 9px; opacity: .75; flex: none; }

/* ---------------------------------------------------------- day view ---- */
.daybar {
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); flex: none;
}
.daybar .dow { font-size: 13px; font-weight: 650; }
.daybar .dow span { color: var(--muted); font-weight: 500; }
.daybar .pill {
  font-size: 11px; padding: 2px 9px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}

.canvas-wrap { display: flex; }
.gutter { width: 62px; flex: none; position: relative; }
.gutter .hl {
  height: var(--hour-h); font-size: 10.5px; color: var(--muted-2);
  text-align: right; padding-right: 9px; font-variant-numeric: tabular-nums;
  transform: translateY(-7px);
}
.gutter .hl:first-child { transform: none; padding-top: 2px; }
.canvas {
  flex: 1; position: relative; border-left: 1px solid var(--line-soft);
  margin-right: 14px; min-width: 0;
}
.hour-row {
  height: var(--hour-h); border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: background .1s;
}
.hour-row:hover { background: #131a24; }
.hour-row.drop { background: #1b2d47; }
.half-rule { border-bottom: 1px dashed #18202c; height: 0; margin-top: calc(var(--hour-h) / 2 - 1px); position: relative; }
.evt {
  --c: var(--accent);
  position: absolute; border-radius: 6px; padding: 3px 7px;
  background: color-mix(in srgb, var(--c) 20%, #101720);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  border-left: 3px solid var(--c); overflow: hidden; cursor: pointer;
  font-size: 11.5px; line-height: 1.35; z-index: 2;
}
.evt:hover { filter: brightness(1.25); z-index: 5; }
.evt.done { opacity: .5; }
.evt.done .evt-title { text-decoration: line-through; }
.evt-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evt-meta { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.evt .evt-lock { font-size: 9px; color: var(--warn); margin-left: 4px; }
.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--danger); z-index: 4; pointer-events: none; }
.now-line::before {
  content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--danger);
}
.day-empty { padding: 26px; color: var(--muted-2); font-size: 13px; }

/* --------------------------------------------------------- hour view ---- */
.hour-wrap { display: flex; gap: 0; }
.min-gutter { width: 56px; flex: none; }
.min-gutter .mg {
  height: 24px; font-size: 10px; color: var(--muted-2); text-align: right;
  padding-right: 9px; font-variant-numeric: tabular-nums; transform: translateY(-6px);
}
.min-gutter .mg.ten { color: var(--muted); }
.min-canvas { flex: 1; position: relative; border-left: 1px solid var(--line-soft); margin-right: 14px; }
.min-row { height: 24px; border-bottom: 1px solid #161e29; cursor: pointer; }
.min-row:hover { background: #131a24; }
.min-row.ten { border-bottom-color: #1f2937; }
.hour-side { width: 320px; flex: none; border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; }
.hour-side h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted-2); margin: 0 0 10px; }
.hour-side .hc {
  border: 1px solid var(--line); border-left: 3px solid var(--c, var(--accent));
  background: var(--panel); border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer;
}
.hour-side .hc:hover { background: var(--panel-2); }
.hour-side .hc .t { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.hour-side .hc .m { font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------- year view --- */
.year {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  padding: 16px 18px 30px; align-content: start;
}
.mini { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 11px 12px; }
.mini-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 7px; cursor: pointer; border-radius: 6px; padding: 2px 3px;
}
.mini-head:hover { background: var(--panel-2); }
.mini-head .m-name { font-size: 12.5px; font-weight: 650; }
.mini-head .m-count { font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mini-grid .wd { font-size: 9px; color: var(--muted-2); text-align: center; font-weight: 700; }
.mini-day {
  aspect-ratio: 1; display: grid; place-items: center; border: none; background: none;
  border-radius: 5px; font-size: 10.5px; color: var(--muted); position: relative;
  font-variant-numeric: tabular-nums; padding: 0;
}
.mini-day:hover { background: var(--panel-3); color: var(--text); }
.mini-day.out { color: #333e4e; }
.mini-day.today { background: var(--accent); color: #06101f; font-weight: 700; }
.mini-day.l1 { color: #a8c8ff; background: #1a2740; }
.mini-day.l2 { color: #cfe0ff; background: #22395c; }
.mini-day.l3 { color: #fff; background: #2f4f7d; }
.mini-day.today.l1, .mini-day.today.l2, .mini-day.today.l3 { background: var(--accent); color: #06101f; }

/* -------------------------------------------------------- bucket view --- */
.bucket-view { padding: 18px 20px 40px; max-width: 940px; }
.bv-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.bv-head h2 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.bv-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; line-height: 1.6; max-width: 640px; }
.bv-empty {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px;
  text-align: center; color: var(--muted-2); font-size: 13px;
}
.bcard {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--accent));
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 9px;
  transition: border-color .12s, background .12s;
}
.bcard:hover { background: var(--panel-2); }
.bcard-main { min-width: 0; flex: 1; cursor: pointer; }
.bcard-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; }
.bcard-title.done { text-decoration: line-through; opacity: .55; }
.bcard-meta { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.bcard-meta .reason-blocked { color: var(--warn); }
.bcard-meta .reason-missed { color: var(--danger); }
.bcard-actions { display: flex; gap: 6px; flex: none; padding-top: 1px; }
.tag {
  font-size: 10px; padding: 1px 7px; border-radius: 20px;
  background: var(--panel-3); color: var(--muted); border: 1px solid var(--line);
}
.tag.grp { border-color: color-mix(in srgb, var(--c) 40%, transparent); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }

/* ------------------------------------------------------------- modal ---- */
.modal-root:empty { display: none; }
.overlay {
  position: fixed; inset: 0; background: #05080dcc; backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; z-index: 100; overflow-y: auto;
}
.dialog {
  width: 100%; max-width: 620px; background: var(--panel);
  border: 1px solid #2c3849; border-radius: 14px;
  box-shadow: 0 24px 70px -12px #000, 0 0 0 1px #ffffff08 inset;
  display: flex; flex-direction: column; max-height: 88vh;
}
.dialog.sm { max-width: 380px; }
.dlg-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.dlg-head h3 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.1px; }
.dlg-head .spacer { flex: 1; }
.dlg-body { padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; }
.dlg-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--line); background: #10161f;
  border-radius: 0 0 14px 14px;
}
.dlg-foot .spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted-2); font-weight: 700; }
.inp, .sel, .ta {
  width: 100%; background: #0f151d; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; outline: none;
  transition: border-color .12s, background .12s;
}
.inp:focus, .sel:focus, .ta:focus { border-color: var(--accent-dim); background: #121b26; }
.ta { resize: vertical; min-height: 58px; font-family: inherit; }
.sel { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row.tight { gap: 8px; }
.title-inp { font-size: 15px; font-weight: 600; padding: 9px 11px; }

.chk { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); user-select: none; cursor: pointer; }
.chk input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.dep-block { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #0f151d; }
.dep-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }
.dep-head .t { font-size: 11.5px; font-weight: 700; letter-spacing: .3px; color: var(--muted); text-transform: uppercase; }
.dep-head .cnt { font-size: 10.5px; background: var(--panel-3); color: var(--muted); padding: 1px 7px; border-radius: 20px; }
.dep-head input { flex: 1; min-width: 0; background: #121b26; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 12px; outline: none; }
.dep-head input:focus { border-color: var(--accent-dim); }
.dep-list { max-height: 132px; overflow-y: auto; padding: 4px; }
.dep-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 7px;
  border-radius: 6px; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.dep-item:hover { background: var(--panel-2); color: var(--text); }
.dep-item input { width: 14px; height: 14px; accent-color: var(--accent); flex: none; }
.dep-item .ti { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-item .dt { font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; flex: none; }
.dep-item .st-dot { width: 5px; height: 5px; border-radius: 50%; flex: none; }
.dep-empty { padding: 10px; font-size: 12px; color: var(--muted-2); text-align: center; }
.hint { font-size: 11.5px; color: var(--muted-2); line-height: 1.55; }
.hint b { color: var(--muted); font-weight: 600; }

.toast-wrap { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: flex-end; }
.toast {
  background: var(--panel-2); border: 1px solid #33415a; border-left: 3px solid var(--warn);
  border-radius: 9px; padding: 10px 14px; font-size: 12.5px; max-width: 380px;
  box-shadow: 0 12px 30px -12px #000; animation: toast-in .18s ease-out;
  line-height: 1.5;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid #ffffff33; border-top-color: #fff; border-radius: 50%; animation: sp .6s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .year { grid-template-columns: repeat(2, 1fr); }
  .search input { width: 120px; }
}

/* ------------------------------------------------------- empty state ---- */
.empty-hint {
  position: absolute; right: 20px; bottom: 20px; width: 320px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 18px 44px -18px #000;
}
.empty-hint .eh-title { font-weight: 650; font-size: 13px; margin-bottom: 7px; }
.empty-hint p { margin: 0 0 8px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.empty-hint p:last-child { margin-bottom: 0; }
.empty-hint b { color: var(--text); font-weight: 600; }
.empty-hint kbd {
  font-family: var(--mono); font-size: 10px; background: var(--panel-3);
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; color: var(--muted);
}

/* =========================================================================
   Auth screen + account settings
   ========================================================================= */
.signed-out .app { display: none; }

.auth-root { display: none; }
.signed-out .auth-root {
  display: grid;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 200;
  padding: 24px;
  background:
    radial-gradient(1000px 600px at 15% -10%, #17233a 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #1b1a33 0%, transparent 55%),
    var(--bg);
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.auth-title { font-size: 15px; font-weight: 650; letter-spacing: -.2px; }
.auth-sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 4px;
  margin-bottom: 16px;
}
.auth-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
}
.auth-tabs button:hover { color: var(--text); }
.auth-tabs button.on { background: var(--panel-3); color: var(--text); }

#auth-form { display: flex; flex-direction: column; gap: 13px; }
#auth-form .btn-block { margin-top: 3px; }
.auth-error {
  font-size: 12px;
  color: var(--danger);
  background: #2a1a1d;
  border: 1px solid #4a2a2c;
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.5;
}
.auth-note { margin-top: 16px; font-size: 11.5px; color: var(--muted-2); line-height: 1.6; }
.auth-note b { color: var(--muted); }

/* ---- account settings panel ---- */
.settings-sec { display: flex; flex-direction: column; gap: 9px; }
.settings-sec .rail-title { padding: 0; }
.settings-sec .hint code { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.acct-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.acct-row .spacer { flex: 1; }

.key-new { display: flex; gap: 8px; }
.key-new .inp { flex: 1; min-width: 0; }
.key-list { display: flex; flex-direction: column; gap: 6px; }
.key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 8px 10px;
}
.key-main { min-width: 0; flex: 1; }
.key-name { font-size: 12.5px; font-weight: 600; }
.key-meta { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.key-meta code { font-family: var(--mono); }

.secret-box {
  background: #16241b;
  border: 1px solid #2c4a33;
  border-radius: 9px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.secret-row { display: flex; align-items: center; gap: 8px; }
.secret-row code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ok);
  word-break: break-all;
  flex: 1;
  user-select: all;
}

.snippet {
  margin: 0;
  background: #101720;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  overflow-x: auto;
  white-space: pre;
}

/* ---- rail identity footer ---- */
.rail-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.rail-email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--muted);
}
