:root {
  --bg: #f5efe4;
  --bg-elevated: rgba(255, 250, 240, 0.84);
  --panel: rgba(255, 248, 238, 0.9);
  --panel-strong: rgba(255, 252, 247, 0.96);
  --line: rgba(94, 66, 44, 0.12);
  --text: #281d16;
  --muted: #70594a;
  --accent: #bf5b2c;
  --accent-dark: #8f3f19;
  --assistant: #f0dfcf;
  --user: #dceae3;
  --shadow: 0 20px 45px rgba(67, 35, 18, 0.12);
}

html {
  font-size: 16px;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(233, 168, 121, 0.32), transparent 28%),
    radial-gradient(circle at right 15%, rgba(142, 188, 169, 0.22), transparent 24%),
    linear-gradient(180deg, #f9f4ec 0%, var(--bg) 100%);
  font-family: Georgia, Cambria, "Times New Roman", serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(249, 244, 236, 0.82);
  border-bottom: 1px solid var(--line);
}

.topbar__inner,
.page-frame {
  width: min(1200px, calc(100vw - 2rem));
  margin: 0 auto;
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 74px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
}

.brand span {
  display: grid;
}

.brand small,
.muted,
.lede {
  color: var(--muted);
}

.brand__mark {
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  place-items: center;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #2d1f18, #8f3f19);
  color: #fff7ef;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.topbar__nav,
.topbar__actions,
.composer__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-pill,
.user-chip,
.button {
  border-radius: 999px;
}

.nav-pill,
.user-chip {
  padding: 0.55rem 0.95rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.page-frame {
  padding: 2rem 0 2.5rem;
}

.auth-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(560px, 100%);
  margin: 4rem auto;
  padding: 2.5rem;
  border-radius: 1.75rem;
}

.eyebrow {
  margin-bottom: 0.8rem;
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
}

.stack-lg,
.stack-sm {
  display: grid;
}

.stack-lg {
  gap: 1rem;
}

.stack-sm {
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field span:first-child {
  font-size: 0.95rem;
  font-weight: 600;
}

.form-control {
  border-radius: 1rem;
  border: 1px solid rgba(107, 82, 66, 0.16);
  background: rgba(255, 252, 248, 0.95);
  padding: 0.85rem 1rem;
}

.form-control:focus {
  border-color: rgba(191, 91, 44, 0.42);
  box-shadow: 0 0 0 0.25rem rgba(191, 91, 44, 0.12);
}

.button {
  border: 1px solid transparent;
  padding: 0.8rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff7ef;
}

.button--ghost {
  background: rgba(255, 255, 255, 0.45);
  border-color: var(--line);
}

.button--block {
  width: 100%;
  display: inline-flex;
  justify-content: center;
}

.alert-panel,
.validation-summary {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(191, 91, 44, 0.18);
  background: rgba(255, 244, 236, 0.92);
}

.validation-summary ul {
  margin: 0;
  padding-left: 1.25rem;
}

.chat-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.25rem;
}

.panel {
  border-radius: 1.5rem;
  overflow: hidden;
}

.panel--padded {
  padding: 1.5rem;
}

.panel__header,
.panel__section,
.chat-transcript,
.composer,
.session-audit-list {
  padding: 1.25rem;
}

.panel__header {
  border-bottom: 1px solid var(--line);
}

.panel__header--spaced {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.session-list {
  display: grid;
  gap: 0.75rem;
  padding: 0 1.25rem 1.25rem;
}

.session-card {
  width: 100%;
  display: grid;
  gap: 0.2rem;
  padding: 0.95rem 1rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.42);
  text-align: left;
}

.session-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.session-card--active {
  border-color: rgba(191, 91, 44, 0.28);
  background: var(--panel-strong);
}

.chat-panel {
  min-height: 70vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-layout--enhanced .chat-sidebar {
  max-height: calc(100vh - 7rem);
  overflow: auto;
}

.chat-status-line {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.chat-transcript {
  display: grid;
  gap: 1rem;
  align-content: start;
  overflow: auto;
}

.message {
  max-width: 82%;
  padding: 1rem 1.1rem;
  border-radius: 1.35rem;
  border: 1px solid var(--line);
}

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

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

.message__meta {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.message__body {
  line-height: 1.55;
}

.message__parts {
  display: grid;
  gap: 0.85rem;
}

.part {
  line-height: 1.6;
}

.part--text,
.part--reasoning > div {
  white-space: pre-wrap;
}

.part--reasoning {
  padding: 0.8rem 0.9rem;
  border: 1px dashed rgba(112, 89, 74, 0.32);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.32);
}

.part--tool {
  padding: 0.9rem 1rem;
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(112, 89, 74, 0.18);
}

.part--tool pre {
  margin: 0.75rem 0 0;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(112, 89, 74, 0.18);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-chip--busy,
.status-chip--tool-running,
.status-chip--tool-pending {
  color: #95511e;
  background: rgba(255, 230, 204, 0.84);
}

.status-chip--idle,
.status-chip--tool-completed {
  color: #2f6f53;
  background: rgba(220, 234, 227, 0.9);
}

.status-chip--retry,
.status-chip--tool-error {
  color: #8a2730;
  background: rgba(250, 220, 220, 0.9);
}

.composer {
  border-top: 1px solid var(--line);
}

.composer__input {
  resize: vertical;
  min-height: 8rem;
}

.empty-state {
  margin: auto;
  max-width: 30rem;
  padding: 2rem;
  text-align: center;
}

.sessions-panel {
  padding-bottom: 0.5rem;
}

.session-audit-list {
  display: grid;
  gap: 0.9rem;
}

.audit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel-strong);
}

.audit-card__meta,
.audit-card__details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.audit-card__details {
  color: var(--muted);
  font-size: 0.92rem;
}

.badge-current {
  color: var(--accent-dark);
  font-weight: 700;
}

.code-input {
  letter-spacing: 0.28em;
  font-size: 1.4rem;
  text-align: center;
}

.notes-body {
  background: #ffffff;
  color: #111111;
  font-family: "Times New Roman", Georgia, serif;
}

.notes-app {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.notes-toolbar-zone {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0.75rem 0;
}

.notes-toolbar-hover {
  position: relative;
  opacity: 0;
  transition: opacity 140ms ease;
}

.notes-toolbar-zone:hover .notes-toolbar-hover,
.notes-toolbar-hover:focus-within {
  opacity: 1;
}

.notes-cog,
.notes-plain-button,
.notes-showbar,
.notes-menu__button {
  border: 0;
  background: transparent;
  color: #222222;
}

.notes-cog {
  font-size: 1rem;
  padding: 0.25rem 0.4rem;
}

.notes-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: #ffffff;
  border: 1px solid #dddddd;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.notes-menu__button {
  display: block;
  padding: 0.5rem 0.8rem;
}

.notes-menu form {
  margin: 0;
}

.notes-sheet {
  padding: 0.5rem 0.85rem 5rem;
}

.notes-entry {
  width: 100%;
  min-height: calc(100vh - 8rem);
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: #111111;
  font-size: 0.94rem;
  line-height: 1.55;
}

.notes-statusbar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  border-top: 1px solid #e6e6e6;
  background: rgba(255, 255, 255, 0.96);
  font-size: 0.92rem;
}

.notes-statusbar__left,
.notes-statusbar__right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.notes-status {
  color: #7a7a7a;
}

.notes-status--model {
  color: #7a7a7a;
}

.notes-statusbar,
.notes-statusbar label,
.notes-plain-button,
.notes-select {
  color: #7a7a7a;
}

.settings-layout {
  display: grid;
  gap: 1rem;
}

.settings-current-row,
.provider-card__header,
.provider-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.provider-card {
  display: grid;
  gap: 1rem;
}

.provider-form {
  max-width: 34rem;
}

.oauth-note {
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  border: 1px dashed rgba(112, 89, 74, 0.28);
  background: rgba(255, 255, 255, 0.4);
}

.oauth-note p {
  margin: 0.35rem 0 0;
}

.oauth-dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

.oauth-dialog::backdrop {
  background: rgba(34, 24, 18, 0.36);
}

.oauth-dialog__card {
  width: min(40rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border-radius: 1.2rem;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.oauth-dialog__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.notes-select {
  border: 0;
  border-bottom: 1px solid #cccccc;
  background: transparent;
  padding: 0.1rem 0.2rem;
}

.notes-showbar-zone {
  position: fixed;
  right: 0.75rem;
  bottom: 0.75rem;
  width: 1.5rem;
  height: 1.5rem;
}

.notes-showbar {
  border: 0;
  background: transparent;
  color: transparent;
  padding: 0.15rem 0.35rem;
  transition: color 140ms ease;
}

.notes-showbar-zone:hover .notes-showbar,
.notes-showbar-zone:focus-within .notes-showbar {
  color: #7a7a7a;
}

.login-minimal {
  min-height: 100vh;
  background: #ffffff;
  color: #000000;
  font-family: Consolas, "Lucida Console", monospace;
}

.login-minimal__form {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.35rem;
  margin: 0.35rem;
  flex-wrap: wrap;
}

.login-minimal__input,
.login-minimal__submit {
  border: 0;
  background: transparent;
  color: #000000;
  font: inherit;
}

.login-minimal__input {
  min-width: 18rem;
  padding: 0.1rem 0;
  outline: none;
}

.login-minimal__submit {
  padding: 0.1rem 0.25rem;
  cursor: pointer;
}

.login-minimal__back {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.25rem;
  color: #000000;
}

.login-minimal__input--code {
  min-width: 8rem;
}

.login-minimal__messages {
  width: 100%;
  font-size: 0.82rem;
  color: #444444;
}

.login-minimal__messages ul {
  margin: 0;
  padding-left: 1rem;
}

.login-minimal__turnstile {
  width: 100%;
}

@media (max-width: 992px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .topbar__inner,
  .topbar__nav,
  .topbar__actions,
  .panel__header--spaced,
  .composer__actions,
  .audit-card,
  .notes-statusbar,
  .notes-statusbar__left,
  .notes-statusbar__right {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar__inner {
    padding: 1rem 0;
  }

  .auth-card,
  .panel {
    border-radius: 1.2rem;
  }

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