:root {
  color-scheme: dark;
  --bg:#111111;
  --panel:#1b1b1b;
  --panel-soft:rgba(26,26,26,0.94);
  --panel-border:rgba(255,255,255,0.08);
  --text:#ffffff;
  --muted:#c8c8c8;
  --brand:#ff6268;
  --field:#141414;
  --field-border:rgba(255,255,255,0.12);
  --assistant:#202020;
  --user:#3b1518;
  --user-border:rgba(255,98,104,0.28);
  --shadow:0 18px 40px rgba(0,0,0,0.28);
}

* { box-sizing:border-box; }

body {
  margin:0;
  min-height:100vh;
  font-family:Inter, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.06), transparent 34%),
    linear-gradient(180deg, #161616 0%, #111111 100%);
  color:var(--text);
}

.topbar {
  position:fixed;
  top:0;
  left:0;
  right:0;
  min-height:58px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:10px 22px;
  background:var(--panel-soft);
  border-bottom:1px solid var(--panel-border);
  box-shadow:var(--shadow);
  backdrop-filter:blur(14px);
  z-index:10;
}

.brand {
  color:var(--brand);
  font-family:Cinzel, Georgia, serif;
  font-size:21px;
  font-weight:700;
  letter-spacing:0;
  text-decoration:none;
  white-space:nowrap;
}

.brand:hover,
.brand:focus { color:var(--brand); }

.topbarMeta {
  color:var(--muted);
  font-size:14px;
  font-weight:500;
}

.appBackLink {
  color:var(--text);
  display:inline-flex;
  align-items:center;
  font-size:14px;
  font-weight:500;
  line-height:1;
  min-height:34px;
  padding:0 12px;
  border-radius:6px;
  text-decoration:none;
}

.appBackLink:hover,
.appBackLink:focus {
  background:rgba(255,255,255,.06);
  color:var(--text);
}

.chatShell {
  width:min(980px, calc(100% - 36px));
  margin:0 auto;
  padding:92px 0 44px;
}

.chatPanel {
  height:calc(100vh - 172px);
  min-height:520px;
  display:flex;
  flex-direction:column;
  background:rgba(27,27,27,0.92);
  border:1px solid var(--panel-border);
  border-radius:8px;
  box-shadow:0 12px 30px rgba(0,0,0,0.22);
  overflow:hidden;
}

.panelHeader {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:18px;
  padding:22px 24px 18px;
  border-bottom:1px solid var(--panel-border);
}

h1 {
  margin:0;
  font-size:30px;
  line-height:1.15;
  font-weight:700;
}

.panelHeader p {
  margin:7px 0 0;
  color:var(--muted);
  font-size:14px;
  line-height:1.45;
}

.modePill {
  display:inline-flex;
  align-items:center;
  min-height:28px;
  padding:5px 10px;
  border:1px solid rgba(255,98,104,0.34);
  border-radius:999px;
  color:#ffd4d6;
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  white-space:nowrap;
}

.messageList {
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:24px;
  overflow:auto;
}

.message {
  display:flex;
  width:100%;
}

.message.user { justify-content:flex-end; }
.message.assistant { justify-content:flex-start; }

.bubble {
  width:fit-content;
  max-width:min(74%, 680px);
  padding:13px 15px;
  border:1px solid var(--panel-border);
  border-radius:8px;
  background:var(--assistant);
  color:#f6f6f6;
  font-size:16px;
  line-height:1.62;
}

.message.user .bubble {
  background:var(--user);
  border-color:var(--user-border);
}

.bubble p { margin:0 0 10px; }
.bubble p:last-child { margin-bottom:0; }
.bubble .error { color:#ffb4b8; }

.chatFooter {
  border-top:1px solid var(--panel-border);
  background:rgba(17,17,17,0.78);
  padding:16px;
}

.chatForm {
  display:grid;
  grid-template-columns:minmax(0, 1fr) auto;
  gap:10px;
}

textarea,
button { font:inherit; }

textarea {
  width:100%;
  min-height:42px;
  resize:none;
  overflow:hidden;
  border:1px solid var(--field-border);
  background:var(--field);
  color:var(--text);
  padding:10px 12px;
  border-radius:8px;
  line-height:1.45;
  outline:none;
}

textarea:focus {
  border-color:rgba(255,98,104,0.55);
  box-shadow:0 0 0 3px rgba(255,98,104,0.12);
}

button {
  min-height:42px;
  min-width:96px;
  border:1px solid rgba(255,255,255,0.2);
  background:#050505;
  color:#ffffff;
  padding:8px 14px;
  border-radius:8px;
  cursor:pointer;
  font-weight:700;
  transition:background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

button:hover:not(:disabled) {
  background:rgba(255,255,255,0.08);
  border-color:rgba(255,255,255,0.24);
  transform:translateY(-1px);
}

button:disabled {
  opacity:0.5;
  cursor:not-allowed;
  transform:none;
}

.disclaimer {
  margin:12px 2px 0;
  color:rgba(255,255,255,0.58);
  font-size:12px;
  line-height:1.5;
}

.settingsControl {
  display:flex;
  align-items:center;
  gap:8px;
  margin:10px 2px 0;
  color:rgba(255,255,255,0.62);
  font-size:12px;
}

.settingsControl select {
  height:28px;
  border:1px solid rgba(255,255,255,0.12);
  border-radius:8px;
  background:#141414;
  color:#ffffff;
  padding:2px 8px;
  font:inherit;
}

@media (max-width: 680px) {
  .topbar {
    min-height:54px;
    padding:10px 16px;
  }

  .brand { font-size:18px; }

  .chatShell {
    width:calc(100% - 24px);
    padding-top:82px;
  }

  .chatPanel { height:calc(100vh - 118px); min-height:500px; }
  .panelHeader { flex-direction:column; padding:18px; }
  h1 { font-size:25px; }
  .messageList { padding:18px; }
  .bubble { max-width:88%; font-size:15px; }
  .chatForm { grid-template-columns:1fr; }
  button { width:100%; }
}
