
:root {
  --page-bg: #f7f3ec;
  --topbar-bg: #f7f3ec;
  --hero-bg: #fffdf8;
  --room-card-bg: #fffdf8;
  --memory-card-bg: #fffdf8;
  --settings-card-bg: #fffdf8;
  --nav-bg: #f7f3ec;
  --accent: #4b3428;
  --text-main: #2d2824;

  --ivory: var(--page-bg);
  --paper: #fffdf8;
  --stone: #d9cdbd;
  --stone-deep: #b9aa96;
  --walnut: var(--accent);
  --walnut-soft: color-mix(in srgb, var(--accent) 82%, white);
  --ink: var(--text-main);
  --muted: color-mix(in srgb, var(--text-main) 62%, white);
  --sage: #697566;
  --rose: #a36f72;
  --line: color-mix(in srgb, var(--accent) 16%, transparent);
  --shadow: 0 12px 35px rgba(61, 47, 37, 0.09);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page-bg);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--page-bg); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255,255,255,.28), rgba(255,255,255,.28)),
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(75,52,40,.025) 39px 40px),
    var(--page-bg);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  background: color-mix(in srgb, var(--page-bg) 82%, white 18%);
  border-left: 1px solid rgba(75,52,40,.08);
  border-right: 1px solid rgba(75,52,40,.08);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--topbar-bg) 94%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

.brand-mark, .empty-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  color: #fffdf8;
  border: 1px solid rgba(255,255,255,.5);
  outline: 1px solid var(--accent);
  outline-offset: 2px;
  border-radius: 50%;
  background: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  letter-spacing: .08em;
}

.brand strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 17px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .03em; }

.icon-button, .close-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  background: #fffdf8;
  font-size: 24px;
}

main { padding: 24px 18px 122px; }
.view { display: none; }
.view.active { display: block; animation: enter .2s ease; }

@keyframes enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 31px 25px 28px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background:
    radial-gradient(circle at 85% 10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 30%),
    linear-gradient(135deg, color-mix(in srgb, var(--hero-bg) 94%, white), color-mix(in srgb, var(--hero-bg) 82%, var(--stone)));
  box-shadow: var(--shadow);
}

.hero::before, .hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 20px;
}
.hero::before { inset: 9px; }
.hero::after { inset: 14px; border-radius: 16px; }

.hero > * { position: relative; z-index: 1; }
.eyebrow {
  margin: 0 0 8px;
  color: color-mix(in srgb, var(--accent) 82%, white);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2 {
  margin: 0;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
}

h1 { font-size: clamp(30px, 8vw, 48px); line-height: 1.04; }
h2 { font-size: 22px; }

.hero-copy {
  max-width: 660px;
  margin: 16px 0 0;
  color: color-mix(in srgb, var(--text-main) 82%, white);
  font-size: 16px;
  line-height: 1.65;
}

.hero-actions, .dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.primary, .secondary, .danger, .file-button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 750;
}

.primary {
  border: 1px solid var(--accent);
  color: #fffdf8;
  background: var(--accent);
  box-shadow: 0 7px 18px color-mix(in srgb, var(--accent) 18%, transparent);
}

.secondary, .file-button {
  border: 1px solid var(--line);
  color: var(--accent);
  background: #fffdf8;
}

.danger {
  border: 1px solid rgba(141,58,58,.25);
  color: #8d3a3a;
  background: #fff7f5;
}

.compact { min-height: 40px; padding: 8px 14px; }

.section-heading, .page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 3px 16px;
}

.page-heading { margin-top: 4px; align-items: center; }
.quiet-pill {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.55);
  font-size: 12px;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.room-card {
  display: flex;
  min-height: 104px;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-align: left;
  background: color-mix(in srgb, var(--room-card-bg) 94%, transparent);
  box-shadow: 0 7px 22px rgba(61,47,37,.055);
}

.room-card:not(:disabled):hover { transform: translateY(-1px); }
.room-card strong, .room-card small { display: block; }
.room-card strong { color: var(--accent); font-family: Georgia, "Times New Roman", serif; font-size: 17px; }
.room-card small { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.room-card.planned { opacity: .62; }
.room-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--accent);
  background: color-mix(in srgb, var(--room-card-bg) 72%, var(--stone));
  font-size: 20px;
}

.today-panel {
  margin-top: 18px;
  padding: 22px;
  border-left: 4px solid var(--sage);
  border-radius: 4px 18px 18px 4px;
  background: rgba(105,117,102,.09);
}
.today-panel p:last-child { margin-bottom: 0; color: #5f655c; line-height: 1.55; }

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 20px;
}

