/* ---------------------------------------------------------------
   Palette lifted from the OpenCode desktop app's own stylesheet
   (--v2-grey-*, --v2-blue-*, dark theme block), so the mobile view
   matches the desktop exactly.
   --------------------------------------------------------------- */
:root {
  --bg-deep: #080808;
  --bg-base: #161616;
  --layer-1: #242424;
  --layer-2: #2e2e2e;
  --layer-3: #3a3a3a;

  --text: #fafafa;
  --muted: #aeaeae;
  --faint: #808080;

  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);
  --border-soft: rgba(255, 255, 255, 0.06);

  --accent: #a2bcff;        /* text accent (blue-400) */
  --accent-solid: #3b5cf6;  /* primary surface (blue-600) */
  --accent-hover: #c3d4fd;  /* blue-300 */

  --green: #6bd586;
  --yellow: #f6c251;
  --orange: #ffa478;
  --red: #f17471;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --hdr: 54px;
  --tabs: 42px;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------- header ------------------------------- */
.hdr {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--hdr) + var(--safe-t));
  padding: var(--safe-t) 10px 0;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-soft);
}

.icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text);
  border-radius: 9px;
  font-size: 15px;
  padding: 0;
}
.icon:active { background: var(--layer-1); }
.icon.sm { width: 30px; height: 30px; border-radius: 8px; }

.hdr-titles { min-width: 0; flex: 1; line-height: 1.25; }
.hdr-project {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hdr-session {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: block; }
.pill.ready { color: var(--green); background: rgba(107, 213, 134, .10); border-color: rgba(107, 213, 134, .25); }
.pill.running { color: var(--yellow); background: rgba(246, 194, 81, .10); border-color: rgba(246, 194, 81, .28); }
.pill.running i { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.75); } }

/* -------------------------------- tabs -------------------------------- */
.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  height: var(--tabs);
  padding: 5px 10px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-soft);
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  padding: 0;
}
.tab.active { background: var(--layer-1); color: var(--text); }

/* -------------------------------- panes ------------------------------- */
.pane {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* -------------------------------- chat -------------------------------- */
.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}

.msg { display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  background: var(--layer-1);
  border: 1px solid var(--border-soft);
  border-radius: 14px 14px 5px 14px;
  padding: 9px 13px;
  max-width: 88%;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
}
.msg.assistant { align-items: stretch; }
.msg.assistant .prose {
  font-size: 15px;
  line-height: 1.68;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.prose p { margin: 0 0 10px; }
.prose p:last-child { margin-bottom: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  margin: 16px 0 8px;
  line-height: 1.3;
  font-weight: 650;
}
.prose h1 { font-size: 19px; }
.prose h2 { font-size: 17px; }
.prose h3 { font-size: 15.5px; }
.prose h4 { font-size: 14.5px; color: var(--muted); }
.prose ul, .prose ol { margin: 0 0 10px; padding-left: 20px; }
.prose li { margin: 3px 0; }
.prose blockquote {
  margin: 10px 0;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--border);
  color: var(--muted);
}
.prose a { color: var(--accent); text-decoration: none; }
.prose strong { font-weight: 650; color: #fff; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.prose code {
  background: var(--layer-1);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.prose pre {
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  overflow-x: auto;
  margin: 10px 0;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.55;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
}
.prose th { background: var(--bg-base); font-weight: 600; }

.typing::after {
  content: '▍';
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.empty {
  color: var(--faint);
  text-align: center;
  margin: 26vh 20px 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.older {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--layer-1);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  z-index: 5;
}
.spin {
  width: 11px; height: 11px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.jump {
  position: absolute;
  right: 14px;
  bottom: 18px;
  z-index: 6;
  background: var(--layer-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .55);
}

/* ------------------------ activity indicator -------------------------- */
.activity {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-deep);
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .01em;
  overflow: hidden;
  white-space: nowrap;
}
.activity .dots { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.activity .dots i {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot 1.1s ease-in-out infinite;
}
.activity .dots i:nth-child(2) { animation-delay: .15s; }
.activity .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot {
  0%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
.activity .label { color: var(--text); font-weight: 550; }
.activity .hint { color: var(--faint); overflow: hidden; text-overflow: ellipsis; }
.activity .elapsed { margin-left: auto; color: var(--faint); font-variant-numeric: tabular-nums; font-size: 11.5px; }

/* ------------------------------ composer ------------------------------ */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: var(--bg-deep);
  border-top: 1px solid var(--border-soft);
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 132px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  line-height: 1.4;
}
.composer textarea:focus { border-color: var(--border-strong); }
.composer textarea:disabled { opacity: .55; }

.send-btn {
  width: 40px; height: 40px;
  border-radius: 11px;
  border: none;
  background: var(--accent-solid);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  transition: background .15s ease, transform .1s ease;
}
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .45; }

.send-btn.stop {
  background: var(--layer-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  animation: stopPulse 1.8s ease-in-out infinite;
}
@keyframes stopPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(246, 194, 81, 0); }
  50% { box-shadow: 0 0 0 3px rgba(246, 194, 81, .12); }
}

/* -------------------------------- files ------------------------------- */
.crumbs {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs button {
  border: none;
  background: none;
  color: var(--muted);
  font-family: inherit;
  padding: 3px 6px;
  border-radius: 6px;
}
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--faint); }

