:root {
  color-scheme: light;
  --paper: #fbfaf6;
  --ink: #243036;
  --muted: #68747a;
  --line: #dfe6df;
  --blue: #3270d9;
  --blue-strong: #245cc0;
  --mint: #ddf4e8;
  --sun: #ffe9a8;
  --rose: #ffe2df;
  --peach: #fff0df;
  --lilac: #eee9ff;
  --white: #ffffff;
  --shadow: 0 18px 54px rgba(73, 82, 76, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(255, 240, 223, 0.82), transparent 42%),
    linear-gradient(300deg, rgba(238, 233, 255, 0.7), transparent 38%),
    linear-gradient(180deg, rgba(221, 244, 232, 0.54), transparent 48%),
    var(--paper);
}

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

button {
  cursor: pointer;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(120deg, rgba(255, 240, 223, 0.9), transparent 46%),
    linear-gradient(300deg, rgba(238, 233, 255, 0.76), transparent 42%),
    linear-gradient(180deg, rgba(221, 244, 232, 0.58), transparent 50%),
    var(--paper);
}

.access-gate.hidden {
  display: none;
}

.access-card {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.gate-copy,
.top-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.gate-copy {
  margin-top: -6px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: min(1220px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.app-shell.locked {
  display: none;
}

.workspace {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(340px, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
}

.topbar,
.settings-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 28px 30px 18px;
  background:
    linear-gradient(90deg, rgba(221, 244, 232, 0.72), transparent 58%),
    rgba(255, 255, 255, 0.38);
}

.eyebrow {
  margin: 0 0 5px;
  color: #526f5e;
  font-size: 13px;
  font-weight: 750;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 46px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 18px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 20px rgba(34, 48, 54, 0.06);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(260px, 1.35fr);
  gap: 14px;
  align-items: end;
  padding: 4px 30px 22px;
  background: rgba(255, 255, 255, 0.38);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
}

select,
input {
  height: 48px;
  padding: 0 14px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.model-field select {
  font-weight: 750;
}

.model-field.needs-key select {
  border-color: #f1cbcb;
  background: var(--rose);
}

.chat-panel {
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 24px 30px;
  background:
    linear-gradient(180deg, rgba(251, 250, 246, 0.66), rgba(255, 255, 255, 0.72)),
    rgba(251, 250, 246, 0.72);
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  margin: 0 0 14px;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 38px;
}

.message.user .avatar {
  grid-column: 2;
  background: var(--sun);
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  background: #eaf1ff;
}

.avatar {
  display: grid;
  min-width: 40px;
  width: fit-content;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  padding: 0 8px;
  color: #0e4734;
  background: var(--mint);
  font-size: 15px;
  font-weight: 850;
  box-shadow: 0 8px 18px rgba(34, 48, 54, 0.08);
}

.bubble {
  width: fit-content;
  max-width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.94);
  line-height: 1.7;
  white-space: pre-wrap;
  box-shadow: 0 10px 24px rgba(34, 48, 54, 0.05);
}

.welcome-bubble {
  border-color: #c8e5d4;
  background: #f5fff8;
  font-weight: 720;
}

.rich-answer {
  display: grid;
  gap: 9px;
  white-space: normal;
}

.rich-answer p {
  margin: 0;
}

.rich-answer strong {
  border-radius: 6px;
  padding: 1px 5px;
  color: #173b6d;
  background: #eaf1ff;
  font-weight: 850;
}

.answer-heading {
  width: fit-content;
  border-radius: 8px;
  padding: 5px 10px;
  color: #14523e;
  background: var(--mint);
  font-size: 15px;
  font-weight: 900;
}

.answer-step {
  border-left: 4px solid var(--blue);
  border-radius: 0 8px 8px 0;
  padding: 7px 10px;
  background: #f3f7ff;
  font-weight: 720;
}

.related-question {
  border: 1px solid #bfd5ff;
  border-radius: 8px;
  padding: 8px 10px;
  color: #173b6d;
  background: #f7faff;
  font-weight: 800;
}

.answer-encourage {
  border: 1px solid #efd584;
  border-radius: 8px;
  padding: 8px 10px;
  color: #604812;
  background: #fff7d7;
  font-weight: 800;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 14px;
  padding: 18px 30px 24px;
  background: rgba(255, 255, 255, 0.5);
}

textarea {
  min-height: 64px;
  max-height: 160px;
  resize: vertical;
  padding: 14px 15px;
  line-height: 1.5;
}

.composer button,
.primary-action,
.secondary-action {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: linear-gradient(135deg, var(--blue), #4d8be6);
  font-weight: 800;
}

.composer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.composer button:hover,
.primary-action:hover {
  background: linear-gradient(135deg, var(--blue-strong), #3270d9);
}

.secondary-action {
  color: #205144;
  background: var(--mint);
}

.secondary-action:hover {
  background: #c9eedc;
}

.composer button:disabled,
.primary-action:disabled {
  cursor: wait;
  opacity: 0.68;
}

.muted,
.form-message {
  color: var(--muted);
  line-height: 1.55;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(21, 31, 36, 0.42);
}

.settings-card {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.companion-settings {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.settings-card code {
  color: #184e77;
  font-weight: 750;
}

.form-message {
  min-height: 22px;
  margin: 0;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .model-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    margin: 10px auto;
  }

  .workspace {
    grid-template-rows: auto auto minmax(300px, 1fr) auto;
  }

  .topbar,
  .controls,
  .chat-panel,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .controls,
  .composer {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }

  .top-copy {
    font-size: 14px;
  }
}
