:root {
  --bg: #F5F0E8;
  --bg-alt: #EDE6D6;
  --card: #FFFFFF;
  --card-hover: #F7F1E4;
  --border: rgba(28,43,74,0.12);
  --border-strong: rgba(28,43,74,0.2);
  --accent: #B8922A;
  --accent-light: #D4AC4A;
  --accent-pale: #8a6d1f;
  --ink: #2A2A2A;
  --muted: #6B6456;
  --on-accent: #16213B;
  --danger: #9b2323;
  --ok: #2f6b3a;
}
html[data-theme="dark"] {
  --bg: #0A0E1A;
  --bg-alt: #0D1322;
  --card: #141B2E;
  --card-hover: #1B2440;
  --border: rgba(255,255,255,0.12);
  --border-strong: rgba(255,255,255,0.2);
  --accent: #D4AC4A;
  --accent-light: #E8C878;
  --accent-pale: #F0DFA0;
  --ink: #F5F7FA;
  --muted: #94A0B8;
  --danger: #e06a6a;
  --ok: #5fcf78;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 400; line-height: 1.6;
  transition: background .2s, color .2s;
}
@media (prefers-reduced-motion: no-preference) {
  @keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
  .bar { animation: fadeInUp .45s ease both; }
  .wrap > .page-head, .wrap > .panel, .wrap > .section, .wrap > h1, .wrap > p.lede,
  .login > h1, .login > p.lede, .login > p.home {
    animation: fadeInUp .45s ease both;
  }
  .login > h1 { animation-delay: 0s; }
  .login > p.lede { animation-delay: .05s; }
  .login > .panel { animation-delay: .1s; }
  .login > p.home { animation-delay: .2s; }
  .panel { animation: fadeInUp .4s ease both; }
  .list li, .entry { animation: fadeInUp .35s ease both; }
  .list li:nth-child(1), .entry:nth-child(1) { animation-delay: .02s; }
  .list li:nth-child(2), .entry:nth-child(2) { animation-delay: .07s; }
  .list li:nth-child(3), .entry:nth-child(3) { animation-delay: .12s; }
  .list li:nth-child(4), .entry:nth-child(4) { animation-delay: .17s; }
  .list li:nth-child(5), .entry:nth-child(5) { animation-delay: .22s; }
  .list li:nth-child(n+6), .entry:nth-child(n+6) { animation-delay: .26s; }
  @keyframes loadingBounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
  .loading { display: flex; gap: .45rem; justify-content: center; align-items: center; padding: 3.5rem 0; }
  .loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: loadingBounce 1.3s ease-in-out infinite both; }
  .loading span:nth-child(2) { animation-delay: .15s; }
  .loading span:nth-child(3) { animation-delay: .3s; }
  @keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
  .status.error { animation: shake .4s ease; }
}
.loading:not(:empty) { display: flex; gap: .45rem; justify-content: center; align-items: center; padding: 3.5rem 0; }
.loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
h1, h2, h3 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; color: var(--ink); line-height: 1.15; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 400; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.25rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.ar { font-family: 'Amiri', serif; }

/* header */
.bar {
  background: var(--card); border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--accent);
  padding: .9rem max(1.4rem, env(safe-area-inset-right)) .9rem max(1.4rem, env(safe-area-inset-left));
  display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; justify-content: space-between;
  transition: background .2s;
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); }
.brand img { width: 40px; height: 40px; object-fit: contain; background: var(--bg); border-radius: 50%; }
.brand .t { font-family: 'Cinzel', serif; font-size: .8rem; letter-spacing: .12em; line-height: 1.25; }
.brand .a { display: block; font-family: 'Amiri', serif; font-size: .95rem; color: var(--accent-pale); letter-spacing: 0; }
.bar nav { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; color: var(--muted); font-size: .9rem; }
.bar nav a { color: var(--accent); }

/* theme toggle */
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s, border-color .2s, transform .2s;
  flex-shrink: 0; padding: 0; position: relative; overflow: hidden;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg {
  position: absolute; top: 50%; left: 50%; width: 17px; height: 17px; fill: var(--ink);
  transition: opacity .3s ease, transform .4s ease;
}
.theme-toggle .icon-sun { transform: translate(-50%,-50%) rotate(0deg) scale(1); opacity: 1; }
.theme-toggle .icon-moon { transform: translate(-50%,-50%) rotate(-90deg) scale(.4); opacity: 0; }
html[data-theme="dark"] .theme-toggle .icon-sun { transform: translate(-50%,-50%) rotate(90deg) scale(.4); opacity: 0; }
html[data-theme="dark"] .theme-toggle .icon-moon { transform: translate(-50%,-50%) rotate(0deg) scale(1); opacity: 1; }

