:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #18202f;
  --muted: #657085;
  --border: #d9dee8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  padding: 24px;
}

.chat-panel,
.side-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 48px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  margin-bottom: 14px;
}

.topbar p,
.result-box p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
}

.status-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  min-width: 78px;
  text-align: center;
  padding: 7px 10px;
  font-size: 13px;
}

.chat-window {
  padding: 22px;
  overflow-y: auto;
}

.message {
  display: flex;
  margin-bottom: 16px;
}

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

.bubble {
  max-width: min(760px, 90%);
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
}

.assistant .bubble {
  background: #eef6f5;
  border: 1px solid #c9e2df;
}

.user .bubble {
  background: #e8edf5;
  border: 1px solid #d2dae8;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--border);
}

textarea,
input,
select,
button {
  font: inherit;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 74px;
  padding: 12px;
}

button {
  align-self: end;
  min-width: 92px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

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

.side-panel {
  padding: 20px;
  align-self: start;
  position: sticky;
  top: 24px;
}

.model-grid {
  display: grid;
  gap: 12px;
}

.model-row {
  display: grid;
  gap: 7px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.model-row label {
  color: var(--muted);
  font-size: 13px;
}

select,
input {
  height: 38px;
  padding: 7px 9px;
}

.result-box {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.meta {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
}

.meta code {
  white-space: pre-wrap;
  background: #f3f5f8;
  padding: 10px;
  border-radius: 8px;
  display: block;
  overflow-x: auto;
}

.download {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent-dark);
  font-weight: 700;
}

.status-success {
  color: var(--ok);
}

.status-failed,
.status-blocked {
  color: var(--danger);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .chat-panel {
    min-height: 70vh;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .topbar,
  .composer {
    grid-template-columns: 1fr;
    display: grid;
  }

  .composer button {
    width: 100%;
  }
}


.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h1 {
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.auth-error {
  margin-top: 12px;
  color: var(--danger);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.text-link {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}