:root {
  color-scheme: dark;
  --bg: #080b13;
  --panel: rgba(19, 25, 40, 0.86);
  --line: rgba(255, 255, 255, 0.11);
  --muted: #9ca9bf;
  --text: #f7f9ff;
  --accent: #7c6cff;
  --accent-2: #31d6c3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(124, 108, 255, 0.24), transparent 32rem),
    radial-gradient(circle at 85% 85%, rgba(49, 214, 195, 0.16), transparent 28rem),
    var(--bg);
}

button, input, textarea { font: inherit; }

button {
  border: 0;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  color: white;
  background: linear-gradient(135deg, var(--accent), #5b8cff);
  cursor: pointer;
  font-weight: 700;
}

button:disabled { cursor: wait; opacity: 0.55; }

.shell {
  width: min(920px, calc(100% - 2rem));
  min-height: 100vh;
  margin: auto;
  padding: 2rem 0 1rem;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 1rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.eyebrow { color: var(--accent-2); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.17em; }
.header-actions { display: flex; gap: 0.55rem; }
.ghost, .secondary { background: rgba(255,255,255,0.07); border: 1px solid var(--line); }

.messages {
  min-height: 55vh;
  max-height: calc(100vh - 225px);
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.message {
  width: fit-content;
  max-width: min(78ch, 88%);
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant { background: rgba(255,255,255,0.075); border: 1px solid var(--line); }
.message.user { margin-left: auto; background: linear-gradient(135deg, rgba(124,108,255,.78), rgba(70,111,213,.78)); }
.label { display: block; margin-bottom: 0.35rem; color: #bdc8db; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

textarea, input {
  width: 100%;
  color: var(--text);
  background: #0f1421;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem;
  outline: none;
}

textarea:focus, input:focus { border-color: var(--accent); }
.composer textarea { resize: none; border: 0; background: transparent; }
.notice { text-align: center; color: var(--muted); font-size: 0.78rem; }

dialog {
  width: min(620px, calc(100% - 2rem));
  padding: 0;
  color: var(--text);
  background: #111725;
  border: 1px solid var(--line);
  border-radius: 20px;
}

dialog::backdrop { background: rgba(2, 4, 10, 0.78); backdrop-filter: blur(5px); }
.admin-card { display: grid; gap: 1rem; padding: 1.25rem; }
.admin-card label { display: grid; gap: 0.45rem; color: #ccd5e6; font-size: 0.9rem; }
.dialog-title { display: flex; align-items: center; justify-content: space-between; }
.icon-button { padding: 0.25rem 0.6rem; font-size: 1.5rem; background: transparent; }
#protected-settings { display: grid; gap: 1rem; }
#protected-settings[hidden] { display: none; }
.status { min-height: 1.4em; color: var(--accent-2); }

@media (max-width: 640px) {
  .shell { width: min(100% - 1rem, 920px); padding-top: 0.8rem; }
  header { align-items: flex-start; }
  .header-actions { flex-direction: column; }
  .messages { max-height: calc(100vh - 225px); }
  .composer { grid-template-columns: 1fr; }
  .composer button { width: 100%; }
}
