* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a1a;
  --bg-alt: #232323;
  --bg-input: #2a2a2a;
  --bg-tool: #1f2630;
  --bg-tool-result: #1c2520;
  --bg-error: #2e1a1a;
  --border: #333;
  --text: #e6e6e6;
  --text-dim: #888;
  --text-faint: #666;
  --accent: #c97b4a;
  --accent-hover: #b06a3f;
  --user-bg: #2d3a4a;
  --tool-accent: #5a8fb8;
  --tool-result-accent: #6fa86b;
  --error-accent: #c96a6a;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.hidden { display: none !important; }

/* The sidebar/menu button only matters on small screens */
.mobile-only { display: none; }

/* ===== Login ===== */

#login-screen {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#login-form {
  background: var(--bg-alt);
  padding: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#login-form h1 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
  text-align: center;
}

#login-form input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
}

#login-form input:focus { outline: none; border-color: var(--accent); }

#login-form button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#login-form button:hover { background: var(--accent-hover); }

#login-error {
  color: var(--error-accent);
  font-size: 12px;
  min-height: 16px;
  text-align: center;
}

/* ===== App ===== */

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
}

#sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
}

#app:not(.files-open) #files-panel { display: none; }

#sidebar {
  width: 260px;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow-y: auto;
}

#new-chat, #logout {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 12px;
}

#logout {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  margin-top: auto;
  margin-bottom: 0;
}

#new-chat:hover { background: var(--accent-hover); }
#logout:hover { color: var(--text); border-color: var(--text-dim); }

#session-list {
  list-style: none;
  flex: 1;
}

#session-list li {
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

#session-list li:hover { background: var(--bg-input); color: var(--text); }
#session-list li.active { background: var(--bg-input); color: var(--text); }

.delete-btn, .edit-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  display: none;
  line-height: 1;
}

.delete-btn { font-size: 16px; }

#session-list li:hover .delete-btn,
#session-list li:hover .edit-btn { display: inline; }

.edit-btn:hover { color: var(--accent); }
.delete-btn:hover { color: var(--error-accent); }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
}

header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 { font-size: 16px; font-weight: 500; color: var(--text-dim); flex: 1; }
#cwd-label { font-size: 11px; color: var(--text-faint); font-family: ui-monospace, monospace; margin-right: 12px; }

.header-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
}
.header-btn:hover { border-color: var(--accent); }
.header-btn.active { background: var(--accent); border-color: var(--accent); }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 820px;
  width: 100%;
  align-self: center;
  padding: 12px 16px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 14px;
}

.msg.user {
  background: var(--user-bg);
}

.msg.assistant {
  background: transparent;
  padding: 4px 0;
}

