/* Variables & Reset */
:root {
  --bg: #080d17; --panel:#1F2937; --muted:#9CA3AF; --text:#F9FAFB; --accent:#8B5CF6;
  --border:#374151; --ring:#8B5CF6;
  --radius:12px;
  /* All decorative shadows are removed by setting this variable to 'none' */
  --shadow: none;
}
* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; touch-action:manipulation; }
body {
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:15px/1.6 Charter,"Bitstream Charter","Sitka Text",Cambria,serif;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
  touch-action:manipulation;
  overflow:hidden;
}

/* Layout */
.app {
  display:flex;
  flex-direction:column;
  height:100dvh;
  overflow:hidden;
}
.grow, .spacer { flex:1; }

/* Header */
header {
  /* backdrop-filter was removed to eliminate the blur/gradient effect */
  background:var(--bg);
  border-bottom:1px solid var(--border);
  position:absolute;
  top:0; left:0; right:0;
  z-index:5;
  transform:translateY(-100%);
  transition:transform 0.3s ease;
}
header.show { transform:translateY(0); }
.bar {
  display:flex;
  align-items:center;
  gap:10px;
  padding:14px 16px;
}

.header-toggle {
  position:fixed;
  top:12px;
  right:12px;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:center;
  width:40px; height:40px;
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:50%;
  box-shadow:var(--shadow);
  cursor:pointer;
  opacity:0.6;
  transition:all 0.3s;
}
.header-toggle:active { transform:scale(0.95); }
header.show + * .header-toggle { top:70px; }
.header-toggle svg {
  width:20px; height:20px;
  color:var(--muted);
  stroke:currentColor;
  opacity:0.6;
  transition:transform 0.3s;
}
header.show ~ .header-toggle svg { transform:rotate(180deg); }

/* Buttons */
.btn {
  appearance:none;
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  padding:10px 14px;
  border-radius:10px;
  box-shadow:var(--shadow);
  cursor:pointer;
  font-family:inherit;
  font-size:15px;
  transition:.2s;
}
.btn:active { transform:translateY(1px); }
.btn.ghost { background:transparent; box-shadow:none; }
.btn.row { display:inline-flex; align-items:center; gap:8px; }
.send {
  padding:12px 16px;
  border-radius:10px;
  border:1px solid transparent;
  background:var(--accent);
  color:white;
  font-weight:500;
  font-family:inherit;
  font-size:15px;
}
.stop { background:var(--border); color:var(--text); }

/* Messages */
.messages-wrap {
  flex-grow:1;
  position:relative;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  background:var(--bg);
}
.messages {
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:18px 12px 10px 12px;
}
.row { display:flex; gap:10px; align-items:flex-start; }
.row.user { justify-content:flex-end; }
.bubble {
  max-width:900px;
  width:100%;
  padding:14px 16px;
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  border:1px solid var(--border);
  word-wrap:break-word;
  white-space:pre-wrap;
  line-height:1.6;
  font-size:15px;
  animation:fadeIn 0.3s ease;
  will-change:contents;
  contain:layout style;
}
.bubble.assistant {
  background:var(--panel);
  border-color:var(--border);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeSpeed;
}
.bubble.user {
  background:var(--bg);
  border-color:var(--panel);
  color:var(--text);
}
.bubble.editing { outline:2px solid var(--accent); }
.bubble.typing { display:flex; gap:4px; padding:16px 20px; }
.bubble.typing span {
  width:8px; height:8px;
  border-radius:50%;
  background:var(--muted);
  animation:typing 1.4s infinite;
}
.bubble.typing span:nth-child(2) { animation-delay:0.2s; }
.bubble.typing span:nth-child(3) { animation-delay:0.4s; }
.reserve { min-height:2.5vh; }

/* Composer */
.composer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 14px 20px;
  display: block;
  box-shadow: none;
}
.composer .row2 {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 0;
  margin: 0;
}
textarea {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 48px;
  max-height: 150px;
  resize: none;
  padding: 12px 14px;
  border-radius: 10px;
  /* The border is now a 1px solid line for visibility before typing */
  border: 1px solid var(--border);
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font: 16px/1.6 Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
  outline: none;
  caret-color: var(--text);
  transition: box-shadow .12s ease, background .12s ease;
}

