:root {
  color-scheme: light;
  --page: #f6f7f4;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #687382;
  --line: #d9dfd8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --user: #0f766e;
  --assistant: #eef2ec;
  --danger: #b42318;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(132, 91, 54, 0.08)),
    var(--page);
  color: var(--ink);
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
}

.chat-panel {
  width: min(960px, 100%);
  height: min(860px, calc(100vh - 36px));
  min-height: 520px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(29, 36, 48, 0.16);
  overflow: hidden;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--accent);
  background: #e5f3ef;
  border: 1px solid #b8dcd3;
  border-radius: 8px;
}

.brand-mark svg,
.icon-button svg,
.send-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.send-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  color: var(--muted);
  background: transparent;
}

.icon-button:hover {
  color: var(--danger);
  background: #f6e9e7;
}

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

.empty-state {
  margin: auto;
  display: grid;
  gap: 14px;
  justify-items: center;
  color: var(--muted);
  text-align: center;
  max-width: 360px;
}

.empty-state svg {
  width: 58px;
  height: 58px;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message {
  max-width: min(680px, 88%);
  padding: 12px 14px;
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 15px;
}

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

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

.message.error {
  align-self: center;
  color: var(--danger);
  background: #fff0ee;
  border: 1px solid #f1b6ae;
}

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

.composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  outline: none;
  background: #fbfcfa;
}

.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.send-button {
  color: #ffffff;
  background: var(--accent);
}

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

.send-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

dialog {
  width: min(360px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(29, 36, 48, 0.25);
}

dialog::backdrop {
  background: rgba(29, 36, 48, 0.4);
}

.password-card {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.password-card h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.password-card input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.password-card button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0;
  }

  .chat-panel {
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .messages {
    padding: 16px;
  }

  .message {
    max-width: 94%;
    font-size: 14px;
  }
}