.msg .role {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.msg.thinking-block {
  color: var(--text-dim);
  font-style: italic;
  border-left: 2px solid var(--border);
  padding-left: 12px;
}

/* tool use card */
.tool-call {
  max-width: 820px;
  width: 100%;
  align-self: center;
  background: var(--bg-tool);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tool-accent);
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.tool-call summary {
  cursor: pointer;
  padding: 8px 12px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary::before {
  content: "▶";
  margin-right: 8px;
  font-size: 9px;
  color: var(--text-dim);
  transition: transform 0.15s;
}

.tool-call[open] summary::before { transform: rotate(90deg); display: inline-block; }

.tool-call .tool-name {
  color: var(--tool-accent);
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-call .tool-summary {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.tool-call pre {
  padding: 10px 12px;
  background: rgba(0,0,0,0.25);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* tool result card */
.tool-result {
  max-width: 820px;
  width: 100%;
  align-self: center;
  background: var(--bg-tool-result);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tool-result-accent);
  border-radius: 6px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  overflow: hidden;
}

.tool-result.error { background: var(--bg-error); border-left-color: var(--error-accent); }

.tool-result summary {
  cursor: pointer;
  padding: 8px 12px;
  list-style: none;
  display: flex;
  align-items: center;
  user-select: none;
}

.tool-result summary::-webkit-details-marker { display: none; }
.tool-result summary::before {
  content: "▶";
  margin-right: 8px;
  font-size: 9px;
  color: var(--text-dim);
  transition: transform 0.15s;
}

.tool-result[open] summary::before { transform: rotate(90deg); display: inline-block; }

.tool-result .label {
  color: var(--tool-result-accent);
  font-weight: 600;
}

.tool-result.error .label { color: var(--error-accent); }

.tool-result .preview {
  color: var(--text-dim);
  margin-left: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.tool-result pre {
  padding: 10px 12px;
  background: rgba(0,0,0,0.25);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}

.error-banner {
  max-width: 820px;
  width: 100%;
  align-self: center;
  background: var(--bg-error);
  border: 1px solid var(--error-accent);
  color: var(--error-accent);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
}

/* ===== AskUserQuestion menu ===== */

.ask-user {
  max-width: 820px;
  width: 100%;
  align-self: center;
  background: linear-gradient(180deg, rgba(201,123,74,0.10), rgba(201,123,74,0.04));
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 14px;
}

.ask-user.archived {
  opacity: 0.65;
  background: var(--bg-alt);
  border-color: var(--border);
}

.ask-user-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  font-weight: 600;
}

.ask-user.archived .ask-user-head { color: var(--text-dim); }

.ask-user-q {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ask-user-tag {
  align-self: flex-start;
  background: rgba(201,123,74,0.18);
  color: var(--accent);
  border-radius: 10px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ask-user-question {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  font-weight: 500;
}

.ask-user-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ask-user-opt {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-height: 42px;
  transition: border-color 0.12s, background 0.12s;
  flex: 1 1 auto;
  min-width: 140px;
  max-width: 100%;
}

.ask-user-opt:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--bg-tool);
}

.ask-user-opt.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.ask-user-opt.selected .ask-user-opt-desc { color: rgba(255,255,255,0.85); }

.ask-user-opt:disabled { cursor: default; }

.ask-user-opt-label { font-weight: 500; }

.ask-user-opt-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.3;
}

.ask-user-other {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}

.ask-user-other:focus { outline: none; border-color: var(--accent); }
.ask-user-other:disabled { opacity: 0.6; }

.ask-user-send {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.ask-user-send:hover:not(:disabled) { background: var(--accent-hover); }
.ask-user-send:disabled { opacity: 0.6; cursor: default; }

#attachments-bar {
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

#attachments-bar:empty { display: none; }

.attach-pill {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 8px 4px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  max-width: 240px;
}

.attach-pill .pill-icon { font-size: 13px; }
.attach-pill .pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-pill .pill-size { color: var(--text-faint); font-size: 11px; }

.attach-pill button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}

.attach-pill button:hover { color: var(--error-accent); }

.attach-pill.uploading { opacity: 0.6; }

.user-attachments {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-attachments .file-chip {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: var(--text-dim);
}

#composer {
  padding: 12px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.icon-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0;
  width: 42px;
  height: 42px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover { border-color: var(--accent); }
.icon-btn.active { background: var(--accent); border-color: var(--accent); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Files panel ===== */

#files-panel {
  width: 320px;
  background: var(--bg-alt);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#files-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

#files-toolbar button {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
#files-toolbar button:hover { border-color: var(--accent); }

#files-path-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  min-width: 0;
}
#files-path-input:focus { outline: none; border-color: var(--accent); }

#files-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  margin: 0;
}

.fs-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  user-select: none;
}

.fs-entry:hover { background: var(--bg-input); }

.fs-entry .fs-icon {
  font-size: 13px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.fs-entry.dir .fs-name { color: var(--tool-accent); font-weight: 500; }
.fs-entry.link .fs-name { color: var(--accent); font-style: italic; }

.fs-entry .fs-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
}

.fs-entry .fs-size {
  font-size: 10px;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
  flex-shrink: 0;
}

#files-status {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  font-family: ui-monospace, monospace;
}

/* ===== Preview modal ===== */

#file-preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 32px;
}

.preview-box {
  background: var(--bg-alt);
  border-radius: 10px;
  width: 90vw;
  max-width: 900px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

#preview-name {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#preview-size {
  color: var(--text-faint);
  font-size: 11px;
  font-family: ui-monospace, monospace;
}

.preview-header button,
.preview-header a {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  display: inline-block;
}
.preview-header button:hover,
.preview-header a:hover { border-color: var(--accent); }

#preview-close {
  font-size: 14px;
  padding: 5px 9px;
}

#preview-body {
  flex: 1;
  overflow: auto;
  padding: 0;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

#preview-body pre {
  width: 100%;
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  line-height: 1.5;
}

#preview-body .preview-image {
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  display: block;
}

#preview-body .preview-meta {
  margin: auto;
  color: var(--text-dim);
  text-align: center;
  font-size: 13px;
  padding: 24px;
}

/* Camera modal */
#camera-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.camera-box {
  background: var(--bg-alt);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 90vw;
  max-height: 90vh;
}

.camera-box video {
  max-width: 640px;
  max-height: 70vh;
  width: 100%;
  background: black;
  border-radius: 8px;
}

.camera-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.camera-actions button {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
}

.camera-actions button#camera-shoot {
  background: var(--accent);
  border-color: var(--accent);
}

.camera-actions button:hover { border-color: var(--accent); }

#camera-error {
  color: var(--error-accent);
  font-size: 13px;
  text-align: center;
  min-height: 16px;
}

#input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 200px;
  line-height: 1.4;
}

#input:focus { outline: none; border-color: var(--accent); }

#send {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  height: 42px;
}

#send:hover:not(:disabled) { background: var(--accent-hover); }
#send:disabled { opacity: 0.5; cursor: not-allowed; }

#send.stopping {
  background: var(--error-accent);
  color: white;
}
#send.stopping:hover:not(:disabled) { background: #b85a5a; }

