/* VibeCipta Console — shared design system.
   Refined, professional internal tool: warm paper background, deep ink,
   per-app accent. No AI-slop gradients/glow. */
:root {
  --bg: #f6f5f1;
  --paper: #fffdfa;
  --ink: #1a1b1e;
  --ink-soft: #4a4d55;
  --ink-faint: #8a8e98;
  --line: #e7e4dc;
  --line-strong: #d8d4c8;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --down: #b91c1c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20,20,25,.04), 0 8px 24px -12px rgba(20,20,25,.18);
  --shadow-lg: 0 2px 6px rgba(20,20,25,.06), 0 24px 60px -20px rgba(20,20,25,.28);
  --font: ui-sans-serif, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--ink-faint); }

/* top bar */
.topbar {
  height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 22px; border-bottom: 1px solid var(--line);
  background: rgba(255,253,250,.86); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 680; letter-spacing: -.02em; }
.brand .spark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 15px;
}
.brand small { display:block; font-weight: 500; color: var(--ink-faint); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.who { font-size: 13px; color: var(--ink-soft); }
.btn-ghost {
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink-soft);
  border-radius: 9px; padding: 7px 13px; font-size: 13px; transition: .15s;
}
.btn-ghost:hover { border-color: var(--ink-faint); color: var(--ink); }