.filelist {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 8px 20px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 10px;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  border-radius: 8px;
}
.row:active { background: var(--layer-1); }
.row svg { flex: 0 0 auto; opacity: .7; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--faint); font-size: 12px; }

.viewer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  z-index: 4;
}
.viewer-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.viewer-bar span:first-of-type {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.viewer-size { color: var(--faint); font-size: 11px; }
.viewer pre {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 12px;
  background: #0d0d0d;
  color: #e2e2e2;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

/* ------------------------------ terminal ------------------------------ */
.term { padding: 0; }
.term-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden;
  white-space: nowrap;
}
.term-head .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}
.term-head.running .dot { background: var(--yellow); animation: pulse 1.1s infinite; }
.term-head.running .state { color: var(--yellow); font-weight: 600; }
.term-head.done .dot { background: var(--green); }
.term-head.done .state { color: var(--green); font-weight: 600; }
.term-head .cwd { overflow: hidden; text-overflow: ellipsis; margin-left: auto; direction: rtl; }

.term-out {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #0d0d0d;
  color: #d5d5d5;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}
.term-out .cmd { color: var(--accent); }
.term-out .err { color: var(--red); }
.term-out .done { color: var(--green); }
.term-out .meta { color: var(--faint); }

.term-in {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-b));
  border-top: 1px solid var(--border-soft);
  background: var(--bg-deep);
}
.term-in .prompt { color: var(--accent); font-family: var(--font-mono); font-size: 14px; }
.term-in input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}
.term-in input:focus { border-color: var(--border-strong); }
.term-in input:disabled { opacity: .55; }
.term-in button {
  border: 1px solid var(--border);
  background: var(--layer-1);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  min-width: 66px;
}
.term-in button:disabled { opacity: .55; }

/* ------------------------------- drawer ------------------------------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  z-index: 30;
  backdrop-filter: blur(2px);
}
.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(86vw, 360px);
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  z-index: 31;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.drawer-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.session-item {
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 11px;
  color: var(--text);
  font-family: inherit;
}
.session-item:active { background: var(--layer-1); }
.session-item.active { border-color: var(--border-strong); background: var(--layer-1); }
.session-item .t { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .d { font-size: 11px; color: var(--faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------- toast ------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--layer-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  z-index: 40;
  max-width: 88vw;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

/* ------------------------- accounts / login --------------------------- */
.empty-btn {
  margin-top: 16px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--layer-1);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
}
.session-item.new-chat .t { color: var(--accent); }
.drawer-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--border-soft);
}
.drawer-foot .who { flex: 1; min-width: 0; }
.drawer-foot .n {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-foot .e {
  font-size: 11px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--layer-1);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}
