:root {
  --bg: #0a0a0b;
  --surface: #121214;
  --raised: #18181b;
  --hover: #1e1e22;
  --line: #232327;
  --line-2: #2f2f35;
  --text: #f2f2f3;
  --muted: #9a9aa3;
  --faint: #63636b;
  --accent: #ffd60a;
  --accent-2: #ffc300;
  --accent-ink: #141414;
  --accent-tint: rgba(255, 214, 10, 0.12);
  --accent-line: rgba(255, 214, 10, 0.35);
  --danger: #ff5c5c;
  --danger-tint: rgba(255, 92, 92, 0.12);

  --c-idea: #8e8e96;
  --c-approved: #ffe36e;
  --c-building: #ffc300;
  --c-testing: #ff9f1c;
  --c-update: #d9c27a;
  --c-done: #6b7280;
  --c-live: #34d399;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--raised); color: var(--text); font-weight: 600; font-size: 14px;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); border-color: #3a3a41; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--raised); color: var(--text); border-color: transparent; }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-tint); border-color: transparent; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field small { color: var(--faint); font-size: 12px; }
.input, .textarea, .select {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-tint); }
.textarea { resize: vertical; min-height: 84px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239a9aa3' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  height: 62px; padding: 0 24px; background: rgba(10, 10, 11, .86); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: .02em; font-size: 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 900; font-size: 15px; }
.brand small { color: var(--faint); font-weight: 600; font-size: 13px; letter-spacing: 0; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tab { height: 32px; padding: 0 14px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; text-decoration: none; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.tab.active svg { color: var(--accent); }
.tab svg { width: 15px; height: 15px; }
.topbar .spacer { flex: 1; }
.who { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; }
.who:hover { color: var(--text); border-color: var(--line-2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; background: var(--accent-tint); color: var(--accent); flex: none; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }

main { max-width: 1240px; margin: 0 auto; padding: 32px 24px 80px; }
main.wide { max-width: none; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; line-height: 1.1; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.seg button { width: 34px; height: 30px; display: grid; place-items: center; border: 0; background: transparent; color: var(--faint); border-radius: 7px; }
.seg button svg { width: 16px; height: 16px; }
.seg button.active { background: var(--raised); color: var(--accent); }

/* ---------- apps page ---------- */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.app-card {
  position: relative; display: flex; flex-direction: column; padding: 20px; min-height: 210px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, transform .15s, background .15s;
}
.app-card:hover { border-color: var(--line-2); background: #141417; }
.app-card .top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.mono { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; font-size: 19px; background: var(--accent-tint); color: var(--accent); border: 1px solid var(--accent-line); flex: none; }
.app-card h3 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.host { color: var(--faint); font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-card .desc { margin: 0 0 18px; color: var(--muted); font-size: 14px; flex: 1; }
.app-card .foot { display: flex; align-items: center; gap: 8px; }
.app-card .foot .btn-primary { flex: 1; }
.app-card .edit { position: absolute; top: 14px; right: 14px; opacity: 0; transition: opacity .15s; }
.app-card:hover .edit, .app-row:hover .edit { opacity: 1; }

.apps-rows { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.app-row { display: grid; grid-template-columns: 44px minmax(140px, 220px) 1fr auto auto; align-items: center; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); }
.app-row:first-child { border-top: 0; }
.app-row:hover { background: #141417; }
.app-row .mono { width: 40px; height: 40px; font-size: 17px; border-radius: 10px; }
.app-row h3 { margin: 0; font-size: 15px; }
.app-row .desc { margin: 0; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.app-row .edit { opacity: 0; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 44px 0 14px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.section-title a { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); text-decoration: none; font-size: 13.5px; }
.section-title a:hover { text-decoration: underline; }
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat { display: block; text-decoration: none; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s; }
.stat:hover { border-color: var(--line-2); }
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .num { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.stat .sub { color: var(--faint); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c-idea); }
.dot.idea { background: var(--c-idea); } .dot.approved { background: var(--c-approved); }
.dot.building { background: var(--c-building); } .dot.testing { background: var(--c-testing); }
.dot.update { background: var(--c-update); } .dot.done { background: var(--c-done); }
.live-tag { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 999px; background: rgba(52, 211, 153, .12); color: var(--c-live); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.live-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c-live); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.pill.upd { margin: -4px 0 12px; align-self: flex-start; max-width: 100%; }
.app-row .pill.upd { margin: 0 0 4px; }

.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--muted); }
.empty h3 { color: var(--text); margin: 0 0 6px; }
.empty p { margin: 0 0 18px; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.col { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; max-height: calc(100vh - 190px); }
.col-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.col-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; }
.col-title .count { margin-left: auto; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--raised); color: var(--muted); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.col-hint { color: var(--faint); font-size: 12.5px; margin-top: 3px; }
.col-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.col-body::-webkit-scrollbar { width: 6px; } .col-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.col-foot { padding: 8px 10px 10px; }
.add-btn { width: 100%; height: 36px; border: 1px dashed var(--line-2); background: transparent; border-radius: 10px; color: var(--faint); font-weight: 600; font-size: 13.5px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.add-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-tint); }
.add-btn svg { width: 15px; height: 15px; }
.quick-add { display: flex; flex-direction: column; gap: 8px; }
.quick-add .row { display: flex; gap: 6px; }

.card {
  position: relative; padding: 12px 12px 10px; background: var(--raised); border: 1px solid var(--line-2);
  border-radius: 11px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: border-color .12s, background .12s;
}
.card:hover { border-color: #3c3c43; background: #1c1c20; }
.card .title { font-weight: 650; font-size: 14px; line-height: 1.35; padding-right: 22px; word-break: break-word; }
.card .order { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin-right: 6px; border-radius: 6px; background: var(--accent-tint); color: var(--accent); font-size: 11.5px; font-weight: 800; vertical-align: 1px; }
.card .desc { color: var(--muted); font-size: 13px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.card .meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--faint); font-size: 12px; }
.card .meta .m { display: inline-flex; align-items: center; gap: 4px; }
.card .meta svg { width: 13px; height: 13px; }
.card .meta .right { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.card .warn { color: var(--c-testing); }
.card .req { margin-top: 6px; padding: 6px 9px; border-left: 2px solid var(--accent); background: var(--accent-tint); border-radius: 0 7px 7px 0; color: var(--text); font-size: 12.5px; }
.card .req-t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.card .req-t::before { content: "New feature: "; color: var(--accent); font-weight: 700; }
.card-ghost { opacity: .35; border-style: dashed; border-color: var(--accent-line); background: var(--accent-tint); }
.card-drag { transform: rotate(2deg); box-shadow: var(--shadow); border-color: var(--accent-line); cursor: grabbing; }
.col-empty { color: var(--faint); font-size: 13px; text-align: center; padding: 18px 6px; border: 1px dashed var(--line); border-radius: 10px; }
.col-body:has(.card) .col-empty { display: none; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .62); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; animation: fade .15s ease; }
.modal { width: 100%; max-width: 640px; max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); animation: pop .18s ease; overflow: hidden; }
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal.small { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.created { color: var(--faint); font-size: 12.5px; margin: -4px 0 14px; }
.shake { animation: shake .35s ease; }

.timeline-title { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.comment-box { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.comment-box .textarea { min-height: 42px; height: 42px; }
.events { display: flex; flex-direction: column; gap: 2px; }
.ev { display: flex; gap: 10px; padding: 8px 0; }
.ev .body { flex: 1; min-width: 0; }
.ev .line { font-size: 13px; color: var(--muted); }
.ev .line b { color: var(--text); font-weight: 650; }
.ev .when { color: var(--faint); font-size: 12px; margin-left: 6px; }
.ev .bubble { margin-top: 4px; padding: 9px 12px; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.ev .bubble.request { border-left: 2px solid var(--accent); }
.req-toggle { display: flex; align-items: center; gap: 8px; margin: -6px 0 14px; color: var(--muted); font-size: 13px; cursor: pointer; }
.req-toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.ev .ic { width: 20px; height: 20px; display: grid; place-items: center; color: var(--faint); flex: none; }
.ev .ic svg { width: 14px; height: 14px; }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 16px; background: var(--raised); border: 1px solid var(--line-2); border-radius: 11px; box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 10px; align-items: center; animation: pop .18s ease; max-width: 92vw; }
.toast.err { border-color: rgba(255, 92, 92, .45); }
.toast .bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--accent); }
.toast.err .bar { background: var(--danger); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 50% -10%, rgba(255, 214, 10, .08), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 380px; padding: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.login-card .btn { width: 100%; height: 42px; }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; margin: -6px 0 10px; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- responsive ---------- */
@media (max-width: 1360px) {
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; margin: 0 -24px; padding-left: 24px; padding-right: 24px; scroll-padding: 0 24px; }
  .col { flex: 0 0 280px; scroll-snap-align: start; }
}
@media (max-width: 1000px) { .pipeline { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) {
  .topbar { padding: 0 14px; gap: 10px; height: 58px; }
  .brand small, .who .name, .tab .lbl-long { display: none; }
  .who { padding: 0 4px; }
  main { padding: 22px 14px 70px; }
  .page-head h1 { font-size: 24px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn-primary { margin-left: auto; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .pipeline .stat:last-child { grid-column: span 2; }
  .apps-grid { grid-template-columns: 1fr; }
  .app-card { min-height: 0; }
  .app-card .edit, .app-row .edit { opacity: 1; }
  .app-row { grid-template-columns: 40px 1fr auto; gap: 12px; padding: 12px 14px; }
  .app-row .host, .app-row .desc { display: none; }
  .app-row .edit { display: none; }
  .board { margin: 0 -14px; padding-left: 14px; padding-right: 14px; scroll-padding: 0 14px; gap: 10px; }
  .col { flex: 0 0 84vw; max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px); }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; }
  .modal-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}
