:root {
  --bg: #f4efe7;
  --panel: #fbf7f2;
  --panel-strong: #fffdf9;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #ded2c4;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --user: #d9f2ec;
  --assistant: #fff5dc;
  --shadow: 0 18px 45px rgba(53, 42, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(180, 83, 9, 0.12), transparent 28%),
    var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.hidden {
  display: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(31, 41, 55, 0.28);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: min(92vw, 440px);
  padding: 24px;
  background: var(--panel);
  border: 1px solid rgba(222, 210, 196, 0.8);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.sidebar,
.chat-panel {
  padding: 24px;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(251, 247, 242, 0.82);
  backdrop-filter: blur(12px);
}

.brand,
.sidebar-section,
.chat-header,
.message-list,
.composer {
  background: var(--panel);
  border: 1px solid rgba(222, 210, 196, 0.8);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.brand,
.sidebar-section {
  padding: 20px;
}

.sidebar-section {
  margin-top: 18px;
}

.eyebrow,
.section-title,
.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.header-note {
  margin-bottom: 0;
  color: var(--muted);
}

.primary-button {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
}

.session-item.active {
  border-color: var(--accent);
  background: #eef8f6;
}

.session-item strong,
.session-item span {
  display: block;
}

.session-item span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chat-panel {
  display: grid;
  gap: 18px;
  grid-template-rows: auto 1fr auto;
}

.chat-header,
.composer {
  padding: 18px 20px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 220px));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  background: #fffdfa;
}

textarea {
  resize: vertical;
}

.message-list {
  min-height: 420px;
  padding: 22px;
  overflow: auto;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100%;
  text-align: center;
  color: var(--muted);
}

.message {
  max-width: 820px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.user {
  margin-left: auto;
  background: var(--user);
}

.message.assistant {
  background: var(--assistant);
}

.message-role {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.message-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.composer {
  display: grid;
  gap: 14px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}

.upload-box input[type="file"] {
  padding: 10px;
  background: #fffdfa;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chat-header {
    flex-direction: column;
  }

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

  .quick-actions,
  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row {
    justify-content: space-between;
  }
}
