:root {
  --paper: #f8f4ec;
  --paper-deep: #efe8dc;
  --ink: #342f2a;
  --muted: #857c71;
  --accent: #b85f42;
  --accent-dark: #95462f;
  --sage: #73806c;
  --line: rgba(74, 61, 48, .13);
  --shadow: 0 18px 50px rgba(75, 57, 39, .10);
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  background-image: radial-gradient(rgba(83, 65, 49, .035) 1px, transparent 1px);
  background-size: 5px 5px;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
.ambient { position: fixed; pointer-events: none; border-radius: 50%; filter: blur(5px); opacity: .5; z-index: -1; }
.ambient-one { width: 36rem; height: 36rem; background: #ead6bd; top: -20rem; right: -12rem; }
.ambient-two { width: 28rem; height: 28rem; background: #dfe4d5; top: 28rem; left: -18rem; }

.site-header {
  height: 92px;
  max-width: 1180px;
  margin: auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: #fff9ee; background: var(--accent); border-radius: 50% 50% 45% 52%; font: 600 19px var(--serif); transform: rotate(-3deg); }
.brand strong { display: block; font: 700 20px var(--serif); letter-spacing: .15em; }
.brand small { color: var(--muted); font-size: 8px; letter-spacing: .22em; }
.primary-button { border: 0; border-radius: 99px; color: #fffaf2; background: var(--accent); padding: 12px 20px; cursor: pointer; box-shadow: 0 8px 20px rgba(184, 95, 66, .2); transition: .2s ease; }
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button span { font-size: 18px; margin-right: 4px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions form { margin: 0; }
.logout-button { border: 0; background: transparent; color: var(--muted); padding: 10px 8px; cursor: pointer; font-size: 13px; }
.logout-button:hover { color: var(--accent); }

main { max-width: 1180px; margin: auto; padding: 0 28px; }
.hero { padding: 88px 0 82px; text-align: center; position: relative; }
.eyebrow, .form-eyebrow { color: var(--accent); font-size: 10px; letter-spacing: .35em; font-weight: 600; }
.hero h1 { margin: 20px 0 22px; font: 600 clamp(40px, 6vw, 68px)/1.35 var(--serif); letter-spacing: .05em; }
.hero h1 em { color: var(--accent); font-style: normal; position: relative; }
.hero h1 em::after { content: ""; position: absolute; height: 8px; left: 3%; right: -3%; bottom: 0; background: rgba(184, 95, 66, .14); border-radius: 50%; transform: rotate(-2deg); }
.hero-copy { color: var(--muted); line-height: 2; font: 400 14px/2 var(--serif); }
.hero-meta { margin-top: 34px; display: flex; justify-content: center; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.hero-meta strong { color: var(--ink); font-family: var(--serif); }
.hero-meta i { width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }

.memory-section { border-top: 1px solid var(--line); padding: 34px 0 80px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 28px; }
.search-box { width: min(360px, 100%); height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: rgba(255,255,255,.52); border: 1px solid var(--line); border-radius: 99px; }
.search-box:focus-within { border-color: rgba(184,95,66,.5); box-shadow: 0 0 0 3px rgba(184,95,66,.08); }
.search-box svg { width: 18px; fill: none; stroke: var(--muted); stroke-width: 1.6; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::placeholder { color: #a39a90; }
kbd { color: #a49b91; background: var(--paper-deep); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; font: 10px var(--sans); }
.categories { display: flex; gap: 8px; overflow-x: auto; padding: 3px; scrollbar-width: none; }
.category-chip { white-space: nowrap; border: 0; background: transparent; color: var(--muted); border-radius: 99px; padding: 9px 14px; cursor: pointer; font-size: 13px; }
.category-chip:hover, .category-chip.active { color: #fffaf3; background: var(--sage); }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin: 52px 0 24px; }
.section-heading > div { display: flex; align-items: center; gap: 12px; }
.heading-line { width: 24px; height: 1px; background: var(--accent); }
.section-heading h2 { margin: 0; font: 600 21px var(--serif); letter-spacing: .08em; }
.section-heading > span { color: var(--muted); font-size: 12px; }

.memory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.memory-card { min-height: 260px; padding: 25px 25px 20px; display: flex; flex-direction: column; background: rgba(255,255,255,.58); border: 1px solid var(--line); border-radius: 4px 18px 4px 4px; box-shadow: 0 5px 18px rgba(63,46,31,.03); transition: .25s ease; animation: cardIn .4s both; }
.memory-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: rgba(184,95,66,.22); }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.card-date { color: var(--accent); font: 500 11px var(--serif); letter-spacing: .08em; }
.card-category { color: var(--sage); background: rgba(115,128,108,.1); border-radius: 99px; padding: 5px 9px; font-size: 10px; }
.memory-card h3 { margin: 23px 0 12px; font: 600 19px/1.5 var(--serif); }
.card-content { margin: 0; color: #776e64; font: 400 13px/1.85 var(--serif); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.card-actions { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 6px; opacity: 0; transition: .2s; }
.memory-card:hover .card-actions, .memory-card:focus-within .card-actions { opacity: 1; }
.icon-button { border: 0; background: transparent; color: var(--muted); padding: 5px 8px; cursor: pointer; font-size: 12px; }
.icon-button:hover { color: var(--accent); }
.delete-button:hover { color: #a33e38; }
.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-illustration { margin: auto; width: 74px; height: 74px; display: grid; place-items: center; color: var(--accent); background: rgba(184,95,66,.08); border-radius: 50%; font-size: 25px; }
.empty-state h3 { color: var(--ink); margin: 22px 0 8px; font: 600 20px var(--serif); }
.empty-state p { font-size: 13px; }
.text-button { border: 0; background: transparent; color: var(--accent); cursor: pointer; margin-top: 8px; }
footer { max-width: 1124px; margin: auto; border-top: 1px solid var(--line); padding: 28px; text-align: center; color: #a2998e; font: 11px var(--serif); letter-spacing: .12em; }
footer span { color: var(--accent); margin: 0 10px; font-size: 8px; }

dialog { width: min(590px, calc(100% - 28px)); max-height: calc(100vh - 28px); border: 0; border-radius: 8px 28px 8px 8px; padding: 0; color: var(--ink); background: #fbf8f2; box-shadow: 0 30px 90px rgba(48,38,29,.3); }
dialog::backdrop { background: rgba(48,42,36,.46); backdrop-filter: blur(4px); }
dialog[open] { animation: dialogIn .25s ease; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
#memoryForm { position: relative; padding: 42px; }
.close-button { position: absolute; top: 20px; right: 23px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--paper-deep); color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
#memoryForm h2 { margin: 8px 0; font: 600 30px var(--serif); }
.form-intro { color: var(--muted); font: 13px var(--serif); margin-bottom: 28px; }
#memoryForm label { display: block; margin-top: 17px; color: #685f56; font-size: 12px; font-weight: 600; }
#memoryForm input, #memoryForm textarea { display: block; width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; outline: 0; padding: 12px 13px; color: var(--ink); background: #fffdfa; resize: vertical; }
#memoryForm input:focus, #memoryForm textarea:focus { border-color: rgba(184,95,66,.55); box-shadow: 0 0 0 3px rgba(184,95,66,.07); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-error { min-height: 18px; margin: 10px 0 0; color: #a33e38; font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.secondary-button { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 11px 18px; cursor: pointer; }
.secondary-button:hover { background: var(--paper-deep); }
.save-button { padding-inline: 24px; }
.toast { position: fixed; left: 50%; bottom: 30px; z-index: 10; transform: translate(-50%, 20px); padding: 11px 20px; color: #fff; background: #4e5749; border-radius: 99px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .memory-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .categories { margin-left: -3px; }
}
@media (max-width: 560px) {
  .site-header { height: 76px; padding: 0 18px; }
  .brand small { display: none; }
  .site-header .primary-button { padding: 10px 14px; font-size: 13px; }
  main { padding: 0 18px; }
  .hero { padding: 66px 0 58px; }
  .hero h1 { font-size: 38px; }
  .hero-copy br { display: none; }
  .memory-grid { grid-template-columns: 1fr; }
  .memory-card { min-height: 230px; }
  .card-actions { opacity: 1; }
  #memoryForm { padding: 36px 22px 24px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions button { width: 100%; }
  kbd { display: none; }
}
