:root {
  color-scheme: light;
  --ink: #17201d;
  --ink-soft: #4d5954;
  --forest: #15211d;
  --forest-raised: #1e2d27;
  --forest-line: #30413a;
  --paper: #f5f3ec;
  --paper-raised: #fffef9;
  --line: #dedbd0;
  --accent: #b7e36a;
  --accent-deep: #2f5a22;
  --danger: #b54235;
  --shadow: 0 24px 70px rgba(22, 31, 27, 0.14);
  --radius-lg: 24px;
  --radius-md: 15px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

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

.eyebrow {
  margin: 0;
  color: var(--accent-deep);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(183, 227, 106, 0.55);
  border-radius: 16px;
  color: var(--forest);
  background: var(--accent);
  font-family: Georgia, serif;
  font-size: 1.6rem;
  font-weight: 800;
  box-shadow: inset 0 -5px 12px rgba(47, 90, 34, 0.18);
}

.brand-mark-small {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 1.15rem;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(183, 227, 106, 0.12);
}

/* Authentication */

.auth-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 18%, rgba(183, 227, 106, 0.14), transparent 26%),
    var(--forest);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(390px, 0.75fr);
  width: min(1180px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  align-items: center;
  gap: 80px;
  padding: 60px 0;
}

.auth-intro {
  color: #f7f7f0;
}

.auth-intro .eyebrow {
  margin-top: 48px;
  color: var(--accent);
}

.auth-intro h1 {
  max-width: 760px;
  margin: 18px 0 26px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(3rem, 6vw, 5.8rem);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.045em;
}

.auth-description {
  max-width: 610px;
  color: #bac5c0;
  font-size: 1.05rem;
  line-height: 1.85;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 42px;
  padding: 12px 16px;
  border: 1px solid var(--forest-line);
  border-radius: 999px;
  color: #dce4e0;
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.82rem;
}

.auth-card {
  display: grid;
  gap: 28px;
  padding: 42px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 8px 0 8px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 2rem;
  font-weight: 600;
}

.muted {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: #37423e;
  font-size: 0.84rem;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid #cfcec5;
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.auth-form input:focus {
  border-color: #6f9341;
  box-shadow: 0 0 0 4px rgba(111, 147, 65, 0.13);
}

.primary-button {
  height: 52px;
  margin-top: 4px;
  border: 0;
  border-radius: 12px;
  color: #101813;
  background: var(--accent);
  font-weight: 800;
  transition: transform 150ms ease, filter 150ms ease;
}

.primary-button:hover {
  filter: brightness(0.96);
  transform: translateY(-1px);
}

.form-error {
  padding: 12px 14px;
  border: 1px solid #e7b4ae;
  border-radius: 10px;
  color: #8f2f25;
  background: #fff0ee;
  font-size: 0.86rem;
}

.auth-switch {
  margin: 0;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.88rem;
}

.auth-switch a {
  color: var(--accent-deep);
  font-weight: 800;
}

/* Application */

.app-page {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  z-index: 20;
  display: flex;
  min-width: 0;
  flex-direction: column;
  color: #f4f5ef;
  background: var(--forest);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 25px 20px 20px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.sidebar-brand strong {
  font-size: 0.95rem;
}

.sidebar-brand small {
  margin-top: 2px;
  color: #90a099;
  font-size: 0.7rem;
}

.sidebar-primary-actions {
  display: grid;
  gap: 7px;
  margin: 4px 16px 24px;
}

.new-chat-button,
.memory-button {
  display: flex;
  height: 45px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #4b5d55;
  border-radius: 12px;
  color: #f7f8f3;
  background: var(--forest-raised);
  font-size: 0.84rem;
  font-weight: 750;
}

.new-chat-button:hover,
.memory-button:hover,
.memory-button.active {
  border-color: #708078;
  background: #26372f;
}

.memory-button {
  justify-content: flex-start;
  padding: 0 13px;
  border-color: transparent;
  background: transparent;
}

.memory-button.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.memory-count-badge {
  min-width: 24px;
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: #cbd7d1;
  background: #31443b;
  font-size: 0.66rem;
  text-align: center;
}

.conversation-heading {
  display: flex;
  justify-content: space-between;
  padding: 0 20px 10px;
  color: #7f9189;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.conversation-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0 9px 20px;
}

.conversation-list::-webkit-scrollbar {
  width: 7px;
}

.conversation-list::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: #34463e;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  border-radius: 11px;
}

.conversation-row + .conversation-row {
  margin-top: 3px;
}

.conversation-row:hover,
.conversation-row.active {
  background: var(--forest-raised);
}

.conversation-row.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.conversation-select,
.conversation-delete {
  border: 0;
  color: inherit;
  background: transparent;
}

.conversation-select {
  min-width: 0;
  padding: 11px 8px 11px 12px;
  text-align: left;
}

.conversation-title,
.conversation-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title {
  font-size: 0.81rem;
  font-weight: 650;
}

.conversation-meta {
  margin-top: 4px;
  color: #7f9189;
  font-size: 0.68rem;
}

.conversation-delete {
  visibility: hidden;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: #8fa099;
}

.conversation-row:hover .conversation-delete,
.conversation-delete:focus-visible {
  visibility: visible;
}

.conversation-delete:hover {
  color: #ffd1cc;
  background: rgba(181, 66, 53, 0.22);
}

.sidebar-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 17px 16px;
  border-top: 1px solid var(--forest-line);
}

