/* goose_web — mobile-first (Android first, desktop second). Dark theme. */
:root {
  --bg: #0f1115;
  --bg2: #161a21;
  --card: #1a1f28;
  --line: #2a3140;
  --text: #e6e9ee;
  --sub: #9aa4b2;
  --accent: #4c8dff;
  --accent-ink: #0b1220;
  --danger: #ff5c5c;
  --ok: #3ecf8e;
  --warn: #f5b84c;
  --bubble-user: #1e3a5f;
  --bubble-agent: #1a1f28;
  --nav-h: 56px;
  --top-h: 52px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
h1 { font-size: 1.05rem; margin: 0; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: .85em; }
.sub { color: var(--sub); }
.hint { color: var(--sub); font-size: .8rem; margin-top: 1rem; }
.status { color: var(--sub); font-size: .9rem; min-height: 1.2em; margin: .8rem 0 0; }
.banner {
  background: #3a1d1d; border: 1px solid #6b2b2b; color: #ffb4b4;
  padding: .5rem .8rem; margin: .5rem .75rem 0; border-radius: 8px; font-size: .85rem;
}
.wide { width: 100%; }

/* topbar */
#topbar {
  height: var(--top-h);
  flex: 0 0 auto;
  display: flex; align-items: center; gap: .5rem;
  padding: 0 .6rem;
  padding-top: env(safe-area-inset-top);
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-actions { display: flex; gap: .25rem; min-width: 44px; justify-content: flex-end; }
.iconbtn {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  min-width: 40px; min-height: 40px; border-radius: 10px;
  font-size: 1.1rem; cursor: pointer; padding: 0 .5rem;
}
.iconbtn:active { background: var(--card); }
.iconbtn.danger { color: var(--danger); border-color: #5a2b2b; }

/* main + views */
main { flex: 1; overflow: hidden; position: relative; }
.view { position: absolute; inset: 0; overflow-y: auto; padding: 1rem .9rem calc(var(--nav-h) + 1.2rem + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.view.center { display: flex; align-items: center; justify-content: center; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.2rem 1.1rem; max-width: 26rem; margin: 0 auto;
}
label { display: block; font-size: .85rem; color: var(--sub); margin: .9rem 0 .3rem; }
input[type=email], input[type=text], textarea, select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .7rem; font-size: 1rem; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: none; max-height: 8rem; }
button {
  font-family: inherit; font-size: 1rem; cursor: pointer;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: .55rem .9rem;
}
button:active { filter: brightness(1.2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { background: transparent; border-color: #6b2b2b; color: var(--danger); }
.code {
  font-size: 2rem; letter-spacing: .4em; text-align: center;
  font-family: ui-monospace, monospace; font-weight: 700;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 10px;
  padding: .7rem 1rem .7rem calc(1rem + .4em); margin: .9rem 0;
}

/* files (W2.3) */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem; margin-bottom: .8rem; }
.crumb { background: transparent; border: none; color: var(--accent); font-size: .9rem; padding: .2rem .35rem; border-radius: 6px; }
.crumb:active { background: var(--bg2); }
.crumb-sep { color: var(--sub); font-size: .85rem; }
.file-row {
  display: flex; justify-content: space-between; align-items: center; gap: .7rem;
  width: 100%; text-align: left; background: var(--bg); padding: .55rem .7rem;
}
.file-row:active { border-color: var(--accent); }
.file-name { font-size: .95rem; overflow-wrap: anywhere; }
.file-meta { color: var(--sub); font-size: .75rem; white-space: nowrap; }
input[type=file].hidden { display: none; }
label.chk { display: flex; align-items: center; gap: .45rem; margin: .7rem 0 0; font-size: .85rem; }
label.chk input { width: auto; }

/* session list */
.list { display: flex; flex-direction: column; gap: .5rem; }
.list.small { gap: .4rem; }
.session-item {
  display: flex; flex-direction: column; gap: .2rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .8rem; width: 100%; text-align: left;
}
.session-item .title { font-size: .98rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .meta { display: flex; gap: .5rem; flex-wrap: wrap; font-size: .75rem; color: var(--sub); }
.badge {
  display: inline-block; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 999px; padding: .05rem .55rem; font-size: .72rem; color: var(--sub);
}
.badge.accent { color: var(--accent); border-color: #2c4a75; }
.device-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .7rem; font-size: .85rem;
}
.device-item .grow { flex: 1; min-width: 0; }
.device-item .sub { font-size: .75rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.dot.ok { background: var(--ok); }
.dot.off { background: #555; }

/* chat */
#view-chat { display: flex; flex-direction: column; padding: 0; }
#view-chat .chat {
  flex: 1; overflow-y: auto;
  padding: .75rem .8rem .5rem;
  display: flex; flex-direction: column; gap: .65rem;
  -webkit-overflow-scrolling: touch;
}
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.agent { align-self: flex-start; align-items: flex-start; }
.msg .who { font-size: .68rem; color: var(--sub); margin-bottom: .15rem; padding: 0 .2rem; }
.msg-body {
  border-radius: 14px; padding: .55rem .75rem;
  overflow-wrap: break-word; word-break: break-word;
}
.msg.user .msg-body { background: var(--bubble-user); border: 1px solid #2c4a75; border-bottom-right-radius: 4px; }
.msg.agent .msg-body { background: var(--bubble-agent); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-body img.attach { max-width: 160px; max-height: 160px; border-radius: 8px; display: block; margin-top: .4rem; }
.msg-body .md { font-size: .95rem; }
.msg-body .md > *:first-child { margin-top: 0; }
.msg-body .md > *:last-child { margin-bottom: 0; }
.msg-body .md pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .7rem; overflow-x: auto; font-size: .8rem;
}
.msg-body .md code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85em; }
.msg-body .md p > code, .msg-body .md li > code { background: var(--bg); padding: .05rem .3rem; border-radius: 4px; }
.msg-body .md table { border-collapse: collapse; font-size: .85rem; }
.msg-body .md th, .msg-body .md td { border: 1px solid var(--line); padding: .25rem .5rem; }
details.thought { margin-bottom: .4rem; font-size: .8rem; color: var(--sub); }
details.thought summary { cursor: pointer; user-select: none; padding: .1rem 0; }
details.thought .thought-text { white-space: pre-wrap; margin: .3rem 0 0; padding-left: .6rem; border-left: 2px solid var(--line); }
.turn-foot { font-size: .7rem; color: var(--sub); margin-top: .35rem; padding: 0 .2rem; }
.tool {
  align-self: flex-start; max-width: 95%;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  font-size: .8rem; color: var(--sub);
}
.tool summary { cursor: pointer; padding: .45rem .7rem; list-style: none; display: flex; gap: .5rem; align-items: center; }
.tool summary::-webkit-details-marker { display: none; }
.tool .tool-title { color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool .tool-io { padding: 0 .7rem .55rem; white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: .72rem; max-height: 12rem; overflow-y: auto; }
.tool .st { font-size: .7rem; border-radius: 999px; padding: .05rem .5rem; border: 1px solid var(--line); }
.tool .st.completed { color: var(--ok); border-color: #2b5a41; }
.tool .st.failed { color: var(--danger); border-color: #6b2b2b; }
.tool .st.in_progress { color: var(--warn); border-color: #6b552b; }
.sysline { align-self: center; font-size: .75rem; color: var(--sub); background: var(--bg2); border-radius: 999px; padding: .2rem .8rem; }

/* footer / composer */
#chat-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--bg2);
  padding: .45rem .6rem calc(.6rem + env(safe-area-inset-bottom));
}
#statusline { display: flex; gap: .5rem; align-items: center; min-height: 1.4rem; margin-bottom: .3rem; font-size: .78rem; color: var(--sub); }
#mode-picker { width: auto; max-width: 11rem; padding: .2rem .5rem; font-size: .78rem; border-radius: 8px; }
#run-status { flex: 1; }
#run-status.running { color: var(--warn); }
#attach-bar { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .35rem .5rem; }
#attach-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
#attach-name { flex: 1; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { display: flex; gap: .45rem; align-items: flex-end; }
.composer textarea { flex: 1; }
#btn-send { min-width: 4.6rem; }
#btn-stop { display: none; min-width: 4.2rem; }
#btn-stop.show { display: inline-block; }
.steering #btn-send { background: var(--warn); border-color: var(--warn); }

/* bottom nav */
#bottomnav {
  flex: 0 0 auto;
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  position: sticky; bottom: 0; z-index: 10;
}
#bottomnav button {
  flex: 1; border: none; background: transparent; border-radius: 0;
  padding: .55rem 0 .45rem; font-size: .78rem; color: var(--sub);
  border-top: 2px solid transparent;
}
#bottomnav button.active { color: var(--accent); border-top-color: var(--accent); }

/* modal */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-card { width: 100%; max-width: 22rem; }
.modal-actions { display: flex; gap: .6rem; margin-top: 1.1rem; justify-content: flex-end; }

/* desktop niceties */
@media (min-width: 760px) {
  main { max-width: 46rem; margin: 0 auto; width: 100%; }
  #topbar { max-width: 46rem; width: 100%; margin: 0 auto; border-radius: 0; }
  #bottomnav { max-width: 46rem; margin: 0 auto; width: 100%; }
  .msg { max-width: 75%; }
}
