:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  --ink: #17211d;
  --muted: #68736d;
  --line: #dce3df;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --green: #13795b;
  --green-dark: #0e5e46;
  --mint: #e6f4ef;
  --warm: #fff0e8;
  --danger: #a63b32;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

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

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #edf3f0;
}

.login-shell {
  width: min(100%, 390px);
}

.login-panel {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgb(27 52 41 / 10%);
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-weight: 750;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
}

.login-panel h1 {
  margin: 20px 0 24px;
  font-size: 24px;
  line-height: 1.2;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  margin-top: 8px;
  color: #46514c;
  font-size: 14px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c8d1cc;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.login-form input:focus,
.composer textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgb(19 121 91 / 14%);
}

.login-form button {
  min-height: 46px;
  margin-top: 14px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.login-form button:hover {
  background: var(--green-dark);
}

.form-error {
  margin: -10px 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  color: var(--danger);
  background: #fff4f2;
  font-size: 14px;
}

.chat-page {
  min-height: 100vh;
  background: #eef3f0;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 45px rgb(29 55 43 / 8%);
}

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

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

.assistant-identity h1 {
  margin: 0 0 3px;
  font-size: 17px;
  line-height: 1.2;
}

.assistant-identity p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions form {
  margin: 0;
}

.secondary-button {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #435049;
  background: #fff;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #435049;
  background: #fff;
  text-decoration: none;
  font-size: 18px;
}

.icon-button:hover {
  background: var(--canvas);
}

.secondary-button:hover {
  background: var(--canvas);
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 28px 20px 36px;
  background: #f8faf9;
}

.message {
  width: fit-content;
  max-width: min(76%, 620px);
  margin-bottom: 16px;
  padding: 11px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.message-author {
  display: block;
  margin-bottom: 5px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 750;
}

.message p {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.48;
  white-space: pre-wrap;
}

.user-message {
  margin-left: auto;
  border-color: #f0d9ca;
  background: var(--warm);
}

.user-message .message-author {
  color: #8a4f2c;
}

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

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: end;
  gap: 10px;
  padding: 14px 18px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 144px;
  resize: none;
  padding: 11px 13px;
  border: 1px solid #c8d1cc;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
  line-height: 1.4;
}

.send-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 24px;
  line-height: 1;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.settings-page {
  min-height: 100vh;
  padding: 40px 20px;
  background: #edf3f0;
}

.settings-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgb(27 52 41 / 8%);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.section-label {
  color: var(--green);
  font-size: 13px;
  font-weight: 750;
}

.settings-header h1 {
  margin: 5px 0 0;
  font-size: 25px;
}

.secondary-link {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #435049;
  text-decoration: none;
  white-space: nowrap;
}

.settings-form {
  display: grid;
  gap: 10px;
}

.settings-form label {
  margin-top: 8px;
  color: #46514c;
  font-size: 14px;
  font-weight: 700;
}

.settings-form h2 {
  margin: 22px 0 2px;
  font-size: 18px;
}

.settings-form input,
.settings-form select,
.settings-form textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #c8d1cc;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgb(19 121 91 / 14%);
}

.settings-form textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.5;
}

.primary-button {
  width: fit-content;
  min-height: 44px;
  margin-top: 10px;
  padding: 9px 18px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--green-dark);
}

.form-success {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-left: 3px solid var(--green);
  color: var(--green-dark);
  background: var(--mint);
  font-size: 14px;
}

.base-prompt {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.base-prompt summary {
  cursor: pointer;
  color: #46514c;
  font-weight: 700;
}

.base-prompt pre {
  max-height: 420px;
  overflow: auto;
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #35413b;
  background: #f7f9f8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .chat-header {
    min-height: 68px;
    padding: 10px 12px;
  }

  .assistant-identity p {
    max-width: 150px;
  }

  .brand-mark.small {
    width: 36px;
    height: 36px;
  }

  .header-actions {
    gap: 4px;
  }

  .secondary-button {
    padding: 6px 8px;
    font-size: 13px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .messages {
    padding: 20px 12px 26px;
  }

  .message {
    max-width: 88%;
  }

  .composer {
    padding-right: 10px;
    padding-left: 10px;
  }

  .settings-page {
    padding: 0;
  }

  .settings-shell {
    min-height: 100vh;
    padding: 24px 16px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .settings-header {
    align-items: center;
  }

  .settings-header h1 {
    font-size: 21px;
  }

  .secondary-link {
    padding: 7px 8px;
    font-size: 13px;
  }
}
