:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #5e6b64;
  --paper: #f4f1e9;
  --surface: #fffdf7;
  --line: #d8d3c7;
  --accent: #176b54;
  --accent-dark: #0f4d3d;
  --danger: #8f2d2d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a {
  color: var(--accent-dark);
}

.site-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 1rem max(1.25rem, calc((100vw - 70rem) / 2));
}

.brand {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 750;
  text-decoration: none;
}

nav {
  align-items: center;
  display: flex;
  gap: 1rem;
}

nav form {
  margin: 0;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.page-shell {
  margin: 0 auto;
  max-width: 70rem;
  padding: 3rem 1.25rem 5rem;
}

.page-heading {
  max-width: 48rem;
  margin-bottom: 2rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

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

.panel,
.memory-card,
.empty-state,
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 1.4rem;
}

.panel,
.notice {
  margin-bottom: 1.5rem;
}

.stacked-form,
.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stacked-form {
  gap: 1rem;
}

label {
  font-weight: 700;
}

textarea,
select,
input[type="date"],
input[type="search"],
input[type="text"],
input[type="password"],
input[type="number"] {
  background: white;
  border: 1px solid #a9b0aa;
  border-radius: 0.4rem;
  color: var(--ink);
  font: inherit;
  padding: 0.75rem;
  width: 100%;
}

textarea:focus,
input[type="search"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid #84c7b4;
  outline-offset: 2px;
}

.action-row,
.split-actions,
.briefing-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.action-row {
  margin-bottom: 1.5rem;
}

.briefing-card {
  border-left: 0.35rem solid var(--accent);
}

.memory-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: 0.75rem;
}

.errorlist {
  color: var(--danger);
}

.primary-button {
  align-self: flex-start;
  background: var(--accent);
  border: 0;
  border-radius: 0.4rem;
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 0.7rem 1rem;
}

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

.auth-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 1rem max(1.25rem, calc((100vw - 34rem) / 2));
}

.auth-shell {
  margin: 0 auto;
  max-width: 34rem;
  padding: 3rem 1.25rem;
}

.auth-shell .container,
.auth-shell .row,
.auth-shell .col-md-5 {
  width: 100%;
}

.auth-shell form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  display: grid;
  gap: 1rem;
  padding: 1.4rem;
}

.auth-shell button,
.auth-shell input[type="submit"],
.btn {
  background: var(--accent);
  border: 0;
  border-radius: 0.4rem;
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 0.7rem 1rem;
}

.auth-shell img {
  height: auto;
  max-width: 100%;
}

.notice-error {
  border-color: var(--danger);
}

.answer-text,
.memory-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.approval-preview {
  unicode-bidi: plaintext;
}

.reference-list {
  display: grid;
  gap: 0.75rem;
  padding-left: 1.2rem;
}

.reference-list code {
  display: block;
  margin-top: 0.2rem;
}

.search-form {
  align-items: flex-end;
  display: flex;
  gap: 1rem;
}

.grow {
  flex: 1;
}

.memory-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
}

.memory-meta {
  color: var(--muted);
  display: flex;
  font-size: 0.82rem;
  gap: 0.75rem;
  justify-content: space-between;
}

code {
  overflow-wrap: anywhere;
}

.metadata-list {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.metadata-list div {
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.metadata-list dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metadata-list dd {
  margin: 0.25rem 0 0;
}

.errorlist {
  color: var(--danger);
  margin: 0;
}

@media (max-width: 38rem) {
  .site-header,
  .search-form {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    justify-content: space-between;
  }
}
