:root {
  --bg: #121416;
  --panel: #191c1f;
  --panel-2: #202428;
  --line: #30363b;
  --text: #eceff1;
  --muted: #9ba4aa;
  --accent: #e7b85d;
  --danger: #ef897d;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(231,184,93,.06), transparent 38%),
    var(--bg);
}
.login-card {
  width: min(390px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.mark, .empty-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #16120a;
  font-weight: 800;
  letter-spacing: 0;
}
.login h1 { margin: 18px 0 6px; font-size: 26px; }
.login p { color: var(--muted); line-height: 1.5; }
.login label { display: grid; gap: 8px; margin-top: 22px; color: var(--muted); font-size: 13px; }
.login input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
.login input:focus { border-color: var(--accent); }
.login button, .composer button {
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
}
.login button { width: 100%; padding: 12px; margin-top: 8px; }
.error { min-height: 20px; color: var(--danger) !important; font-size: 13px; }

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) auto;
}
.rail {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid var(--line);
  background: #15181a;
}
.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
}
.rail-head div { display: grid; gap: 3px; }
.rail-head strong { font-size: 15px; }
.rail-head span, .rail-foot, .conversation-head span { color: var(--muted); font-size: 12px; }
.icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}
.session-list { overflow: auto; padding: 0 10px 12px; }
.session-row {
  width: 100%;
  display: grid;
  gap: 5px;
  margin: 3px 0;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
}
.session-row:hover, .session-row.is-active { background: var(--panel); border-color: var(--line); }
.session-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.session-row span { color: var(--muted); font-size: 11px; }
.rail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.text { border: 0; background: transparent; color: var(--muted); padding: 5px; }
.text:hover { color: var(--text); }

.conversation {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.conversation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.conversation-head h1 { margin: 0 0 3px; font-size: 18px; letter-spacing: 0; }
.head-actions { display: flex; gap: 8px; }
.stop {
  border: 1px solid #74413b;
  border-radius: var(--radius);
  background: #34211f;
  color: #ffc0b8;
  padding: 7px 12px;
}
.messages { overflow: auto; padding: 28px clamp(18px, 5vw, 78px); }
.empty { max-width: 470px; margin: 12vh auto 0; text-align: center; }
.empty-mark { margin: 0 auto 18px; }
.empty h2 { margin: 0 0 8px; font-size: 22px; }
.empty p { color: var(--muted); line-height: 1.6; }
.message {
  max-width: 820px;
  margin: 0 auto 20px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.message.user { background: #23272b; margin-left: auto; }
.message.assistant { border-left: 2px solid var(--accent); }
.message small { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.live { min-height: 22px; }
.tool-line { max-width: 820px; margin: -12px auto 18px; color: var(--muted); font-size: 12px; }
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 16px clamp(18px, 5vw, 78px) 24px;
}
.composer textarea {
  resize: none;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 13px 15px;
  outline: none;
  line-height: 1.45;
}
.composer textarea:focus { border-color: #5b6267; }
.composer button { width: 42px; height: 42px; align-self: end; font-size: 20px; }
.composer button:disabled, .composer textarea:disabled { opacity: .45; cursor: default; }

.files {
  width: min(340px, 32vw);
  border-left: 1px solid var(--line);
  background: #15181a;
  overflow: auto;
}
.files header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.files-list { padding: 0 12px 18px; }
.file {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 8px;
  border: 0;
  border-bottom: 1px solid #25292d;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
}
.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file em { flex: none; color: var(--muted); font-style: normal; }

@media (max-width: 900px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); }
  .files {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 10;
    width: min(360px, 88vw);
  }
}
@media (max-width: 640px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .conversation-head { padding: 14px 16px; }
  .messages { padding: 20px 14px; }
  .composer { padding: 12px 14px 18px; }
  .message { margin-bottom: 14px; }
}