/* dashboard */
.wrap { max-width: 1040px; margin: 0 auto; padding: 40px 24px 80px; }
.hero h1 { font-size: clamp(26px, 4vw, 38px); letter-spacing: -.03em; margin: 0 0 6px; }
.hero p { color: var(--ink-soft); margin: 0 0 34px; font-size: 16px; max-width: 60ch; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card {
  position: relative; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; text-decoration: none; color: inherit; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s, border-color .18s;
  display: flex; flex-direction: column; min-height: 178px; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--card-accent, var(--accent));
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.card .mono {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 21px; color: #fff; background: var(--card-accent, var(--accent));
  margin-bottom: 16px; letter-spacing: -.02em;
}
.card h3 { margin: 0 0 3px; font-size: 18px; letter-spacing: -.02em; }
.card .tag { color: var(--card-accent, var(--accent)); font-size: 12.5px; font-weight: 620; margin-bottom: 10px; }
.card .desc { color: var(--ink-soft); font-size: 13.5px; line-height: 1.5; flex: 1; }
.card .foot { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 12.5px; color: var(--ink-faint); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px rgba(21,128,61,.14); }
.dot.down { background: var(--down); box-shadow: 0 0 0 3px rgba(185,28,28,.14); }
.card .foot .st { margin-right: auto; }
.card .golive {
  color: var(--card-accent, var(--accent)); font-weight: 640; text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--card-accent, var(--accent)) 35%, var(--line));
  padding: 4px 9px; border-radius: 7px; transition: .15s;
}
.card .golive:hover { background: color-mix(in srgb, var(--card-accent, var(--accent)) 10%, #fff); border-color: var(--card-accent, var(--accent)); }
.card .go { color: var(--card-accent, var(--accent)); font-weight: 640; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 40px; max-width: 400px; width: 100%; text-align: center;
}
.login .spark { width: 46px; height: 46px; border-radius: 12px; background: var(--ink); color:#fff; display: grid; place-items:center; font-weight: 800; font-size: 22px; margin: 0 auto 18px; }
.login h1 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 6px; }
.login p { color: var(--ink-soft); margin: 0 0 26px; font-size: 14px; }
.ms-btn {
  display: inline-flex; align-items: center; gap: 10px; justify-content: center;
  width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink); font-size: 14.5px; font-weight: 600; text-decoration: none; transition: .15s;
}
.ms-btn:hover { border-color: var(--ink-faint); box-shadow: var(--shadow); }
.ms-btn .ms { width: 18px; height: 18px; display:inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.ms-btn .ms i { display:block; width:8px; height:8px; }

/* ============================ CHAT ============================ */
/* Full-viewport flex column so the composer is ALWAYS visible and the mobile
   keyboard (interactive-widget=resizes-content) shrinks the thread, not the input. */
.chat-page { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.chat-page .topbar { position: static; flex: none; }
.chat-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 264px 1fr; }
.sidebar { border-right: 1px solid var(--line); background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.sidebar .head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.sidebar .applink { display:flex; align-items:center; gap:10px; text-decoration:none; color:var(--ink); }
.sidebar .mono { width: 34px; height: 34px; border-radius: 9px; display:grid; place-items:center; color:#fff; font-weight:800; background: var(--accent); }
.sidebar .applink h2 { font-size: 15px; margin: 0; letter-spacing: -.02em; }
.sidebar .applink .tag { font-size: 11.5px; color: var(--ink-faint); }
.newchat { margin: 12px 16px; padding: 9px; border-radius: 9px; border: 1px dashed var(--line-strong); background: transparent; color: var(--ink-soft); font-size: 13px; font-weight: 600; transition:.15s; }
.newchat:hover { border-color: var(--accent); color: var(--accent); }
.convs { flex: 1; overflow-y: auto; padding: 4px 10px 16px; min-height: 0; }
.conv { display:flex; align-items:center; gap:8px; padding: 9px 10px; border-radius: 8px; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.conv:hover { background: var(--bg); }
.conv.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--ink); font-weight: 600; }
.conv .t { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conv .del { opacity: 0; color: var(--ink-faint); font-size: 15px; border:none; background:none; padding: 0 2px; }
.conv:hover .del { opacity: 1; }
.sidebar .back { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-faint); text-decoration:none; }
.sidebar .back:hover { color: var(--ink); }

.main { display: flex; flex-direction: column; min-height: 0; }
.thread { flex: 1; overflow-y: auto; padding: 28px 0; }
.thread-inner { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.msg { display: flex; gap: 13px; margin-bottom: 22px; }
.msg .av { width: 30px; height: 30px; border-radius: 9px; flex: none; display:grid; place-items:center; font-weight: 800; font-size: 13px; color:#fff; }
.msg.user .av { background: var(--ink); }
.msg.assistant .av { background: var(--accent); }
.msg .body { flex: 1; min-width: 0; padding-top: 3px; }
.msg .body .name { font-size: 12px; color: var(--ink-faint); margin-bottom: 4px; font-weight: 600; }
.bubble { font-size: 15px; line-height: 1.62; color: var(--ink); word-wrap: break-word; }
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble pre { background: #1c1d22; color: #e6e6e6; padding: 13px 15px; border-radius: 10px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.bubble code { font-family: var(--mono); font-size: .9em; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.bubble pre code { background: none; padding: 0; }
.bubble ul, .bubble ol { margin: 0 0 10px; padding-left: 22px; }
.bubble h1,.bubble h2,.bubble h3 { letter-spacing: -.02em; margin: 14px 0 8px; }
.bubble a { color: var(--accent); }
.attach-chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.attach-chips .c { font-size: 12px; background: var(--bg); border:1px solid var(--line); border-radius: 7px; padding: 3px 8px; color: var(--ink-soft); }

/* activity feed (tool use) */
.acts { margin: 6px 0 2px; display:flex; flex-direction:column; gap: 4px; }
.act { display:flex; align-items:center; gap:8px; font-size: 12.5px; color: var(--ink-faint); font-family: var(--mono); }
.act .ic { width: 15px; text-align:center; }
.act .v { color: var(--ink-soft); font-weight: 600; font-family: var(--font); }
.act .s { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.act.ok .ic { color: var(--ok); }
.act.err .ic { color: var(--down); }

.thinking { display:inline-flex; gap:4px; align-items:center; color: var(--ink-faint); font-size: 13px; }
.thinking i { width:6px;height:6px;border-radius:50%;background:var(--ink-faint); animation: bl 1.2s infinite; }
.thinking i:nth-child(2){animation-delay:.2s} .thinking i:nth-child(3){animation-delay:.4s}
@keyframes bl { 0%,80%,100%{opacity:.25} 40%{opacity:1} }

/* composer */
.composer { border-top: 1px solid var(--line); background: var(--paper); padding: 14px 0 18px; }
.composer-inner { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.dropzone { border: 1px solid var(--line-strong); border-radius: 14px; background: #fff; padding: 8px 8px 8px 14px; transition: border-color .15s; }
.dropzone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, #fff); }
.pending { display:flex; flex-wrap:wrap; gap:6px; padding: 4px 0 8px; }
.pending .p { font-size:12px; background:var(--bg); border:1px solid var(--line); border-radius:7px; padding:4px 8px; display:flex; gap:6px; align-items:center; }
.pending .p button { border:none;background:none;color:var(--ink-faint);font-size:14px;padding:0;line-height:1;}
.row { display:flex; align-items:flex-end; gap:8px; }
.row textarea {
  flex:1; border:none; resize:none; outline:none; background:transparent; font-family:var(--font);
  font-size:15px; line-height:1.5; max-height:200px; padding:8px 2px; color:var(--ink);
}
.iconbtn { width: 38px; height: 38px; flex:none; border-radius: 10px; border:1px solid var(--line); background:#fff; color: var(--ink-soft); display:grid; place-items:center; font-size:17px; transition:.15s; }
.iconbtn:hover { border-color: var(--ink-faint); color: var(--ink); }
.iconbtn.on { background: var(--accent); color:#fff; border-color: var(--accent); }
.iconbtn.rec { background: var(--down); color:#fff; border-color: var(--down); animation: pulse 1.3s infinite; }
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(185,28,28,.4)} 50%{box-shadow:0 0 0 6px rgba(185,28,28,0)} }
.send { width:38px; height:38px; flex:none; border-radius:10px; border:none; background: var(--accent); color:#fff; display:grid; place-items:center; font-size:17px; transition:.15s; }
.send:disabled { opacity:.4; cursor:not-allowed; }
.hint { text-align:center; font-size:11.5px; color:var(--ink-faint); margin-top:9px; }

/* persistent "agent is working" bar (survives reconnect/refresh) */
.workbar { max-width: 760px; margin: 0 auto 10px; padding: 8px 14px; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line)); border-radius: 9px; }
.workbar .spin { width: 13px; height: 13px; flex: none; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toast (e.g. "I'm still working on your previous request…") */
.toast { position: fixed; left: 50%; bottom: 92px; transform: translate(-50%, 14px); z-index: 60;
  background: var(--ink); color: #fff; font-size: 13px; padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 86vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { max-width:560px; margin: 8vh auto 0; text-align:center; color:var(--ink-soft); }
.empty .mono { width:56px;height:56px;border-radius:14px;display:grid;place-items:center;color:#fff;font-weight:800;font-size:26px;margin:0 auto 16px; background: var(--accent); }
.empty h2 { font-size:22px; letter-spacing:-.02em; color:var(--ink); margin:0 0 8px; }
.empty p { font-size:14.5px; line-height:1.6; }
.examples { display:flex; flex-direction:column; gap:8px; margin-top:20px; }
.examples button { text-align:left; border:1px solid var(--line); background:var(--paper); border-radius:10px; padding:11px 14px; font-size:13.5px; color:var(--ink-soft); transition:.15s; }
.examples button:hover { border-color: var(--accent); color: var(--ink); }

/* "Open live app" buttons */
.topbar .live { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong)); font-weight: 600; }
.topbar .live:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, #fff); color: var(--accent); }
.livefull {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px;
  padding: 10px; border-radius: 9px; text-decoration: none; font-size: 13px; font-weight: 640;
  color: #fff; background: var(--accent); transition: .15s;
}
.livefull:hover { filter: brightness(1.06); }

/* mobile scrim behind the slide-out sidebar */
.scrim { display: none; position: fixed; inset: 0; background: rgba(20,20,25,.38); z-index: 35; }
.scrim.show { display: block; }

.hamb { display:none; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 860px) {
  .chat-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 56px auto 0 0; width: min(82vw, 300px); z-index: 40;
    transform: translateX(-100%); transition: transform .22s cubic-bezier(.2,.7,.3,1); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .hamb { display: grid; }
}

@media (max-width: 760px) {
  .wrap { padding: 24px 16px 64px; }
  .cards { grid-template-columns: 1fr; }
  .topbar { height: 56px; padding: 0 12px; gap: 8px; }
  .brand small { display: none; }
  .brand { font-size: 15px; gap: 8px; }
  /* compact the header actions on phones */
  .topbar .live { padding: 7px 10px; font-size: 12px; }
  .btn-ghost.apps-link { padding: 7px 11px; }
  .who { display: none; }
  .thread { padding: 18px 0; }
  .thread-inner, .composer-inner { padding: 0 14px; }
  .msg { gap: 10px; margin-bottom: 18px; }
  .msg .av { width: 26px; height: 26px; font-size: 12px; }
  .bubble { font-size: 14.5px; }
  .empty { margin-top: 5vh; }
  .composer { padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
  .hint { display: none; }
  .dropzone { border-radius: 12px; padding: 7px 7px 7px 12px; }
}

@media (max-width: 460px) {
  .topbar { padding: 0 8px; gap: 6px; }
  /* show "Open live" as a compact pill, hide its long label on very small screens */
  .topbar .live { font-size: 0; padding: 7px 9px; }
  .topbar .live [aria-hidden] { font-size: 15px; }
  .iconbtn { width: 36px; height: 36px; }
  .send { width: 36px; height: 36px; }
  .hero h1 { font-size: 24px; }
  .hero p { font-size: 14.5px; margin-bottom: 26px; }
  .card { min-height: 0; padding: 18px; }
  .row { gap: 6px; }
  .row textarea { font-size: 16px; } /* >=16px stops iOS auto-zoom on focus */
  .login .panel { padding: 28px 22px; }
}