.stopped-notice {
  align-self: center;
  max-width: 820px;
  width: 100%;
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
  padding: 4px 8px;
  text-align: center;
}

/* ===== Copy button ===== */

.msg, .tool-call summary, .tool-result summary {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 5px;
  width: 26px;
  height: 26px;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, border-color 0.12s;
  z-index: 1;
}

.msg:hover .copy-btn,
.tool-call summary:hover .copy-btn,
.tool-result summary:hover .copy-btn,
.copy-btn:focus {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.copy-btn.copied {
  color: var(--tool-result-accent);
  border-color: var(--tool-result-accent);
  opacity: 1;
}

/* On touch devices hover doesn't fire — keep buttons subtly visible. */
@media (hover: none) {
  .copy-btn { opacity: 0.45; }
  .copy-btn:active { opacity: 1; }
}

/* Avoid the copy button colliding with the bubble's text on the right edge */
.msg.user .body, .msg.assistant .body { padding-right: 30px; }
.msg.thinking-block .body { padding-right: 30px; }

/* The summary already has flex layout with elements; reserve the right space */
.tool-call summary, .tool-result summary { padding-right: 38px !important; }

/* ===== Thinking indicator ===== */

.thinking-indicator {
  align-self: center;
  max-width: 820px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

.thinking-indicator .ti-dots {
  display: inline-flex;
  gap: 3px;
}

.thinking-indicator .ti-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: ti-bounce 1.2s infinite ease-in-out both;
}

.thinking-indicator .ti-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-indicator .ti-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-indicator .ti-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes ti-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1.0); opacity: 1; }
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ========== Mobile / small tablets ========== */

@media (max-width: 900px) {
  #app.files-open #files-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 86vw;
    max-width: 360px;
    z-index: 50;
    box-shadow: -8px 0 24px rgba(0,0,0,0.4);
  }
}

@media (max-width: 768px) {
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }

  /* Sidebar becomes a slide-in drawer */
  #sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 82vw;
    max-width: 320px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.4);
  }
  #app.sidebar-open #sidebar { transform: translateX(0); }

  /* Files panel: full-width drawer from the right */
  #app.files-open #files-panel {
    width: 92vw;
    max-width: none;
  }

  /* Header tweaks */
  header {
    padding: 10px 12px;
    gap: 8px;
  }
  header h1 {
    font-size: 14px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* cwd label takes too much room on mobile, hide */
  #cwd-label { display: none; }

  .header-btn {
    padding: 8px 10px;
    min-width: 38px;
    height: 38px;
    font-size: 16px;
  }

  /* Messages: tighter padding */
  #messages {
    padding: 14px 12px;
    gap: 10px;
  }

  .msg, .tool-call, .tool-result, .error-banner, .ask-user {
    max-width: 100%;
    font-size: 14px;
  }

  .msg { padding: 10px 12px; }

  .ask-user { padding: 12px; gap: 12px; }
  .ask-user-question { font-size: 14px; }
  .ask-user-opt {
    flex: 1 1 100%;
    min-width: 0;
    padding: 12px 14px;
    font-size: 15px;  /* easy tap targets */
  }
  .ask-user-other { font-size: 16px; padding: 11px 12px; }
  .ask-user-send { width: 100%; padding: 12px; font-size: 15px; }

  /* Composer: keep buttons compact and prevent zoom on iOS */
  #composer {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    gap: 4px;
    flex-wrap: wrap;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  #input {
    flex: 1 1 100%;
    order: -1;
    width: 100%;
    font-size: 16px; /* prevents iOS auto-zoom */
    padding: 10px 12px;
    max-height: 140px;
  }

  #send {
    margin-left: auto;
    padding: 0 16px;
    height: 38px;
    font-size: 14px;
    min-width: 76px;  /* keeps width stable when text swaps to "Parar" */
  }

  #attachments-bar { padding: 0 10px; }

  /* Preview modal: full screen */
  #file-preview-modal { padding: 0; }
  .preview-box {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
  .preview-header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  #preview-name { font-size: 12px; flex: 1 1 100%; order: -1; }

  /* Camera modal */
  .camera-box {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding: 12px;
    justify-content: center;
  }
  .camera-box video { max-height: 65vh; }
  .camera-actions button { padding: 12px 14px; font-size: 14px; }

  /* Files panel takes more room on mobile */
  #files-panel {
    background: var(--bg-alt);
  }
  #files-toolbar { padding: 8px; }
  #files-path-input { font-size: 12px; padding: 6px 8px; }

  /* Login: bigger touch targets, no iOS zoom */
  #login-form input { font-size: 16px; }
}

/* Very small phones */
@media (max-width: 380px) {
  header h1 { font-size: 13px; }
  .icon-btn { width: 36px; height: 36px; }
  #send { padding: 0 12px; font-size: 13px; }
  #messages { padding: 10px 8px; }
  .msg { padding: 9px 10px; font-size: 13px; }
}
