:root {
  color-scheme: light;
  --page: #f7f3f6;
  --page-2: #eef6f2;
  --ink: #24181e;
  --muted: #735f68;
  --soft: #8b7b82;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --line: rgba(64, 43, 53, 0.16);
  --line-strong: rgba(64, 43, 53, 0.24);
  --rose: #db8aa1;
  --sage: #75a084;
  --blue: #7b9bb8;
  --butter: #f3d36b;
  --plum: #775167;
  --brown: #47251f;
  --shadow: 0 18px 60px rgba(57, 40, 49, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(135deg, var(--page) 0%, var(--page-2) 54%, #f4f7fb 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

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

img {
  display: block;
  max-width: 100%;
}

noscript {
  display: block;
  padding: 20px;
}

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

.app-surface {
  min-height: 100vh;
  transition: filter 220ms ease, transform 220ms ease;
}

.memory-app.is-locked .app-surface {
  filter: blur(14px) saturate(0.82) brightness(0.86);
  pointer-events: none;
  transform: scale(1.01);
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100% - 24px, 1480px);
  margin: 0 auto;
  padding: 18px 0 12px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(42px, 5vw, 68px);
  line-height: 0.92;
  font-weight: 920;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 740;
}

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

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(57, 40, 49, 0.1);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.78fr);
  gap: 14px;
  width: min(100% - 24px, 1480px);
  margin: 0 auto;
  align-items: stretch;
}

.chat-panel,
.ingest-panel,
.memory-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-panel,
.ingest-panel {
  min-height: 520px;
  padding: 16px;
}

.panel-head,
.wall-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-head h2,
.wall-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.panel-head p,
.wall-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.suggestions button {
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.messages {
  height: 326px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.message {
  width: fit-content;
  max-width: min(760px, 94%);
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid rgba(64, 43, 53, 0.08);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.message.user {
  margin-left: auto;
  border-color: rgba(219, 138, 161, 0.24);
  background: #fff6f8;
}

.message.assistant {
  background: #ffffff;
}

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

.message-warning {
  display: block;
  margin-top: 8px;
  color: var(--plum);
  font-size: 12px;
  font-weight: 760;
}

.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.sources span {
  max-width: 230px;
  overflow: hidden;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fbf9fb;
  font-size: 11px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 8px;
  margin-top: 10px;
}

.chat-form textarea,
.memory-field {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  resize: vertical;
}

.chat-form textarea {
  min-height: 58px;
  max-height: 130px;
}

.memory-field {
  min-height: 226px;
  margin-top: 10px;
  line-height: 1.42;
}

.drop-zone {
  display: grid;
  min-height: 126px;
  place-items: center;
  padding: 18px;
  border: 1px dashed rgba(64, 43, 53, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  text-align: center;
}

.drop-zone.is-dragging {
  border-color: var(--sage);
  background: rgba(117, 160, 132, 0.13);
}

.drop-zone strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
  font-weight: 860;
}

.drop-zone span span {
  display: block;
  max-width: 38ch;
  margin-top: 5px;
  font-size: 13px;
  font-weight: 650;
}

.file-input {
  display: none;
}

.file-count {
  min-height: 19px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

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

.primary-button,
.secondary-button,
.pin-submit {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 840;
}

.primary-button,
.pin-submit {
  background: var(--brown);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.memory-section {
  width: min(100% - 24px, 1480px);
  margin: 14px auto 0;
  padding: 16px;
}

.memory-wall {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.memory-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(57, 40, 49, 0.08);
}

.memory-card.photo {
  grid-column: span 3;
  aspect-ratio: 4 / 5.2;
}

.memory-card.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-caption {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  min-height: 38%;
  display: flex;
  align-items: flex-end;
  padding: 38px 12px 12px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.68));
}

.photo-caption span {
  display: block;
  color: #fff;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.25;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.72);
}

.info-card {
  grid-column: span 4;
  min-height: 0;
  padding: 14px;
  color: var(--ink);
  background: #fff;
}

.info-card.long {
  grid-column: span 6;
}

.info-card.quote {
  background: #ffffff;
}

.info-card.date {
  background: #fff8dc;
}

.info-card.contact {
  background: #eff8f2;
}

.info-card.address {
  background: #eef5fb;
}

.info-card.note {
  background: #fff4f6;
}

.type-label {
  display: inline-block;
  margin-bottom: 10px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.info-text {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 640;
  white-space: pre-wrap;
}

.info-card:not(.long) .info-text {
  font-size: 16px;
  font-weight: 700;
}

.meta-row {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.delete-button {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(64, 43, 53, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
  opacity: 0;
}

.memory-card:hover .delete-button,
.memory-card:focus-within .delete-button {
  opacity: 1;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.46);
  text-align: center;
  font-weight: 720;
}

.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(36, 24, 30, 0.18);
}

.memory-app.is-locked .pin-overlay {
  display: grid;
}

.pin-window {
  width: min(100%, 402px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 30px 90px rgba(57, 40, 49, 0.22);
}

.pin-window.is-wrong {
  animation: shake 180ms ease-in-out 2;
}

.pin-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  overflow: hidden;
  border-radius: 16px;
}

.pin-icon img {
  width: 100%;
  height: 100%;
}

.pin-window h2 {
  margin: 0;
  font-size: 34px;
  line-height: 0.95;
  font-weight: 920;
}

.pin-window p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 670;
}

.pin-label {
  display: block;
  margin: 20px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 860;
}

.pin-input {
  width: 160px;
  height: 58px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 32px;
  font-weight: 880;
  letter-spacing: 10px;
  text-align: center;
  text-indent: 10px;
}

.pin-submit {
  display: block;
  width: 100%;
  margin-top: 16px;
}

.remember-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.remember-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--plum);
}

.pin-error {
  min-height: 18px;
  color: #a53e4e;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 60;
  max-width: min(420px, calc(100% - 24px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  box-shadow: 0 18px 44px rgba(57, 40, 49, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(5px);
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .memory-card.photo {
    grid-column: span 4;
  }

  .info-card,
  .info-card.long {
    grid-column: span 6;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    width: calc(100% - 14px);
    padding-top: 12px;
  }

  .brand h1 {
    font-size: 44px;
  }

  .workspace,
  .memory-section {
    width: calc(100% - 12px);
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .messages {
    height: 300px;
  }

  .memory-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .memory-card.photo,
  .info-card,
  .info-card.long {
    grid-column: span 2;
  }

  .delete-button {
    opacity: 1;
  }

  .composer-actions {
    justify-content: stretch;
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-surface,
  .toast {
    transition: none;
  }
}