.account-settings-button {
  display: grid;
  min-width: 0;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 5px;
  border: 0;
  border-radius: 12px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.account-settings-button:hover,
.account-settings-button:focus-visible {
  outline: none;
  background: var(--forest-raised);
}

.user-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  color: var(--forest);
  background: var(--accent);
  font-weight: 850;
}

.user-info {
  min-width: 0;
}

.user-info strong,
.user-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info strong {
  font-size: 0.78rem;
}

.user-info span {
  margin-top: 2px;
  color: #809188;
  font-size: 0.66rem;
}

.logout-button {
  padding: 7px;
  border: 0;
  color: #95a69e;
  background: transparent;
  font-size: 0.72rem;
}

.logout-button:hover {
  color: #fff;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(rgba(23, 32, 29, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 29, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
}

.workspace-header {
  display: flex;
  min-height: 82px;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  padding: 14px clamp(22px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 243, 236, 0.92);
  backdrop-filter: blur(12px);
}

.workspace-kicker {
  margin: 0 0 3px;
  color: #748079;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.workspace-header h1 {
  max-width: 56vw;
  margin: 0;
  overflow: hidden;
  font-size: 1.08rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid #d4d7ca;
  border-radius: 999px;
  color: #4f5c56;
  background: rgba(255, 255, 255, 0.66);
  font-size: 0.72rem;
  font-weight: 700;
}

.messages {
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.messages[hidden],
.composer-area[hidden],
.memory-workspace[hidden] {
  display: none;
}

.memory-workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-row: 2;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  background: rgba(250, 249, 244, 0.76);
}

.memory-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(22px, 4vw, 54px) 22px;
}

.memory-intro h2 {
  margin: 6px 0 5px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 550;
}

.memory-intro p:last-child {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.memory-total {
  display: grid;
  min-width: 112px;
  padding: 15px 17px;
  border: 1px solid #d9d8ce;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
  text-align: right;
}

.memory-total strong {
  color: var(--accent-deep);
  font-family: Georgia, serif;
  font-size: 1.7rem;
}

.memory-total span {
  color: #7a857f;
  font-size: 0.68rem;
}

.memory-toolbar {
  display: grid;
  gap: 12px;
  padding: 0 clamp(22px, 4vw, 54px) 18px;
  border-bottom: 1px solid var(--line);
}

.memory-search {
  display: flex;
  height: 43px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid #d5d4ca;
  border-radius: 12px;
  color: #7c8781;
  background: rgba(255, 255, 255, 0.82);
}

.memory-search:focus-within {
  border-color: #81a353;
  box-shadow: 0 0 0 4px rgba(111, 147, 65, 0.11);
}

.memory-search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 0.82rem;
}