.search-box {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf8;
}

.search-box.large { margin-top: 22px; }
.search-box span { color: var(--muted); font-size: 22px; }
.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--ink);
  background: #fffdf8;
}
select, input { min-height: 46px; padding: 10px 12px; }
textarea { resize: vertical; padding: 12px; line-height: 1.5; }
select:focus, input:focus, textarea:focus { border-color: var(--stone-deep); box-shadow: 0 0 0 3px rgba(185,170,150,.18); }

.tag-filters {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 13px 1px 7px;
  scrollbar-width: none;
}
.tag-filters::-webkit-scrollbar { display: none; }
.tag-chip, .memory-tag {
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: color-mix(in srgb, var(--accent) 82%, white);
  background: rgba(255,253,248,.8);
  font-size: 12px;
}
.tag-chip { padding: 7px 11px; }
.tag-chip.selected { color: #fffdf8; background: var(--accent); }
.memory-tag { padding: 4px 8px; }

.memory-list { display: grid; gap: 12px; margin-top: 12px; }
.memory-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--memory-card-bg) 94%, transparent);
  box-shadow: 0 7px 24px rgba(61,47,37,.05);
  transition: transform .14s ease, box-shadow .14s ease;
}
.memory-card:hover, .memory-card:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(61,47,37,.08);
  outline: none;
}
.memory-card-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.memory-meta { color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.memory-title { margin-top: 5px; font-size: 21px; }
.memory-body {
  display: -webkit-box;
  overflow: hidden;
  margin: 13px 0 0;
  color: color-mix(in srgb, var(--text-main) 80%, white);
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.memory-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.open-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: #fffdf8;
  font-size: 12px;
  font-weight: 750;
}

.empty-state {
  margin-top: 30px;
  padding: 40px 20px;
  text-align: center;
}
.empty-state .empty-mark { margin: 0 auto 18px; }
.empty-state p { color: var(--muted); }

.settings-card {
  margin-top: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--settings-card-bg) 94%, transparent);
}
.settings-card p { color: var(--muted); line-height: 1.55; }
.settings-card.caution { border-left: 4px solid var(--rose); }
.file-button { display: inline-flex; align-items: center; cursor: pointer; }
.file-button input { display: none; }
.status-line { min-height: 1.4em; font-size: 13px; }

.bottom-nav {
  position: fixed;
  z-index: 25;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 980px);
  min-height: 76px;
  margin: 0 auto;
  padding: 8px 7px max(9px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--nav-bg) 96%, transparent);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
}
.nav-item span { font-size: 20px; }
.nav-item small { font-size: 9px; }
.nav-item.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

dialog {
  width: min(calc(100% - 24px), 680px);
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--ink);
  background: var(--page-bg);
  box-shadow: 0 24px 90px rgba(40,30,23,.28);
}
dialog::backdrop { background: rgba(32,27,23,.48); backdrop-filter: blur(4px); }
dialog form, .memory-reader { display: grid; gap: 15px; padding: 22px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
dialog label { display: grid; gap: 7px; color: var(--accent); font-size: 13px; font-weight: 750; }
.field-help { color: var(--muted); font-weight: 400; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action-spacer { flex: 1; }

.reader-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.reader-body {
  min-height: 160px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--memory-card-bg) 94%, white);
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.72;
}
.reader-actions { margin-top: 2px; }

.decor-form { display: grid; gap: 2px; }
.decor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-top: 16px;
}
.decor-grid label { display: grid; gap: 7px; color: var(--accent); font-size: 13px; font-weight: 750; }
.full-width { grid-column: 1 / -1; }
.colour-grid label {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.45);
}
input[type="color"] {
  width: 54px;
  height: 38px;
  min-height: 38px;
  padding: 2px;
  border-radius: 10px;
  cursor: pointer;
}
.sticky-save {
  position: sticky;
  bottom: 82px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--page-bg) 94%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.sticky-save .status-line { margin: 0; }

@media (min-width: 760px) {
  main { padding-inline: 32px; }
  .room-grid { grid-template-columns: repeat(3, 1fr); }
  .memory-list { grid-template-columns: repeat(2, 1fr); }
  .search-results { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .room-grid { grid-template-columns: 1fr; }
  .hero-actions > * { flex: 1 1 auto; }
  .toolbar { grid-template-columns: 1fr; }
  .two-column, .decor-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .dialog-actions { align-items: stretch; }
  .dialog-actions button { flex: 1 1 auto; }
  .action-spacer { display: none; }
  .sticky-save { align-items: stretch; flex-direction: column; }
  .sticky-save button { width: 100%; }
}
