:root {
  --bg: #050000;
  --panel: rgba(18, 2, 4, 0.82);
  --panel-solid: #120204;
  --line: rgba(255, 26, 46, 0.35);
  --line-soft: rgba(255, 26, 46, 0.16);
  --red: #ff1a2e;
  --red-hot: #ff4d5e;
  --red-dim: #a3121f;
  --text: #ffe3e6;
  --muted: #c9868d;
  --fire: #ff8a1f;
  --ok: #ff9aa4;
  --glow: 0 0 12px rgba(255, 26, 46, 0.45);
  --mono: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
#bg-rain { position: fixed; inset: 0; width: 100%; height: 100%; opacity: 0.18; pointer-events: none; z-index: 0; }
#app { position: relative; z-index: 1; min-height: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--red-hot); }
img { max-width: 100%; }

/* ---------- controls ---------- */
.btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--red-hot);
  padding: 9px 14px;
  letter-spacing: 0.14em;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: rgba(255, 26, 46, 0.1); box-shadow: var(--glow); }
.btn.solid { background: var(--red); color: #140003; border-color: var(--red); font-weight: bold; }
.btn.solid:hover { background: var(--red-hot); }
.btn.small { padding: 5px 9px; font-size: 11px; }
.btn.danger { color: #ff8090; border-color: rgba(255, 128, 144, 0.4); }
.btn:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
.field, textarea.field, select.field {
  width: 100%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
}
.field:focus { border-color: var(--red); box-shadow: var(--glow); }
textarea.field { resize: vertical; min-height: 80px; }
label.lbl { display: block; font-size: 11px; letter-spacing: 0.2em; color: var(--muted); margin: 12px 0 5px; text-transform: uppercase; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; letter-spacing: 0.12em; }
.hidden { display: none !important; }

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px 16px;
}
.login img { width: min(320px, 72vw); filter: drop-shadow(0 0 18px rgba(255, 26, 46, 0.5)); }
.login form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login .field { text-align: center; letter-spacing: 0.3em; font-size: 16px; padding: 14px; }
.login .err { color: #ff8090; min-height: 1.2em; text-align: center; font-size: 13px; }
.greet { text-align: center; letter-spacing: 0.3em; color: var(--red-hot); text-shadow: var(--glow); font-size: 18px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(5, 0, 0, 0.88);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; cursor: pointer; text-decoration: none; color: var(--text); }
.topbar .brand img { height: 34px; }
.topbar .brand span { letter-spacing: 0.28em; font-size: 13px; color: var(--red-hot); text-shadow: var(--glow); }
.topbar .who { margin-left: auto; font-size: 12px; letter-spacing: 0.16em; color: var(--muted); text-align: right; }
.topbar .who b { color: var(--text); font-weight: normal; display: block; }
.view { max-width: 1180px; margin: 0 auto; padding: 18px 16px 90px; }
.view h1 {
  font-size: 15px;
  letter-spacing: 0.32em;
  color: var(--red-hot);
  text-shadow: var(--glow);
  margin: 6px 0 16px;
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 12px;
}
.back { cursor: pointer; color: var(--muted); font-size: 12px; letter-spacing: 0.2em; }
.back:hover { color: var(--red-hot); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
}
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--red);
  border-style: solid;
}
.panel::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.panel::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }
.panel-title { font-size: 11px; letter-spacing: 0.26em; color: var(--muted); margin-bottom: 10px; text-transform: uppercase; }