/* placeholder muted */
textarea::placeholder { color: var(--muted); opacity: 1; }

/* accessible focus state — subtle, non-panelizing ring */
textarea:focus,
textarea:focus-visible {
  /* box-shadow was replaced with an outline for a flat look */
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

/* kill platform autofill shadows on WebKit */
textarea:-webkit-autofill,
textarea:-webkit-autofill:focus {
  /* This box-shadow is a functional hack to override browser-default autofill styles.
     Removing it can cause a bright white background on autofilled fields. */
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  box-shadow: 0 0 0 1000px var(--bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
}

/* ensure no pseudo-elements add rings */
textarea::before,
textarea::after { content: none; display: none; }

/* keep Send button visually separated without coloring the input */
.composer .send {
  margin-left: 8px;
  border: 1px solid transparent;
  box-shadow: none;
}

/* Sheets */
.sheet {
  position:fixed;
  inset:auto 0 0 0;
  background:var(--bg);
  border-top:1px solid var(--border);
  border-radius:16px 16px 0 0;
  /* box-shadow was removed for a flat design */
  box-shadow: none;
  transform:translateY(102%);
  transition:transform .25s ease;
  z-index:20;
}
.sheet.show { transform:translateY(0); }
.sheet .head {
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
}
.sheet .list { max-height:55dvh; overflow:auto; }
.thread {
  display:flex;
  gap:10px;
  align-items:center;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  cursor:pointer;
}
.thread:hover { background:var(--panel); }
.t-title { font-weight:600; }
.t-sub { font-size:12px; color:var(--muted); }

/* Debug */
.debug-list .entry {
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
}
.kv {
  display:grid;
  grid-template-columns:auto 1fr;
  gap:6px 12px;
  font-size:13px;
  color:var(--muted);
}
.kv .k { color:var(--muted); }
.kv .v { color:var(--text); }
.code {
  font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px;
  overflow:auto;
}
.pill {
  display:inline-block;
  padding:2px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
}

/* Menu */
.menu {
  position:fixed;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  box-shadow:var(--shadow);
  padding:6px;
  min-width:180px;
  z-index:50;
}
.menu.hidden { display:none; }
.menu button {
  width:100%;
  border:0;
  background:transparent;
  color:var(--text);
  padding:10px 12px;
  text-align:left;
  border-radius:8px;
  cursor:pointer;
  font-family:inherit;
}
.menu button:hover { background:var(--border); }

/* Modal */
.modal {
  position:fixed;
  top:50%; left:50%;
  transform:translate(-50%, -50%);
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  border-radius:var(--radius);
  padding:24px;
  box-shadow:var(--shadow);
  width:90%;
  max-width:400px;
  z-index:100;
}
.modal::backdrop {
  /* This is now a solid color, which will hide the page content behind it.
     backdrop-filter was also removed. */
  background:var(--bg);
}
.modal h3 { margin-top:0; }
.form-group { margin-bottom:16px; }
.form-group label {
  display:block;
  margin-bottom:8px;
  font-weight:600;
  color:var(--muted);
}
.form-group select,
.form-group input[type="number"] {
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--bg);
  color:var(--text);
  font-size:16px;
  font-family:inherit;
}
.modal-actions {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:24px;
}

/* Toast */
.toast {
  position:fixed;
  left:50%;
  bottom:18px;
  transform:translateX(-50%);
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 12px;
  box-shadow:var(--shadow);
  opacity:0;
  pointer-events:none;
  transition:opacity .25s;
}
.toast.show { opacity:1; }

/* Animations */
@keyframes typing {
  0%, 60%, 100% { opacity:0.3; transform:translateY(0); }
  30% { opacity:1; transform:translateY(-4px); }
}
@keyframes fadeIn {
  from { opacity:0; transform:translateY(8px); }
  to { opacity:1; transform:translateY(0); }
}