.memory-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.memory-filters button {
  padding: 7px 11px;
  border: 1px solid #d8d7cd;
  border-radius: 999px;
  color: #59645f;
  background: rgba(255, 255, 255, 0.64);
  font-size: 0.72rem;
  font-weight: 700;
}

.memory-filters button:hover,
.memory-filters button.active {
  border-color: #87a95b;
  color: #24461c;
  background: #eff8df;
}

.memory-filters span {
  margin-left: 3px;
  color: #8a958f;
}

.memory-list {
  min-height: 0;
  overflow-y: auto;
  padding: 18px clamp(22px, 4vw, 54px) 42px;
}

.memory-card {
  --memory-color: #49785d;
  padding: 18px 20px;
  border: 1px solid #dfded5;
  border-left: 4px solid var(--memory-color);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 25px rgba(22, 31, 27, 0.045);
}

.memory-card + .memory-card {
  margin-top: 11px;
}

.memory-card[data-category="observation"] {
  --memory-color: #4c7e9d;
}

.memory-card[data-category="preference"] {
  --memory-color: #8a69a8;
}

.memory-card[data-category="rule"] {
  --memory-color: #c26a4b;
}

.memory-card[data-category="procedure"] {
  --memory-color: #b58a31;
}

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

.memory-category {
  padding: 4px 8px;
  border-radius: 7px;
  color: var(--memory-color);
  background: color-mix(in srgb, var(--memory-color) 10%, white);
  font-size: 0.66rem;
  font-weight: 850;
}

.memory-confidence,
.memory-updated {
  color: #89938e;
  font-size: 0.66rem;
}

.memory-content {
  margin: 13px 0 16px;
  color: #27332e;
  font-size: 0.88rem;
  line-height: 1.65;
}

.memory-source {
  min-width: 0;
  overflow: hidden;
  color: #7a8580;
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.memory-actions button {
  padding: 6px 9px;
  border: 1px solid #d8d8cf;
  border-radius: 8px;
  color: #4c5953;
  background: #fff;
  font-size: 0.68rem;
  font-weight: 750;
}

.memory-actions .memory-delete {
  border-color: transparent;
  color: var(--danger);
  background: transparent;
}

.memory-empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 30px;
  border: 1px dashed #d4d3c9;
  border-radius: 16px;
  color: #7c8781;
  background: rgba(255, 255, 255, 0.36);
  text-align: center;
}

.empty-state {
  display: grid;
  max-width: 760px;
  min-height: 100%;
  margin: 0 auto;
  place-content: center;
  justify-items: center;
  padding: 52px 28px;
  text-align: center;
}

.empty-symbol {
  display: grid;
  width: 62px;
  height: 62px;
  margin-bottom: 24px;
  place-items: center;
  border: 1px solid #cad0c3;
  border-radius: 20px;
  color: var(--accent-deep);
  background: var(--paper-raised);
  box-shadow: 0 12px 30px rgba(23, 32, 29, 0.08);
  font-size: 2rem;
}

.empty-state h2 {
  margin: 12px 0 10px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(1.8rem, 3.5vw, 2.7rem);
  font-weight: 550;
  letter-spacing: -0.03em;
}

.empty-state > p:not(.eyebrow) {
  max-width: 520px;
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.prompt-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 28px;
}

.prompt-suggestions button {
  padding: 10px 14px;
  border: 1px solid #d4d3ca;
  border-radius: 999px;
  color: #4c5853;
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.78rem;
}

.prompt-suggestions button:hover {
  border-color: #91ad68;
  color: #29471f;
  background: #fbfff3;
}

