:root {
  --navy: #1C3B6E;
  --navy-2: #294e8a;
  --bg: #F4F7FB;
  --card: #FFFFFF;
  --muted: #7A96B8;
  --line: #e2e9f3;
  --text: #1d2939;
  --ok: #15a06b;
  --warn: #d98a00;
  --danger: #d64545;
  --grad: linear-gradient(135deg, #294e8a 0%, #1C3B6E 100%);
  --radius: 14px;
  --shadow: 0 4px 18px rgba(28,59,110,.10);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.only-mobile { display: none; }

/* buttons */
.btn { border: 0; border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; background: #eef3fa; color: var(--navy); transition: transform .05s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-danger { background: #fbe9e9; color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; font-size: 18px; cursor: pointer; padding: 6px 8px;
  border-radius: 8px; color: #fff; }
.icon-btn:hover { background: rgba(255,255,255,.12); }

/* login */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--grad); padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 30px 26px; width: 100%; max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card h1 { margin: 6px 0 0; color: var(--navy); }
.login-card p { margin: 0 0 8px; }
.login-card input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; }
.login-card input:focus { outline: 2px solid var(--navy-2); border-color: transparent; }
.brand-mark { width: 56px; height: 56px; margin: 0 auto; border-radius: 16px; background: var(--grad);
  display: grid; place-items: center; font-size: 28px; color: #fff; }
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 16px; display: inline-grid; vertical-align: middle; }
.login-err { color: var(--danger); font-size: 13px; min-height: 16px; }

/* shell */
.shell { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; background: var(--navy);
  padding: calc(10px + var(--safe-top)) 14px 10px; color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .logo { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }

/* board — desktop: compact columns packed left; empty stages collapse slim */
.board { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 16px;
  overflow-x: auto; overflow-y: hidden; align-items: stretch; }
.col { background: #eef2f8; border-radius: var(--radius); flex: 1 1 0; min-width: 180px; max-width: 260px;
  min-height: 0; max-height: 100%; display: flex; flex-direction: column; }
.col.col-empty { flex: 0 1 140px; min-width: 110px; max-width: 150px; }
.col-head { padding: 12px 12px 10px; font-weight: 700; font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--navy); display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.col-head .count { background: #fff; color: var(--muted); border-radius: 20px; padding: 1px 8px; font-size: 12px; }
.col-body { padding: 0 8px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; flex: 1; min-height: 0; }
.col.drop-target { outline: 2px dashed var(--navy-2); outline-offset: -4px; }
textarea.drop-target { outline: 2px dashed var(--navy-2); outline-offset: -2px; background: #f4f7fb; }

.card { background: var(--card); border-radius: 12px; padding: 11px 12px; box-shadow: var(--shadow);
  cursor: pointer; border: 1px solid transparent; min-width: 0; }
.card:hover { border-color: var(--line); }
.card.dragging { opacity: .5; }
.card .title { font-weight: 700; margin-bottom: 3px; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.card .slug { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.card .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eef3fa; color: var(--navy); font-weight: 600; }
.chip.sched { background: #fff4e0; color: var(--warn); }
.chip.deploy { background: #e7f6ef; color: var(--ok); }
.chip.server { background: #eef2f8; color: var(--muted); }
.empty-col { color: var(--muted); font-size: 12.5px; text-align: center; padding: 14px 6px; opacity: .7; }
.col.col-empty { background: #eef2f8aa; }

/* hamburger nav menu (jump to stage + quick actions) */
.navmenu { position: fixed; top: calc(52px + var(--safe-top)); left: 10px; z-index: 35;
  background: #fff; border-radius: 14px; box-shadow: 0 14px 44px rgba(20,30,50,.28);
  padding: 6px; min-width: 230px; max-width: calc(100vw - 20px); animation: navIn .14s ease; }
@keyframes navIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.navmenu .nm-item { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 12px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--text); font-size: 15px; }
.navmenu .nm-item:hover, .navmenu .nm-item:active { background: #eef3fa; }
.navmenu .nm-count { background: #eef3fa; color: var(--muted); border-radius: 20px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.navmenu .nm-sep { height: 1px; background: var(--line); margin: 5px 8px; }
.navmenu .nm-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px 12px 4px; font-weight: 700; }

/* drawer */
.drawer, .modal { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop, .modal-backdrop { position: absolute; inset: 0; background: rgba(20,30,50,.45); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: 560px; max-width: 100%;
  background: var(--bg); box-shadow: -8px 0 40px rgba(0,0,0,.2); overflow-y: auto;
  animation: slideIn .2s ease; padding-bottom: 40px; }
@keyframes slideIn { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; background: var(--navy); color: #fff; padding: calc(14px + var(--safe-top)) 18px 14px;
  display: flex; align-items: center; gap: 10px; z-index: 2; }
.drawer-head h2 { margin: 0; font-size: 18px; flex: 1; }
.drawer-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; }

.section { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.section h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
input, textarea, select { font-family: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--text); width: 100%; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--navy-2); border-color: transparent; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* prompts */
.prompt { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: #fff; }
.prompt-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; cursor: pointer; }
.prompt-head .pt { font-weight: 600; flex: 1; }
.prompt-body { padding: 0 12px 12px; display: none; flex-direction: column; gap: 10px; }
.prompt.open .prompt-body { display: flex; }
.prompt.open .prompt-head { border-bottom: 1px solid var(--line); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 700; text-transform: capitalize; }
.b-draft { background: #eef2f8; color: var(--muted); }
.b-refined { background: #e8effb; color: var(--navy); }
.b-scheduled { background: #fff4e0; color: var(--warn); }
.b-deploying { background: #e7f6ef; color: var(--ok); }
.b-done { background: #dcf5e9; color: var(--ok); }
.b-failed { background: #fbe9e9; color: var(--danger); }
.refined-box { background: #f8fafd; border: 1px dashed var(--line); border-radius: 10px; padding: 10px;
  font-family: ui-monospace, Menlo, monospace; font-size: 13px; white-space: pre-wrap; max-height: 320px; overflow: auto; }

/* AI clarifying questions */
.q-card { background: #f4f8ff; border: 1px solid #d8e6fb; border-radius: 12px; padding: 13px;
  display: flex; flex-direction: column; gap: 13px; }
.q-head { font-weight: 700; color: var(--navy); font-size: 13.5px; }
.q { display: flex; flex-direction: column; gap: 6px; }
.q-text { font-weight: 600; }
.q-why { font-size: 12px; color: var(--muted); }
.q-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.q-opt { font-size: 12.5px; padding: 6px 11px; border-radius: 20px; border: 1px solid var(--line);
  background: #fff; color: var(--navy); cursor: pointer; font-weight: 600; }
.q-opt:hover { border-color: var(--navy-2); }
.q-opt.sel { background: var(--grad); color: #fff; border-color: transparent; }
.log-row { font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--muted); display: flex; gap: 8px; }
.log-row.bad { color: var(--danger); }
.log-row time { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* modal */
.modal-card { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--bg); border-radius: 16px; width: 520px; max-width: calc(100% - 24px); max-height: 88vh;
  overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.modal-head { background: var(--navy); color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 0 18px 18px; display: flex; gap: 10px; justify-content: flex-end; }

.server-item { background: #fff; border-radius: 12px; padding: 12px; box-shadow: var(--shadow); margin-bottom: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--danger); }

/* toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow);
  font-size: 14px; max-width: 90%; }
.toast.bad { background: var(--danger); }

/* mobile + tablet — stack stages vertically, no horizontal swipe, page scrolls */
@media (max-width: 920px) {
  .only-mobile { display: inline-grid; place-items: center; }
  .board { display: block; padding: 12px; overflow-y: auto; overflow-x: hidden; }
  .col { width: auto; min-width: 0; max-height: none; margin-bottom: 12px; }
  .col-body { overflow: visible; padding-bottom: 6px; }
  /* empty stages collapse to a slim header so they don't waste a whole screen */
  .col.col-empty { background: transparent; margin-bottom: 4px; }
  .col.col-empty .col-head { padding: 8px 4px; opacity: .55; }
  .col.col-empty .col-body { display: none; }
  .drawer-panel { width: 100%; animation: slideUp .22s ease; }
  @keyframes slideUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
  input, textarea, select { font-size: 16px; } /* avoid iOS zoom */
  .topbar .logo { font-size: 16px; }
}