.wrap { max-width: 900px; margin: 0 auto; padding: 2.4rem max(1rem, env(safe-area-inset-right)) 4rem max(1rem, env(safe-area-inset-left)); }
.page-head { margin-bottom: 1.8rem; }
.back { display: inline-block; margin-bottom: .8rem; font-size: .95rem; text-decoration: none; }
.back:hover { text-decoration: underline; }

/* controls */
.btn, button.btn {
  font: inherit; font-family: 'Jost', sans-serif; font-weight: 500; font-size: .82rem; letter-spacing: .03em;
  background: var(--ink); color: var(--bg); border: 1px solid var(--ink);
  border-radius: 999px;
  padding: .7rem 1.5rem; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.2;
  transition: background .2s, color .2s, border-color .2s, transform .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.btn:active { transform: scale(.96); box-shadow: none; }
.btn.gold { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.gold:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--card-hover); border-color: var(--accent); box-shadow: none; transform: none; }
.btn.small { padding: .45rem .95rem; font-size: .72rem; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn[disabled] { opacity: .55; cursor: wait; transform: none; box-shadow: none; }

form.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .35rem; font-size: .88rem; font-weight: 500; color: var(--ink); }
input, select, textarea {
  font: inherit; font-size: 1rem; padding: .7rem .9rem; border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  width: 100%; min-width: 0; border-radius: 12px;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,146,42,.15); }
textarea { min-height: 6rem; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem; }
.status { min-height: 1.4em; margin: .5rem 0 0; font-weight: 500; }
.status.ok { color: var(--ok); }
.status.error { color: var(--danger); }

/* blocks */
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 1.6rem 1.8rem; margin-top: 1rem;
  box-shadow: 0 2px 14px rgba(0,0,0,.05);
}
.panel > *:first-child { margin-top: 0; }
.section { margin-top: 2.6rem; }
.section > h2 { border-bottom: 1px solid var(--border); padding-bottom: .5rem; position: relative; }
.section > h2::after { content: ''; position: absolute; left: 0; bottom: -1px; width: 48px; height: 2px; background: var(--accent); border-radius: 2px; }
.list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .7rem; }
.list li {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 1rem 1.3rem;
  display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 8px rgba(0,0,0,.04);
  transition: box-shadow .2s, transform .2s;
}
.list li:hover { box-shadow: 0 6px 20px rgba(0,0,0,.08); transform: translateY(-1px); }
.list li > div { min-width: 0; }
.list .name { font-weight: 600; overflow-wrap: anywhere; }
.list .inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.list .inline select, .list .inline input { width: auto; min-width: 11rem; flex: 1 1 11rem; }
.empty { margin: 0; padding: .6rem 0; }
.note { background: var(--bg-alt); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px; padding: .9rem 1.1rem; font-size: .92rem; margin-top: .9rem; }

.entries { display: grid; gap: .6rem; }
.entry { padding: 1rem 1.2rem; background: var(--bg-alt); border-radius: 14px; display: grid; gap: .3rem; justify-items: start; }
.entry .meta { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry p { margin: .1rem 0 .3rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.stars { color: var(--accent); letter-spacing: 2px; }

details.account { margin-top: 2.6rem; }
details.account summary { cursor: pointer; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.4rem; color: var(--ink); }

/* login */
.login { max-width: 440px; margin: 3.5rem auto; padding: 0 1rem; }
.login .panel { padding: 2rem 1.8rem; border-radius: 24px; }
.login h1 { text-align: center; }
.login .lede { text-align: center; margin: 0 0 1.4rem; }
.login .home { text-align: center; margin-top: 1.4rem; font-size: .92rem; }

/* change login / reset password */
.list li details.login-edit { flex-basis: 100%; border-top: 1px solid var(--border); padding-top: .7rem; margin-top: .2rem; }
.login-edit summary { cursor: pointer; color: var(--ink); font-size: .92rem; }
.login-edit .stack { margin-top: .8rem; }

.panel .status + .btn { margin-top: .9rem; }

.stack .inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.stack .inline input { flex: 1 1 12rem; width: auto; }
.sendbox { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: .9rem; min-height: 11rem; background: var(--bg-alt); border-radius: 12px; }
.panel h3 { margin-bottom: .5rem; }
