/* app.css - OLED dark glassmorphism, mobile-first */
:root {
  --bg: #0A0E17;
  --card: rgba(24, 33, 52, 0.72);
  --border: rgba(255, 255, 255, 0.08);
  --indigo: #6366F1;
  --emerald: #10B981;
  --amber: #F59E0B;
  --rose: #EF4444;
  --text: #E5E9F2;
  --muted: #8A93A6;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.small { font-size: 13px; color: var(--muted); }

/* ---- inputs ---- */
input[type="text"], textarea {
  width: 100%;
  font-size: 16px; /* iOS no-zoom */
  padding: 10px 12px;
  margin: 6px 0;
  color: var(--text);
  background: rgba(10, 14, 23, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--indigo); }
textarea { resize: none; }

/* ---- lock screen ---- */
.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.lock-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 20px;
}
.lock-title { font-size: 20px; font-weight: 700; }
.lock-sub { color: var(--muted); margin: 4px 0 16px; }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin-bottom: 8px; }
.pin-dots .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  transition: background 0.15s;
}
.pin-dots .dot.filled { background: var(--indigo); }
.pin-msg { min-height: 18px; font-size: 13px; color: var(--rose); }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 10px;
}
.pin-key {
  height: 56px;
  min-width: 48px;
  font-size: 22px;
  color: var(--text);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
}
.pin-key:active { transform: scale(0.98); }
.pin-key-blank { visibility: hidden; }

/* ---- app shell ---- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar {
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  border-bottom: 1px solid var(--border);
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-pill[data-state="running"] .status-dot { background: var(--emerald); }
.status-pill[data-state="waiting"] .status-dot { background: var(--amber); }
.status-pill[data-state="error"] .status-dot { background: var(--rose); }

/* ---- panels & tabs ---- */
.panels { flex: 1; overflow: hidden; position: relative; }
.panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 14px 14px 20px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  -ms-overflow-style: none;
}
.panel::-webkit-scrollbar { display: none; }
.panel[data-active="true"] { opacity: 1; transform: none; pointer-events: auto; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.panel-head h2, .card h3 { margin: 0 0 8px; font-size: 16px; }

/* ---- cards ---- */
.card {
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}
.card-danger { border-color: var(--rose); }
.guide { color: var(--muted); font-size: 13px; padding-left: 18px; line-height: 1.6; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.ops-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ---- buttons / chips ---- */
.btn {
  min-height: 44px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--indigo); color: #fff; border: none; }
.btn-green { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.4); }
.btn-stop { background: rgba(245, 158, 11, 0.2); border-color: rgba(245, 158, 11, 0.4); }
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--rose);
  color: var(--rose);
  width: 100%;
  font-weight: 700;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.chip {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.chip:active { transform: scale(0.98); }

/* ---- monitor feed ---- */
.feed { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.feed-card {
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 14px;
}
.feed-card .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.feed-card .src-ico { font-size: 14px; }
.feed-card[data-kind="error"] { border-color: var(--rose); }
.feed-card[data-kind="green"] { border-color: rgba(16, 185, 129, 0.5); }
.feed-card[data-kind="waiting"] { border-color: rgba(245, 158, 11, 0.5); }
.feed-card.collapsed .body { display: none; }
details.tool-out { margin-top: 6px; }
details.tool-out summary {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  list-style: none;
}
details.tool-out pre {
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  color: var(--muted);
  background: rgba(10, 14, 23, 0.5);
  border-radius: 10px;
  padding: 8px;
  margin: 6px 0 0;
}
.steer { border-top: 1px solid var(--border); padding-top: 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- architect chat ---- */
.chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 30vh;
}
.msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.msg.user {
  align-self: flex-end;
  background: rgba(99, 102, 241, 0.25);
  border: 1px solid rgba(99, 102, 241, 0.35);
}
.msg.assistant {
  align-self: flex-start;
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
}
.msg pre {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(10, 14, 23, 0.6);
  border-radius: 10px;
  padding: 10px;
  overflow-x: auto;
  position: relative;
}
.msg code { font-family: var(--mono); font-size: 13px; }
.tz-bar { display: flex; gap: 6px; margin-top: 6px; }
.stream-indicator { color: var(--amber); font-size: 12px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; }
.btn-send { min-width: 48px; min-height: 48px; }

/* ---- code panel ---- */
.state-cards { margin-bottom: 12px; }
.state-card { margin-bottom: 8px; }
.state-card summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  padding: 4px 0;
}
.state-card pre {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--muted);
  margin: 6px 0 0;
}
.filetree { list-style: none; padding-left: 0; margin: 0; }
.filetree ul { list-style: none; padding-left: 16px; }
.filetree li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.filetree li:last-child { border-bottom: none; }
.filetree .f-name { cursor: pointer; display: inline-block; min-height: 32px; }
.filetree .f-name:active { transform: scale(0.98); }
.filetree .dir-ico { margin-right: 6px; }
.code-viewer { margin-top: 12px; }
.code-viewer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.code-viewer-head code { font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; }
#codeBody {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(10, 14, 23, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  overflow-x: auto;
  max-height: 50vh;
  margin: 0;
}

/* ---- bottom nav ---- */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 23, 0.9);
  backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-btn {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  border-top: 2px solid transparent;
  cursor: pointer;
}
.nav-btn .nav-ico { font-size: 18px; }
.nav-btn[data-active="true"] { color: var(--indigo); border-top-color: var(--indigo); }
.nav-btn:active { transform: scale(0.98); }

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
  transform: translateX(-50%);
  z-index: 200;
  max-width: 90vw;
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 12px;
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
}
.toast[data-kind="green"] { border-color: var(--emerald); }
.toast[data-kind="red"] { border-color: var(--rose); }

.anti-sleep .status-dot { background: var(--emerald); }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* lock screen alt inputs: passphrase + 2FA code */
.lock-alt { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pin-switch {
  background: none; border: none; color: rgba(255,255,255,0.55);
  font-size: 13px; text-decoration: underline; padding: 6px; cursor: pointer;
}
.lock-input {
  width: 100%; box-sizing: border-box; font-size: 16px; padding: 12px 14px;
  border-radius: 12px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(10,14,23,0.6); color: #fff; outline: none;
}
.pin-go {
  padding: 12px; border-radius: 12px; border: 1px solid rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.25); color: #fff; font-size: 16px;
}