/* ---------- HUD home ---------- */
.hud-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.hud-head .hello { font-size: 13px; letter-spacing: 0.3em; color: var(--muted); }
.hud-head .hello b { display: block; color: var(--text); font-size: 20px; letter-spacing: 0.18em; font-weight: normal; margin-top: 4px; }
.hud-head .clock { font-size: 28px; color: var(--red-hot); text-shadow: var(--glow); letter-spacing: 0.1em; }
.hud-head .clock small { display: block; font-size: 11px; letter-spacing: 0.3em; color: var(--muted); text-align: right; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 14px;
  min-height: 132px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tile:hover { border-color: var(--red); box-shadow: var(--glow); transform: translateY(-2px); }
.tile svg { width: 30px; height: 30px; stroke: var(--red); fill: none; stroke-width: 1.6; }
.tile .t { letter-spacing: 0.22em; font-size: 13px; color: var(--text); }
.tile .s { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; margin-top: auto; }
.tile .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--red);
  color: #140003;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: bold;
}
.tile.onhold { cursor: default; opacity: 0.45; filter: grayscale(0.6); }
.tile.onhold:hover { transform: none; box-shadow: none; border-color: var(--line-soft); }
.tile.onhold .badge { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: normal; letter-spacing: 0.14em; }
.hud-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-top: 14px; }
@media (max-width: 760px) { .hud-cols { grid-template-columns: 1fr; } }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-list .item { border-left: 2px solid var(--red); padding: 4px 0 4px 10px; font-size: 13px; cursor: pointer; }
.mini-list .item small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }

/* ---------- ideas ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line);
  padding: 6px 11px;
  border-radius: 20px;
  font-size: 11px;
  letter-spacing: 0.14em;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  text-transform: uppercase;
}
.chip.on { background: var(--red); color: #140003; border-color: var(--red); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: var(--red); box-shadow: var(--glow); }
.card .cover {
  aspect-ratio: 1;
  background: #0d0103 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red-dim);
  font-size: 36px;
  border-bottom: 1px solid var(--line-soft);
}
.card .meta { padding: 9px 10px; }
.card .meta .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta small { color: var(--muted); font-size: 11px; display: block; margin-top: 3px; }
.status { font-size: 10px; letter-spacing: 0.16em; padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--red-hot); text-transform: uppercase; }
.status.approved { background: var(--red); color: #140003; border-color: var(--red); }
.idea-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; }
@media (max-width: 820px) { .idea-grid { grid-template-columns: 1fr; } }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.file {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d0103;
  display: flex;
  flex-direction: column;
}
.file .pv { aspect-ratio: 1; background: center/contain no-repeat #0a0102; cursor: zoom-in; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 6px; word-break: break-all; }
.file .fa { display: flex; gap: 6px; padding: 6px; align-items: center; }
.file .fa span { font-size: 10px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.drop.over { background: rgba(255, 26, 46, 0.12); border-color: var(--red); color: var(--text); }
.section-label { font-size: 11px; letter-spacing: 0.24em; color: var(--muted); margin: 16px 0 8px; text-transform: uppercase; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); height: calc(100dvh - 150px); }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 12px; }
.msg { max-width: 78%; align-self: flex-start; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg .bubble {
  display: inline-block;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px 10px 10px 2px;
  background: rgba(255, 26, 46, 0.08);
  border: 1px solid var(--line-soft);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.45;
}
.msg.mine .bubble { border-radius: 10px 10px 2px 10px; background: rgba(255, 26, 46, 0.2); border-color: var(--line); }
.msg .who { font-size: 10px; letter-spacing: 0.16em; color: var(--muted); margin-bottom: 3px; }
.msg img { display: block; max-width: 260px; max-height: 260px; border-radius: 6px; margin-top: 6px; cursor: zoom-in; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; }
.attach-name { font-size: 11px; color: var(--fire); }
.day-sep { text-align: center; font-size: 10px; letter-spacing: 0.24em; color: var(--muted); margin: 8px 0; }

/* ---------- AI ---------- */
.ai-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 12px; }
@media (max-width: 820px) { .ai-wrap { grid-template-columns: 1fr; } .ai-wrap.in-thread .threads { display: none; } .ai-wrap:not(.in-thread) .ai-main { display: none; } }
.threads { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 170px); overflow-y: auto; }
.thread { padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.thread.on, .thread:hover { border-color: var(--red); background: rgba(255, 26, 46, 0.08); }
.thread small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.ai-main .msgs { height: calc(100vh - 290px); height: calc(100dvh - 290px); min-height: 260px; }
.ai-reply { line-height: 1.55; }
.ai-reply h3 { font-size: 14px; color: var(--red-hot); margin: 10px 0 4px; }
.ai-reply ul { margin: 6px 0; padding-left: 20px; }
.ai-reply code { background: rgba(255, 26, 46, 0.12); padding: 1px 4px; border-radius: 3px; }
.notice { border: 1px solid rgba(255, 138, 31, 0.5); color: #ffc58f; background: rgba(255, 138, 31, 0.08); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.typing { color: var(--muted); font-size: 12px; letter-spacing: 0.2em; }

/* ---------- calendar ---------- */
.cal-wrap { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
@media (max-width: 820px) { .cal-wrap { grid-template-columns: 1fr; } }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { letter-spacing: 0.24em; font-weight: normal; color: var(--red-hot); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 10px; text-align: center; color: var(--muted); letter-spacing: 0.14em; padding: 4px 0; }
.cal .day {
  aspect-ratio: 1;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 4px;
  font-size: 12px;
  cursor: pointer;
  position: relative;
  min-height: 38px;
}
.cal .day.out { opacity: 0.3; }
.cal .day.today { border-color: var(--red); color: var(--red-hot); }
.cal .day.sel { background: rgba(255, 26, 46, 0.2); }
.cal .day .dots { position: absolute; bottom: 4px; left: 4px; right: 4px; display: flex; gap: 2px; flex-wrap: wrap; }
.cal .day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--fire); box-shadow: 0 0 4px var(--fire); }
.cal .day .dots i.r { background: var(--red); box-shadow: 0 0 4px var(--red); }
.ev { border-left: 2px solid var(--fire); padding: 6px 10px; margin-bottom: 8px; background: rgba(255, 138, 31, 0.05); }
.ev .t { font-size: 14px; }
.ev small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.rem { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.rem input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red); margin-top: 2px; }
.rem.done .txt { text-decoration: line-through; color: var(--muted); }
.rem .txt small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.rem.overdue .txt small { color: #ff8090; }

/* ---------- modal / toasts / lightbox ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(460px, 100%); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 13px; letter-spacing: 0.3em; color: var(--red-hot); font-weight: normal; margin: 0 0 6px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toasts { position: fixed; top: 70px; right: 16px; left: 16px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 380px; width: 100%; background: var(--panel-solid); border: 1px solid var(--red); box-shadow: var(--glow); padding: 12px 14px; border-radius: var(--radius); font-size: 13px; }
.toast .tt { font-size: 10px; letter-spacing: 0.26em; color: var(--red-hot); margin-bottom: 4px; }
.toast .row { margin-top: 10px; justify-content: flex-end; }
.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.92); display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; box-shadow: 0 0 30px rgba(255, 26, 46, 0.3); }

/* ---------- bottom nav (phone) ---------- */
.bottomnav { display: none; }
@media (max-width: 700px) {
  .topbar .brand span { display: none; }
  .bottomnav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    background: rgba(5, 0, 0, 0.94);
    border-top: 1px solid var(--line-soft);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a {
    flex: 1;
    text-align: center;
    padding: 9px 0 8px;
    font-size: 9px;
    letter-spacing: 0.14em;
    color: var(--muted);
    text-decoration: none;
    position: relative;
  }
  .bottomnav a svg { display: block; margin: 0 auto 3px; width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
  .bottomnav a.on { color: var(--red-hot); }
  .bottomnav a .dot { position: absolute; top: 6px; left: 55%; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: var(--glow); }
  .chat { height: calc(100vh - 205px); height: calc(100dvh - 205px); }
  .ai-main .msgs { height: calc(100dvh - 340px); }
  .msg { max-width: 88%; }
}

/* ---------- polish ---------- */
a.tile, a.card { text-decoration: none; color: inherit; }
select.field {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--red) 50%), linear-gradient(135deg, var(--red) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
select.field option { background: var(--panel-solid); color: var(--text); }
/* faint CRT scanlines over everything - the matrix feel without costing frames */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(to bottom, rgba(255, 26, 46, 0.035) 0 1px, transparent 1px 3px);
}
