:root {
  color-scheme: light;
  --bg: #eef3f4;
  --ink: #172022;
  --muted: #637174;
  --panel: #ffffff;
  --line: #d9e1e3;
  --accent: #0f7b68;
  --accent-dark: #095d50;
  --accent-soft: #dff1ed;
  --user: #12322d;
  --assistant: #f6f8f8;
  --danger: #9a3412;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 123, 104, 0.12), transparent 38%),
    var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(360px, 1.18fr);
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.brand-panel,
.chat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(20, 42, 47, 0.12);
  overflow: hidden;
}

.brand-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 520px;
}

.brand-copy {
  padding: 30px;
}

.eyebrow,
.status-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1.02;
}

h2 {
  font-size: 1.1rem;
}

.brand-copy p:last-child {
  margin: 18px 0 0;
  max-width: 36rem;
  color: var(--muted);
  line-height: 1.65;
}

.brand-panel img {
  width: 100%;
  height: 100%;
  min-height: 340px;
  object-fit: cover;
  object-position: center top;
  border-top: 1px solid var(--line);
}

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

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1.25rem;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 20px;
}

.message {
  max-width: min(86%, 720px);
  padding: 13px 15px;
  border-radius: 8px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: var(--user);
  color: #fff;
}

.message.assistant {
  align-self: flex-start;
  background: var(--assistant);
  border: 1px solid var(--line);
}

.message.error {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--danger);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfc;
}

.composer textarea {
  width: 100%;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  outline: none;
}

.composer textarea:focus,
.settings-card input:focus,
.settings-card select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 104, 0.14);
}

.composer button,
.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 0 20px;
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.secondary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  padding: 10px 14px;
}

.settings-dialog {
  width: min(520px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 26px 70px rgba(16, 32, 35, 0.24);
}

.settings-dialog::backdrop {
  background: rgba(11, 25, 28, 0.45);
}

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

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.settings-card input,
.settings-card select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  outline: none;
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.settings-actions .primary-button {
  padding: 10px 18px;
}

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

  .brand-panel {
    min-height: 0;
  }

  .brand-panel img {
    max-height: 240px;
  }

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

  .message {
    max-width: 94%;
  }
}

@media (max-width: 520px) {
  .brand-copy,
  .messages {
    padding: 16px;
  }

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

  .composer button {
    min-height: 44px;
  }
}