.message-list {
  width: min(830px, calc(100% - 44px));
  margin: 0 auto;
  padding: 36px 0 20px;
}

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

.message + .message {
  margin-top: 26px;
}

.message-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #d2d3ca;
  border-radius: 11px;
  color: #536059;
  background: #fffef9;
  font-size: 0.72rem;
  font-weight: 850;
}

.message.assistant .message-avatar {
  border-color: #b7cc90;
  color: #223d19;
  background: #e9f6cf;
}

.message-content {
  min-width: 0;
  padding-top: 5px;
}

.message-author {
  margin: 0 0 8px;
  color: #52605a;
  font-size: 0.72rem;
  font-weight: 800;
}

.message-text {
  margin: 0;
  color: #26312d;
  font-size: 0.94rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user .message-text {
  display: inline-block;
  padding: 11px 15px;
  border: 1px solid #d7d7cd;
  border-radius: 6px 16px 16px 16px;
  background: rgba(255, 255, 255, 0.78);
}

.message-markdown {
  color: #26312d;
  font-size: 0.94rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.message-markdown > :first-child {
  margin-top: 0;
}

.message-markdown > :last-child {
  margin-bottom: 0;
}

.message-markdown h2,
.message-markdown h3,
.message-markdown h4,
.message-markdown h5,
.message-markdown h6 {
  margin: 1.35em 0 0.55em;
  color: #17231e;
  line-height: 1.35;
}

.message-markdown h2 {
  font-size: 1.28rem;
}

.message-markdown h3 {
  font-size: 1.08rem;
}

.message-markdown h4,
.message-markdown h5,
.message-markdown h6 {
  font-size: 0.98rem;
}

.message-markdown p {
  margin: 0.65em 0;
}

.message-markdown ul,
.message-markdown ol {
  margin: 0.55em 0 0.85em;
  padding-left: 1.5em;
}

.message-markdown li + li {
  margin-top: 0.32em;
}

.message-markdown strong {
  color: #17231e;
  font-weight: 760;
}

.message-markdown a {
  color: #426d27;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.message-markdown code {
  padding: 0.12em 0.35em;
  border: 1px solid #d9ddd2;
  border-radius: 5px;
  background: #f0f1eb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
}

.message-markdown pre {
  max-width: 100%;
  margin: 0.85em 0;
  overflow-x: auto;
  padding: 13px 15px;
  border: 1px solid #d2d7ca;
  border-radius: 10px;
  background: #202b27;
  color: #edf2eb;
  line-height: 1.55;
}

.message-markdown pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 0.82rem;
  white-space: pre;
}

.message-markdown blockquote {
  margin: 0.8em 0;
  padding: 0.25em 0 0.25em 1em;
  border-left: 3px solid #9abd68;
  color: #53605a;
}

.message-markdown hr {
  margin: 1.15em 0;
  border: 0;
  border-top: 1px solid #d8dbd1;
}

.markdown-table-wrap {
  max-width: 100%;
  margin: 0.85em 0;
  overflow-x: auto;
}

.message-markdown table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.52);
  font-size: 0.88rem;
}

.message-markdown th,
.message-markdown td {
  padding: 8px 10px;
  border: 1px solid #d5d8ce;
  text-align: left;
  vertical-align: top;
}

.message-markdown th {
  background: #edf1e5;
  color: #25331f;
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-top: 9px;
}

.thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #83917f;
  animation: thinking 1.1s infinite ease-in-out;
}

.thinking span:nth-child(2) {
  animation-delay: 120ms;
}

