:root {
  --ink: #17212b;
  --muted: #64707d;
  --paper: #f7f3ea;
  --panel: #fffaf0;
  --line: #d9cdb9;
  --sea: #126c73;
  --sea-dark: #0c4d54;
  --coral: #d95f43;
  --sun: #f3b33d;
  --mint: #d8ece6;
  --shadow: 0 18px 50px rgba(32, 40, 48, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(18, 108, 115, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(18, 108, 115, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 42px 42px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  max-width: 100vw;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.86);
  backdrop-filter: blur(16px);
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden auto;
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: white;
  background: var(--sea);
  border-radius: 14px 14px 14px 3px;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 1.05rem;
}

.brand p,
.muted,
.eyebrow,
.panel-title small {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.new-chat,
.settings-btn,
.composer button,
.dialog-actions button:last-child {
  color: white;
  background: var(--sea);
  border-radius: 8px;
  font-weight: 750;
}

.new-chat {
  min-height: 42px;
}

.new-chat:hover,
.settings-btn:hover,
.composer button:hover,
.dialog-actions button:last-child:hover {
  background: var(--sea-dark);
}

.panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.44);
  border-radius: 8px;
}

.compact {
  padding: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 800;
}

.session-list,
.memory-list {
  display: grid;
  gap: 8px;
}

.session-row,
.memory-item {
  width: 100%;
  min-width: 0;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 250, 240, 0.68);
  border: 1px solid transparent;
  border-radius: 7px;
}

.session-row.active {
  border-color: var(--sea);
  background: var(--mint);
}

.session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  padding: 0;
  overflow: hidden;
}

.session-item {
  min-width: 0;
  padding: 10px;
  color: var(--ink);
  text-align: left;
  background: transparent;
}

.delete-session {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  font-size: 1.25rem;
  line-height: 1;
}

.delete-session:hover,
.delete-session:focus-visible {
  color: white;
  background: var(--coral);
  outline: none;
}

.session-item strong,
.memory-item strong {
  display: block;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
}

.session-item strong {
  white-space: nowrap;
}

.memory-item strong {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.session-item small,
.memory-item small {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100vh;
  padding: 22px;
  gap: 16px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}

.topbar h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 2.4vw, 2.6rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.delete-chat-btn {
  color: white;
  background: var(--coral);
  border-radius: 8px;
  font-weight: 750;
  min-height: 40px;
  padding: 0 14px;
}

.delete-chat-btn:hover {
  background: #b84931;
}

.settings-btn {
  min-width: 96px;
  min-height: 40px;
}


.profile-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  overflow: hidden;
  padding-bottom: 2px;
}

.profile-pill {
  flex: 0 0 auto;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--sea-dark);
  font-size: 0.88rem;
  font-weight: 700;
}

.chat-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
  padding: 24px;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.message-row.user-row {
  justify-content: flex-end;
}

.message-row.assistant-row {
  justify-content: flex-start;
}

.delete-msg-btn {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  margin-top: 8px;
}

.message-row:hover .delete-msg-btn,
.delete-msg-btn:focus-visible {
  opacity: 1;
}

.delete-msg-btn:hover {
  background: var(--coral);
  color: white;
}

.message {
  max-width: 860px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  color: white;
  background: var(--sea);
}

.message.assistant {
  background: white;
  border: 1px solid var(--line);
}


.trace {
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.trace summary {
  padding-top: 8px;
  color: var(--coral);
  cursor: pointer;
  font-weight: 800;
}

.trace pre {
  overflow-x: auto;
  max-height: 260px;
  padding: 10px;
  background: #162129;
  color: #eef8f4;
  border-radius: 6px;
  font-size: 0.78rem;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: white;
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 72px;
  padding: 12px;
}

input,
select {
  min-height: 40px;
  padding: 8px 10px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(18, 108, 115, 0.14);
}

.onboarding {
  width: min(720px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}

.onboarding::backdrop {
  background: rgba(23, 33, 43, 0.38);
  backdrop-filter: blur(5px);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dialog-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 750;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.dialog-actions button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
}

.ghost {
  color: var(--sea-dark);
  background: var(--mint);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 36vh) minmax(0, 1fr);
  }

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

  .workspace {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 620px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

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