.thinking span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes thinking {
  0%,
  70%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.composer-area {
  grid-row: 3;
  padding: 15px clamp(22px, 4vw, 54px) 19px;
  border-top: 1px solid rgba(222, 219, 208, 0.8);
  background: rgba(245, 243, 236, 0.95);
}

.composer {
  display: grid;
  width: min(830px, 100%);
  min-height: 56px;
  margin: 0 auto;
  grid-template-columns: 36px minmax(0, 1fr) 42px;
  align-items: end;
  gap: 10px;
  padding: 8px;
  border: 1px solid #cbccc1;
  border-radius: 18px;
  background: var(--paper-raised);
  box-shadow: 0 10px 30px rgba(23, 32, 29, 0.08);
}

.composer:focus-within {
  border-color: #7e9f50;
  box-shadow: 0 0 0 4px rgba(126, 159, 80, 0.11), 0 10px 30px rgba(23, 32, 29, 0.08);
}

.composer.dragging {
  border-color: #6f9341;
  background: #f8fdea;
  box-shadow: 0 0 0 4px rgba(126, 159, 80, 0.16);
}

.attachment-preview {
  display: grid;
  min-width: 0;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(0, 1fr) 28px;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid #cfd9bc;
  border-radius: 10px;
  background: #f2f8e7;
  color: #34442d;
  font-size: 0.76rem;
}

.attachment-preview[hidden] {
  display: none;
}

.attachment-preview > span {
  padding: 3px 6px;
  border-radius: 5px;
  color: #eaf5d9;
  background: #425b36;
  font-size: 0.61rem;
  font-weight: 850;
}

.attachment-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview button,
.attach-button {
  border: 0;
  color: #52605a;
  background: transparent;
}

.attachment-preview button {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 1rem;
}

.attachment-preview button:hover {
  color: #7f2f27;
  background: #f4ded9;
}

.attach-button {
  display: grid;
  width: 36px;
  height: 42px;
  place-items: center;
  border-radius: 11px;
  font-size: 1.3rem;
}

.attach-button:hover,
.attach-button:focus-visible {
  outline: none;
  color: #29471f;
  background: #edf4df;
}

.attach-button:disabled {
  cursor: wait;
  opacity: 0.5;
}

.composer textarea {
  max-height: 140px;
  padding: 8px 0;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: #929890;
}

.send-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 13px;
  color: #142015;
  background: var(--accent);
  font-size: 1.25rem;
  font-weight: 900;
}

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

.composer-note {
  width: min(830px, 100%);
  margin: 8px auto 0;
  color: #7b827c;
  text-align: center;
  font-size: 0.67rem;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #d3d4ca;
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
}

.mobile-only,
.mobile-scrim {
  display: none;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 15px;
  border-radius: 12px;
  color: #fff;
  background: #25332d;
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Model settings dialog */

.settings-dialog {
  width: min(620px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: transparent;
  box-shadow: 0 30px 100px rgba(8, 15, 12, 0.36);
}

.settings-dialog::backdrop {
  background: rgba(8, 15, 12, 0.58);
  backdrop-filter: blur(5px);
}

.settings-panel {
  padding: 30px;
  background: var(--paper-raised);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.settings-header h2 {
  margin: 7px 0 8px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.settings-header p:last-child {
  max-width: 470px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.65;
}

.dialog-close {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #d8d7ce;
  border-radius: 11px;
  color: #59635e;
  background: #f8f7f1;
  font-size: 1.25rem;
}

.dialog-close:hover {
  color: var(--ink);
  background: #efeee7;
}

.model-state {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 24px 0 20px;
  padding: 11px 13px;
  border: 1px solid #dddcd2;
  border-radius: 11px;
  color: #5e6963;
  background: #f8f7f2;
  font-size: 0.78rem;
  font-weight: 700;
}

.model-state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a3aaa6;
}

.model-state.configured {
  border-color: #cbdcad;
  color: #365226;
  background: #f4fae9;
}

.model-state.configured .model-state-dot {
  background: #7eb640;
  box-shadow: 0 0 0 4px rgba(126, 182, 64, 0.13);
}

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

.settings-form > label {
  display: grid;
  gap: 8px;
  color: #37423e;
  font-size: 0.8rem;
  font-weight: 800;
}

.settings-form input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #cfcec5;
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
}

.settings-form input:focus {
  border-color: #6f9341;
  box-shadow: 0 0 0 4px rgba(111, 147, 65, 0.12);
}

.settings-form label small {
  color: #7a837e;
  font-weight: 500;
  line-height: 1.5;
}

.secret-input {
  position: relative;
  display: block;
}

.secret-input input {
  padding-right: 64px;
}

.secret-input button {
  position: absolute;
  top: 7px;
  right: 7px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: #55625b;
  background: #eff0e9;
  font-size: 0.72rem;
  font-weight: 750;
}

.settings-security-note {
  display: grid;
  gap: 4px;
  padding: 13px 15px;
  border-left: 3px solid #91b859;
  border-radius: 4px 10px 10px 4px;
  color: #53605a;
  background: #f1f4ea;
  font-size: 0.76rem;
  line-height: 1.5;
}

.settings-security-note strong {
  color: #32452a;
}

.settings-error {
  margin: 0;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.settings-actions-spacer {
  flex: 1;
}

.settings-actions button {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 11px;
  font-size: 0.8rem;
  font-weight: 800;
}

.settings-actions .settings-save {
  min-width: 112px;
  margin: 0;
}

.secondary-button {
  border: 1px solid #d1d1c8;
  color: #45514b;
  background: #f8f7f2;
}

.danger-text-button {
  border: 0;
  color: var(--danger);
  background: transparent;
}

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

@media (max-width: 860px) {
  .auth-shell {
    grid-template-columns: 1fr;
    width: min(560px, calc(100% - 34px));
    gap: 34px;
    padding: 34px 0;
  }

  .auth-intro .eyebrow {
    margin-top: 28px;
  }

  .auth-intro h1 {
    font-size: clamp(2.55rem, 11vw, 4.5rem);
  }

  .auth-description,
  .privacy-note {
    display: none;
  }

  .auth-card {
    padding: 30px;
  }

  .app-page {
    display: block;
  }

  .mobile-only {
    display: grid;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(310px, calc(100vw - 52px));
    transform: translateX(-102%);
    transition: transform 190ms ease;
  }

  body.sidebar-visible .sidebar {
    transform: translateX(0);
  }

  .sidebar .icon-button {
    border-color: var(--forest-line);
    color: #e9efec;
    background: var(--forest-raised);
  }

  .mobile-scrim {
    position: fixed;
    z-index: 15;
    inset: 0;
    background: rgba(10, 16, 13, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 190ms ease;
  }

  body.sidebar-visible .mobile-scrim {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .workspace {
    height: 100vh;
  }

  .workspace-header {
    min-height: 72px;
    padding: 10px 16px;
  }

  .workspace-header > div:nth-child(2) {
    min-width: 0;
    flex: 1;
  }

  .workspace-header h1 {
    max-width: 100%;
  }

  .online-badge {
    display: none;
  }

  .composer-area {
    padding: 11px 12px 14px;
  }

  .composer-note {
    display: none;
  }

  .message-list {
    width: calc(100% - 28px);
    padding-top: 25px;
  }

  .memory-intro,
  .memory-toolbar,
  .memory-list {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 24px 20px;
  }

  .auth-intro h1 {
    margin-bottom: 0;
  }

  .empty-state {
    padding: 34px 18px;
  }

  .memory-intro {
    align-items: flex-start;
  }

  .memory-total {
    min-width: 86px;
  }

  .memory-card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .prompt-suggestions {
    display: grid;
    width: 100%;
  }

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

  .message-avatar {
    width: 29px;
    height: 29px;
    border-radius: 9px;
    font-size: 0.64rem;
  }

  .settings-panel {
    padding: 24px 18px;
  }

  .settings-header h2 {
    font-size: 1.65rem;
  }

  .settings-actions {
    flex-wrap: wrap;
  }

  .settings-actions-spacer {
    display: none;
  }

  .settings-actions button {
    flex: 1;
  }

  .settings-actions .danger-text-button {
    flex-basis: 100%;
    order: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
