/* Heirloom — private memory workspace
   Palette: deep ink/forest sidebar, warm ivory canvas, quiet gold starlight. */

:root {
  --ink: #111f19;
  --ink-2: #182b23;
  --ink-3: #24412f;
  --ink-line: rgba(241, 236, 223, 0.12);
  --ivory: #f6f1e5;
  --ivory-2: #fbf8f0;
  --paper: #fffdf8;
  --line: #e5ddca;
  --line-strong: #cfc3a8;
  --text: #21271f;
  --text-muted: #6a6f62;
  --text-on-ink: #f1ecdf;
  --text-on-ink-muted: #b4bfb3;
  --gold: #c9a45a;
  --gold-deep: #a07a33;
  --gold-soft: #f3e6c0;
  --gold-glow: rgba(230, 197, 119, 0.35);
  --forest: #2f5c4b;
  --forest-deep: #244a3b;
  --forest-soft: #e4efe8;
  --danger: #a4392f;
  --danger-soft: #fbe9e6;
  --ok: #2d6a4d;
  --ok-soft: #e4f1e8;
  --warn-soft: #fbf1d6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(17, 31, 25, 0.05), 0 14px 34px -22px rgba(17, 31, 25, 0.35);
  --shadow-lg: 0 24px 60px -24px rgba(17, 31, 25, 0.45);
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --focus-ring: 0 0 0 3px rgba(201, 164, 90, 0.6);
  --sidebar-w: 284px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--ivory);
  overflow-wrap: anywhere;
}

h1, h2, h3, .brand-name, .account-name, .card-title, .empty-title, .detail-title {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.005em;
  color: var(--ink);
  margin: 0;
}

h1 { font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem); line-height: 1.15; }
h2 { font-size: 1.45rem; line-height: 1.2; }
h3 { font-size: 1.1rem; line-height: 1.3; }

p { margin: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
a { color: var(--forest-deep); }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  padding: 10px 14px; background: var(--ink); color: var(--text-on-ink);
  border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  min-width: 0;
  padding: clamp(24px, 2vw + 16px, 48px) clamp(16px, 3vw + 8px, 56px) 64px;
}
.main:focus { outline: none; }

.view { max-width: 1060px; }

.view-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px;
}
.lede { color: var(--text-muted); margin-top: 6px; max-width: 56ch; }

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 28px 22px 22px;
  background: linear-gradient(176deg, var(--ink) 0%, var(--ink-2) 55%, var(--ink-3) 100%);
  color: var(--text-on-ink);
  overflow: hidden;
}
.sidebar::after {
  content: ""; position: absolute; inset: auto -40% -30% auto; width: 60%; aspect-ratio: 1;
  background: radial-gradient(circle, var(--gold-glow) 0%, rgba(0,0,0,0) 65%);
  opacity: 0.35; pointer-events: none;
}

.constellation {
  position: absolute; top: 10px; right: 6px; width: 170px; height: auto;
  pointer-events: none; opacity: 0.85;
}
.constellation-lines line { stroke: var(--gold); stroke-width: 0.5; opacity: 0.35; }
.constellation-stars circle { fill: var(--gold-soft); }
.constellation-stars circle:nth-child(2),
.constellation-stars circle:nth-child(4) { filter: drop-shadow(0 0 3px var(--gold)); }

.brand { display: flex; align-items: center; gap: 12px; position: relative; }
.brand-mark { width: 46px; height: 46px; flex: none; filter: drop-shadow(0 0 6px rgba(230,197,119,0.3)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { color: var(--text-on-ink); font-size: 1.5rem; line-height: 1.1; letter-spacing: 0.02em; }
.brand-tagline { color: var(--text-on-ink-muted); font-size: 0.8rem; line-height: 1.3; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 4px; position: relative; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-on-ink-muted); text-align: left; width: 100%;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--ink-line); color: var(--text-on-ink); }
.nav-link[aria-current="page"] { background: rgba(201, 164, 90, 0.14); color: var(--text-on-ink); }
.nav-link[aria-current="page"] .nav-icon { color: var(--gold); }
.nav-icon { width: 20px; height: 20px; flex: none; }
.nav-icon svg { width: 20px; height: 20px; }
.nav-count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px; background: var(--gold); color: var(--ink);
  font-size: 0.78rem; font-weight: 600;
}

.account-card {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 14px 14px 12px; border-radius: var(--radius);
  background: rgba(241, 236, 223, 0.06); border: 1px solid var(--ink-line);
}
.account-label { font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-on-ink-muted); }
.account-name { color: var(--text-on-ink); font-size: 1.2rem; line-height: 1.2; }
.account-email { color: var(--text-on-ink-muted); font-size: 0.86rem; }
.account-card .btn { margin-top: 10px; align-self: flex-start; }

.lang-toggle { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(241,236,223,0.08); border: 1px solid var(--ink-line); align-self: flex-start; margin-top: auto; position: relative; }
.lang-toggle button {
  border: 0; background: transparent; color: var(--text-on-ink-muted);
  padding: 6px 14px; border-radius: 999px; font-size: 0.9rem;
}
.lang-toggle button[aria-pressed="true"] { background: var(--gold); color: var(--ink); font-weight: 600; }
.lang-toggle button:focus-visible { box-shadow: var(--focus-ring); border-radius: 999px; }

.beta-notice {
  font-size: 0.76rem; color: var(--text-on-ink-muted); letter-spacing: 0.02em;
  padding-left: 10px; border-left: 2px solid var(--gold-deep); position: relative;
  margin-top: -8px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--paper); color: var(--ink); font-weight: 500; text-decoration: none;
  line-height: 1.2; min-height: 42px; transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--ivory-2); border-color: var(--gold-deep); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { border-radius: 999px; }
.btn-primary { background: var(--forest-deep); border-color: var(--forest-deep); color: #fff; }
.btn-primary:hover { background: var(--forest); border-color: var(--forest); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--forest-deep); }
.btn-ghost:hover { background: rgba(47, 92, 75, 0.08); border-color: transparent; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8d2f26; border-color: #8d2f26; }
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 0.9rem; }
.btn-outline-light { background: transparent; border-color: rgba(241,236,223,0.3); color: var(--text-on-ink); }
.btn-outline-light:hover { background: var(--ink-line); border-color: var(--gold); }

.btn-record { border-color: var(--danger); color: var(--danger); }
.btn-record:hover { background: var(--danger-soft); border-color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.btn-stop { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-stop:hover { background: #8d2f26; }
.stop-square { width: 10px; height: 10px; background: #fff; border-radius: 2px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid transparent;
  background: transparent; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--ivory); color: var(--ink); }
.icon-btn:focus-visible { border-radius: 50%; }

/* ---------- Tabs ---------- */

.filter-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.filter-tabs [role="tab"] {
  border: 0; background: transparent; padding: 10px 14px 12px; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.filter-tabs [role="tab"]:hover { color: var(--ink); }
.filter-tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold-deep); }
.filter-tabs [role="tab"]:focus-visible { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab-count { color: var(--text-muted); font-weight: 400; }

/* ---------- Memory cards ---------- */

.memory-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.memory-card {
  width: 100%; height: 100%; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 18px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--paper); box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.memory-card:hover { border-color: var(--gold); transform: translateY(-1px); }
.memory-card:focus-visible { border-radius: var(--radius); border-color: var(--gold); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-muted); }
.card-lang { letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; color: var(--gold-deep); }
.card-title { font-size: 1.22rem; line-height: 1.25; }
.card-by { font-size: 0.86rem; color: var(--forest-deep); }
.card-excerpt {
  color: var(--text-muted); font-size: 0.94rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-excerpt.is-audio-only { font-style: italic; }
.card-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 0.76rem;
  background: var(--ivory); color: var(--text-muted); border: 1px solid var(--line);
}
.badge svg { width: 13px; height: 13px; }
.badge-pending { background: var(--warn-soft); color: var(--gold-deep); border-color: transparent; }
.badge-accepted { background: var(--forest-soft); color: var(--forest-deep); border-color: transparent; }
.badge-lang { letter-spacing: 0.02em; }

/* ---------- Empty / loading / error states ---------- */

.empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: clamp(28px, 4vw, 48px); border-radius: var(--radius);
  border: 1px dashed var(--line-strong); background: var(--ivory-2); max-width: 620px;
  position: relative; overflow: hidden;
}
.empty-star { width: 34px; height: 34px; color: var(--gold); margin-bottom: 4px; }
.empty-title { font-size: 1.5rem; }
.empty-body { color: var(--text-muted); max-width: 48ch; }
.empty .btn { margin-top: 8px; }

.loading { color: var(--text-muted); padding: 24px 0; }
.error-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(164,57,47,0.25);
}
.error-box p { flex: 1 1 240px; }
.banner { margin-bottom: 20px; }

.notice {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--forest-soft); color: var(--forest-deep); font-size: 0.94rem;
}
.notice-warn { background: var(--warn-soft); color: var(--gold-deep); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Invitations ---------- */

.invite-list { display: flex; flex-direction: column; gap: 12px; max-width: 720px; }
.invite-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--paper); box-shadow: var(--shadow);
}
.invite-text { flex: 1 1 260px; }
.invite-title { font-family: var(--font-display); font-size: 1.15rem; color: var(--ink); }
.invite-meta { font-size: 0.86rem; color: var(--text-muted); margin-top: 2px; }
.invite-link-box {
  margin-bottom: 18px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--gold-soft); border: 1px solid rgba(160,122,51,0.3); max-width: 720px;
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
}
.invite-link-box p { flex: 1 1 240px; }

/* ---------- Archive ---------- */

.archive-card {
  max-width: 620px; padding: 26px 28px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.archive-includes { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.archive-includes li { padding-left: 22px; position: relative; }
.archive-includes li::before {
  content: ""; position: absolute; left: 4px; top: 10px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 6px var(--gold-glow);
}
.archive-card .btn { align-self: flex-start; text-align: center; }
.archive-card .btn[aria-disabled="true"] { opacity: 0.6; pointer-events: none; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; min-width: 0; }
fieldset.field { border: 0; padding: 0; margin: 0 0 18px; }
legend, label { font-weight: 600; font-size: 0.95rem; color: var(--ink); padding: 0; }
.help { color: var(--text-muted); font-size: 0.9rem; }
.hint { color: var(--text-muted); font-size: 0.9rem; padding: 12px 14px; border-left: 3px solid var(--gold); background: var(--ivory-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

input[type="text"], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--text);
  min-height: 44px;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input[type="text"]:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--gold-deep); box-shadow: var(--focus-ring);
}
.field-meta { display: flex; justify-content: flex-end; font-size: 0.78rem; color: var(--text-muted); }
.field-error { color: var(--danger); font-size: 0.9rem; }
.is-invalid { border-color: var(--danger) !important; }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.radio { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; min-height: 32px; }
.radio input { width: 18px; height: 18px; accent-color: var(--forest-deep); margin: 0; }

.media-block {
  margin-bottom: 18px; padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--ivory-2);
  display: flex; flex-direction: column; gap: 10px;
}
.media-block h3 { margin-bottom: -2px; }
.recorder { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.timer { font-variant-numeric: tabular-nums; font-size: 0.95rem; color: var(--danger); font-weight: 600; }
.notice-inline { color: var(--gold-deep); }

.preview {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
  border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--line);
}
.preview-label { font-weight: 600; font-size: 0.9rem; }
.preview audio { width: 100%; max-width: 440px; }
.preview-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.preview-meta { font-size: 0.84rem; color: var(--text-muted); }
.preview-photo img { width: 160px; height: 120px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }

.file-field { position: relative; display: inline-flex; flex-direction: column; gap: 6px; }
.file-field label { font-weight: 500; font-size: 0.9rem; display: block; padding: 10px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.file-field input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-field:focus-within label { outline: 2px solid var(--gold-deep); outline-offset: 3px; }
input[type="file"] { font-size: 0.9rem; max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; margin-right: 10px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); cursor: pointer;
}
input[type="file"]:focus-visible { box-shadow: none; }
input[type="file"]:focus-visible::file-selector-button { box-shadow: var(--focus-ring); border-color: var(--gold-deep); }

.prep { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); margin-bottom: 18px; }
.prep summary { padding: 14px 18px; cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 10px; }
.prep summary::-webkit-details-marker { display: none; }
.prep summary::before {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--gold-deep); border-bottom: 2px solid var(--gold-deep);
  transform: rotate(-45deg); transition: transform 0.15s; flex: none;
}
.prep[open] summary::before { transform: rotate(45deg); }
.prep summary:focus-visible { border-radius: var(--radius); }
.prep > :not(summary) { margin-left: 18px; margin-right: 18px; }
.prep > .help { margin-bottom: 14px; }
.prep > .field:last-child { margin-bottom: 18px; }

.progress-box { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.progress-box progress { flex: 1; height: 8px; accent-color: var(--forest-deep); }
.progress-box span { font-size: 0.9rem; color: var(--text-muted); white-space: nowrap; }

/* ---------- Dialogs ---------- */

.dialog {
  border: 0; padding: 0; margin: auto; background: transparent; color: var(--text);
  width: min(100% - 24px, 640px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow: visible;
}
.dialog::backdrop { background: rgba(17, 31, 25, 0.55); backdrop-filter: blur(2px); }
.dialog-inner {
  display: flex; flex-direction: column; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); margin: 0; overflow: hidden;
}
.dialog-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.dialog-header h2:focus { outline: none; }
.dialog-body { padding: 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dialog-footer {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--ivory-2); flex: none;
}
.dialog-footer:empty { display: none; }
.spacer { flex: 1; }
.dialog-compose { width: min(100% - 24px, 700px); }
.dialog-detail { width: min(100% - 24px, 760px); }

/* Memory detail */
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 18px; }
.detail-meta .card-lang { font-size: 0.78rem; align-self: center; }
.detail-body {
  font-family: var(--font-display); font-size: 1.08rem; line-height: 1.65; white-space: pre-wrap;
  color: var(--text); margin-bottom: 22px;
}
.detail-body.is-empty { font-family: var(--font-body); font-style: italic; color: var(--text-muted); font-size: 1rem; }
.detail-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.detail-section h3 { margin-bottom: 2px; }
.detail-audio audio { width: 100%; }
.detail-photo img { max-height: 360px; width: auto; max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.detail-prep { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.detail-prep dt { font-weight: 600; font-size: 0.9rem; color: var(--text-muted); }
.detail-prep dd { margin: 0; white-space: pre-wrap; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.share-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.share-form .field { flex: 1 1 200px; margin: 0; }
.share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.share-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--ivory-2); border: 1px solid var(--line);
}
.share-name { font-weight: 600; flex: 1 1 140px; }
.share-status { font-size: 0.78rem; padding: 3px 9px; border-radius: 999px; }
.share-status.pending { background: var(--warn-soft); color: var(--gold-deep); }
.share-status.accepted { background: var(--forest-soft); color: var(--forest-deep); }
.share-status.revoked { background: var(--ivory); color: var(--text-muted); border: 1px solid var(--line); }
.share-confirm {
  flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 0.92rem;
}
.share-confirm p { flex: 1 1 220px; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-row input { flex: 1 1 200px; font-size: 0.86rem; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(8px);
  max-width: min(92vw, 480px); padding: 12px 18px; border-radius: 999px;
  background: var(--ink); color: var(--text-on-ink); box-shadow: var(--shadow-lg);
  font-size: 0.94rem; opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; padding: 16px 16px 12px; gap: 12px;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas:
      "brand lang"
      "account account"
      "nav nav"
      "notice notice";
    align-items: center;
  }
  .sidebar::after { display: none; }
  .constellation { width: 110px; top: 34px; right: 4px; opacity: 0.4; }
  .brand { grid-area: brand; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-name { font-size: 1.3rem; }
  .brand-tagline { display: none; }
  .nav { grid-area: nav; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; padding-bottom: 2px; }
  .nav-link { width: 100%; min-width: 0; justify-content: center; white-space: nowrap; padding: 8px 6px; gap: 5px; }
  .nav-count { margin-left: 2px; }
  .account-card { grid-area: account; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; }
  .account-label { flex-basis: 100%; }
  .account-name { font-size: 1.05rem; }
  .account-card .btn { margin: 0 0 0 auto; }
  .lang-toggle { grid-area: lang; justify-self: end; margin-top: 0; }
  .lang-toggle button { padding: 5px 10px; font-size: 0.84rem; }
  .beta-notice { grid-area: notice; margin-top: 0; }
  .main { padding: 20px 16px 56px; }
  .view-header { margin-bottom: 18px; }
  .view-header .btn-primary { width: 100%; }
}

@media (max-width: 480px) {
  body { font-size: 15.5px; }
  .dialog { width: calc(100% - 12px); max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px); }
  .dialog-inner { max-height: calc(100vh - 12px); max-height: calc(100dvh - 12px); }
  .dialog-header, .dialog-body, .dialog-footer { padding-left: 14px; padding-right: 14px; }
  .dialog-footer .btn { flex: 1 1 auto; }
  .dialog-footer .spacer { display: none; }
  .dialog-footer .btn-danger-text { flex-basis: 100%; order: 3; }
  .media-block { padding: 14px; }
  .memory-grid { grid-template-columns: 1fr; }
  .filter-tabs { overflow-x: auto; }
  .filter-tabs [role="tab"] { white-space: nowrap; }
  .account-card .btn { margin-left: 0; }
  .detail-prep { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-prep dd { margin-bottom: 8px; }
  .nav-icon { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .memory-card:hover { transform: none; }
}

/* Account beta additions preserve the original visual language. */
[hidden] { display: none !important; }
.account-panel { max-width: 650px; margin: 28px auto 40px; padding: clamp(20px, 4vw, 40px); background: var(--ivory-2); border: 1px solid var(--line); border-radius: var(--radius); }
.account-panel h1 { margin-top: 12px; } .account-panel p { margin: 16px 0; }
.auth-form { display: flex; flex-direction: column; align-items: stretch; gap: 14px; margin: 24px 0; }
.auth-form .field { margin: 0; } .auth-form .btn { align-self: flex-start; }
.eyebrow { color: var(--gold-deep); text-transform: uppercase; letter-spacing: .1em; font-size: .76rem; font-weight: 700; }
.account-email, .share-name { overflow-wrap: anywhere; min-width: 0; }
.account-label, .account-email, .account-name { display: block; } .account-card { min-width: 0; }
.account-footer { margin-top: 40px; }
.acknowledgement { display: flex; gap: 12px; align-items: flex-start; line-height: 1.6; }
.acknowledgement input { flex: 0 0 20px; width: 20px; min-height: 20px; margin-top: 3px; }
#authCode { max-width: 260px; letter-spacing: .2em; }
@media (max-width: 480px) { .account-panel { margin: 8px 0 24px; padding: 20px 16px; } .auth-form .btn { align-self: stretch; } }

/* ---------- The private observatory ----------
   Paper holds the stories and forms; the night sky holds the collection. */
:root {
  --night: #101e24;
  --night-deep: #0b171c;
  --night-raised: #182c31;
  --night-line: rgba(223, 225, 207, .17);
  --night-muted: #b8c7c0;
  --starlight: #dfc48a;
}
.app { background: var(--night-deep); }
.app .main {
  background:
    radial-gradient(ellipse at 95% 0, rgba(86, 111, 97, .22), transparent 45%),
    radial-gradient(ellipse at 0 65%, rgba(36, 70, 67, .18), transparent 60%),
    linear-gradient(155deg, var(--night), var(--night-deep) 80%);
}
.view { max-width: 1180px; margin-inline: auto; }
#privateViews { color: var(--text-on-ink); }
#privateViews :is(.archive-card, .invite-card, .invite-link-box, .empty) { color: var(--text); }
#privateViews .view-header h1 { color: var(--text-on-ink); font-size: clamp(2rem, 2.9vw, 3.2rem); }
#privateViews .view-header .lede,
.workspace-intro > p,
.capture-paths > p,
.preparation-intro { color: var(--night-muted); }
.sidebar {
  background: linear-gradient(175deg, #10231f, #152c26 60%, #1c342c);
  border-right: 1px solid var(--night-line);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #527063 transparent;
}
.sidebar > :not(.constellation) { flex-shrink: 0; }
.nav { gap: 6px; }
.nav-link { min-height: 46px; padding-block: 12px; }
.nav-link[aria-current="page"] { background: rgba(223, 196, 138, .13); box-shadow: inset 2px 0 var(--starlight); }
.account-card { background: rgba(8, 22, 18, .22); }
.app .account-panel { box-shadow: 0 24px 70px rgba(0, 0, 0, .18); }
.app > .main > .account-footer { color: var(--night-muted); }
.app > .main > .account-footer a { color: #cdd8cc; text-underline-offset: 4px; }
.workspace-intro { max-width: 65ch; margin-bottom: 18px; }
.workspace-intro h2 { color: var(--text-on-ink); font-size: 1.65rem; }
.view-header h1:focus, .dialog-header h2:focus, #sceneHeading:focus { outline: none; box-shadow: none; }
.workspace-intro .eyebrow { display: block; color: var(--starlight); margin-bottom: 10px; }
.workspace-intro > p { margin-top: 10px; line-height: 1.7; }
.view-header > * { min-width: 0; }
#privateViews .view-header .btn-primary { background: var(--starlight); border-color: var(--starlight); color: #18271f; }
#privateViews .view-header .btn-primary:hover { background: #ecd39e; border-color: #ecd39e; }

/* A quiet, tactile switch between ways of exploring. */
.explore-switch, .compose-path-switch {
  display: flex; flex-wrap: wrap; gap: 5px; width: fit-content; max-width: 100%;
  padding: 5px; border: 1px solid var(--night-line); border-radius: 999px;
  background: rgba(7, 18, 22, .3);
}
.explore-switch { margin: 0 0 22px; }
.explore-switch button, .compose-path-switch button {
  border: 1px solid transparent; border-radius: 999px; padding: 9px 17px;
  min-height: 42px; background: transparent; color: var(--night-muted);
  font-size: .88rem; font-weight: 600; transition: color .18s, background .18s, border-color .18s;
}
.explore-switch button:hover { color: var(--text-on-ink); background: rgba(223, 196, 138, .07); }
.explore-switch button[aria-pressed="true"] { background: #e9debf; color: #23372d; border-color: #e9debf; }

/* Copy lives outside the drawing surface so even long translations cannot obscure nodes. */
.constellation-shell {
  position: relative; isolation: isolate; margin-bottom: 36px; overflow: hidden;
  border: 1px solid rgba(210, 194, 149, .26); border-radius: 22px;
  background:
    radial-gradient(ellipse at 80% 32%, rgba(63, 95, 89, .25), transparent 58%),
    linear-gradient(145deg, #14272c, #0a171f 75%);
  box-shadow: 0 25px 70px -40px rgba(0, 0, 0, .75), inset 0 1px rgba(248, 237, 202, .04);
}
.constellation-copy { position: relative; z-index: 1; padding: 26px 30px 0; max-width: 750px; }
.constellation-copy .eyebrow { color: var(--starlight); }
.constellation-copy h2 { color: #f5eddc; font-size: clamp(1.7rem, 2.5vw, 2.3rem); margin-top: 9px; }
.constellation-copy p { color: var(--night-muted); max-width: 58ch; margin-top: 10px; font-size: .93rem; line-height: 1.65; }
.constellation-stage { position: relative; width: 100%; height: clamp(380px, 36vw, 460px); overflow: hidden; }
canvas#memorySceneCanvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: pan-y; }
canvas#memorySceneCanvas:focus-visible { outline: 2px solid var(--starlight); outline-offset: -6px; box-shadow: none; border-radius: 12px; }
.scene-empty-note {
  position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: 28px; color: #cfdbd2; pointer-events: none; font-size: .95rem;
}
.scene-empty-note p { max-width: 40ch; }
.scene-empty-note strong { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; color: #f2e9d5; }
.scene-footer {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px 20px; padding: 14px 26px; border-top: 1px solid var(--night-line);
  background: rgba(5, 16, 20, .25); color: var(--night-muted); font-size: .8rem;
}
.scene-count { display: inline-flex; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.scene-count::before { content: ""; width: 5px; height: 5px; flex: none; background: var(--starlight); border-radius: 50%; }
#sceneMotion { border: 1px solid #5d7068; background: #18302f; color: #e5e9da; border-radius: 999px; min-height: 36px; padding: 6px 12px; font-size: .8rem; }
#sceneMotion:hover { background: #25413c; border-color: var(--starlight); }
#sceneMotion[aria-pressed="true"] { border-color: var(--starlight); }

/* Invitations to capture: human prompts, rather than blank form fields. */
.capture-paths { margin: 28px 0 32px; }
.capture-paths > h2 { color: var(--text-on-ink); font-size: 1.55rem; }
.capture-paths > p { margin-top: 8px; max-width: 65ch; font-size: .92rem; }
.capture-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.capture-action {
  min-width: 0; min-height: 122px; padding: 20px; display: flex; flex-direction: column;
  align-items: flex-start; gap: 5px; text-align: left; border-radius: 14px;
  background: #eee8d9; color: #334638; border: 1px solid #d0c6aa;
  box-shadow: 0 8px 25px -18px #000; transition: transform .18s, background .18s, border-color .18s;
}
.capture-action > :is(svg, .capture-icon, .capture-action-icon) { width: 23px; height: 23px; color: #527159; margin-bottom: 8px; }
.capture-action > strong { font-family: var(--font-display); font-size: 1.3rem; font-weight: 400; line-height: 1.3; color: #1b352a; }
.capture-action > span { color: #556051; font-size: .82rem; line-height: 1.5; }
.capture-action:hover { background: #faf3e3; border-color: var(--starlight); transform: translateY(-2px); }
.prompt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 10px; margin-top: 18px; }
.prompt-card {
  display: flex; flex-direction: column; gap: 9px; min-width: 0; padding: 18px;
  text-align: left; background: #172b2d; border: 1px solid #3a504b;
  border-radius: 12px; color: #d7e0d2; transition: background .18s, border-color .18s, transform .18s;
}
.prompt-card > small { color: var(--starlight); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; line-height: 1.5; }
.prompt-card > strong { font-family: var(--font-display); color: #f1ead9; font-size: 1.13rem; font-weight: 400; line-height: 1.4; }
.prompt-card > span { color: #b9c9bf; font-size: .8rem; line-height: 1.55; }
.prompt-card:hover { background: #203732; border-color: #9a926c; transform: translateY(-2px); }

/* Find and browse the actual collection. */
.library-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 28px 0 18px; }
.search-field { flex: 1 1 250px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.library-select { flex: 0 1 180px; min-width: 140px; display: flex; flex-direction: column; gap: 6px; }
.library-toolbar label { font-size: .77rem; font-weight: 500; color: #c7d2c7; }
.library-toolbar input, .library-toolbar select { min-height: 46px; background: #f6f0e3; color: #273c2f; border-color: #a5ad99; }
.library-toolbar input::placeholder { color: #646f61; opacity: 1; }
.library-summary { flex: 1 0 100%; color: #b6c7bc; font-size: .8rem; margin-top: 2px; }
#privateViews .filter-tabs { border-color: var(--night-line); }
#privateViews .filter-tabs [role="tab"] { color: #becbc1; padding-inline: 16px; min-height: 46px; }
#privateViews .filter-tabs [role="tab"]:hover { color: #fff8e7; }
#privateViews .filter-tabs [role="tab"][aria-selected="true"] { color: #f3e4bc; border-bottom-color: var(--starlight); }
#privateViews .tab-count { color: #bdcabc; }
.memory-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 265px), 1fr)); gap: 20px; }
.memory-grid > li { min-width: 0; }
.memory-card {
  position: relative; min-height: 240px; padding: 24px 24px 22px; gap: 12px;
  background: linear-gradient(145deg, #fffdf7, #f1ebdd); border-color: #ded4bc;
  border-radius: 4px 18px 18px 4px;
  box-shadow: 0 12px 30px -20px #000, inset 3px 0 #d5c393;
}
.memory-card:hover { transform: translateY(-3px); border-color: #c3ab6c; box-shadow: 0 18px 36px -20px #000, inset 3px 0 #a78542; }
.card-title { font-size: 1.5rem; line-height: 1.26; color: #25372b; }
.card-top { font-size: .72rem; color: #64705f; }
.card-lang { color: #7c5e25; }
.card-excerpt { font-size: .93rem; color: #5d6859; line-height: 1.65; -webkit-line-clamp: 4; }
.card-badges { gap: 6px; padding-top: 12px; }
.card-by { color: #375d45; font-size: .8rem; }
.memory-list .no-results { padding: 30px; color: #cbd6cb; border: 1px dashed #607164; border-radius: 14px; background: #132629; }
.memory-list .no-results h2, .memory-list .no-results h3 { color: var(--text-on-ink); }
.memory-list.is-timeline { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.timeline-group { grid-column: 1 / -1; min-width: 0; padding-left: 24px; border-left: 1px solid #657164; position: relative; }
.timeline-group::before { content: ""; position: absolute; left: -4px; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--starlight); }
.timeline-group > h2 { color: #e7ddc5; font-size: 1.3rem; margin-bottom: 18px; }
.timeline-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 18px; padding: 0; margin: 0; list-style: none; }
.timeline-cards > * { min-width: 0; }
#privateViews .loading { color: var(--night-muted); }
.empty { max-width: none; background: #f2ecdf; padding: clamp(26px, 4vw, 44px); border-style: solid; }
.empty .empty-title { font-size: clamp(1.6rem, 2vw, 2rem); }
.empty .empty-body { color: #5a6757; }

/* A circle of real people, and practical notes from real memories. */
.circle-grid, .preparation-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 20px; }
.person-card, .preparation-card {
  min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  padding: 26px; border: 1px solid #d6ceb7; border-radius: 18px;
  background: #f5efe2; color: #374535; box-shadow: 0 15px 30px -24px #000;
}
.person-symbol {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 54px; height: 54px; border-radius: 50%; background: #dae1cd; color: #39513a;
  border: 1px solid #bac6ac; font-family: var(--font-display); font-size: 1.55rem;
}
.person-card h2, .preparation-card h2 { font-size: 1.5rem; color: #243d2d; }
.person-card p { color: #5c6857; font-size: .88rem; }
.person-stories { display: flex; flex-direction: column; width: 100%; gap: 7px; margin-top: 2px; }
.person-stories button { text-align: left; padding: 10px 12px; border-radius: 8px; background: #fffdf6; border: 1px solid #d9d2bd; color: #35513d; font-size: .88rem; line-height: 1.5; }
.person-stories button:hover { border-color: #9d9d77; background: #ece9d7; }
.status-pill { display: inline-flex; align-items: center; padding: 4px 10px; border: 1px solid #bdcbb5; background: #e2eadb; color: #37553a; border-radius: 999px; font-size: .72rem; line-height: 1.4; }
.person-status { display: flex; flex-wrap: wrap; gap: 6px; }
.preparation-detail { width: 100%; }
.preparation-detail h3 { color: #657155; font-size: .8rem; margin-bottom: 5px; }
.preparation-detail p { white-space: pre-wrap; line-height: 1.7; }
.preparation-intro { max-width: 67ch; margin: 0 0 24px; line-height: 1.7; }
.preparation-card > :is(small, .eyebrow) { color: #786133; }
.preparation-card dl { width: 100%; margin: 0; }
.preparation-card dt { color: #6c715e; font-size: .73rem; text-transform: uppercase; letter-spacing: .06em; margin: 16px 0 4px; }
.preparation-card dd { margin: 0; white-space: pre-wrap; line-height: 1.7; color: #334832; }
.preparation-card > .btn { margin-top: auto; }

/* Keep all authoring, account, and privacy controls on clear warm paper. */
input[type="email"], input[type="search"] {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--text);
}
input[type="email"]:focus-visible, input[type="search"]:focus-visible { border-color: var(--gold-deep); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { opacity: .7; cursor: not-allowed; }
.compose-prompt { margin: 0 0 22px; padding: 18px 20px; border-left: 3px solid #a98b48; border-radius: 3px 12px 12px 3px; background: #efe8d5; color: #3d533b; line-height: 1.65; }
.compose-prompt > strong { display: block; font-family: var(--font-display); font-size: 1.3rem; font-weight: 400; color: #30462e; margin-bottom: 5px; }
.compose-prompt > small { display: block; color: #76633f; font-size: .73rem; }
.compose-path-switch { margin: 0 0 24px; background: #eeeadd; border-color: #d6cdb6; }
.compose-path-switch button { color: #53624c; }
.compose-path-switch button:hover { background: #e2dfca; color: #314b32; }
.compose-path-switch button[aria-pressed="true"] { background: #304e3c; color: #fff8e8; border-color: #304e3c; }
.media-block:target, .media-block:focus-within { border-color: #b5a06d; }
.dialog-compose { width: min(100% - 32px, 760px); }
.dialog-compose .dialog-header { padding: 24px 28px 20px; }
.dialog-compose .dialog-body { padding: 26px 28px; }
.dialog-compose .dialog-footer { padding: 18px 28px; }
.dialog::backdrop { background: rgba(3, 12, 14, .78); backdrop-filter: blur(7px); }
.dialog-inner { box-shadow: 0 34px 100px rgba(0, 0, 0, .35); border-color: #c5b995; }
.dialog-header .icon-btn { border-color: #d8d0bb; color: #40513b; background: #f6f1e4; }
.dialog-header .icon-btn:hover { background: #e9e2cc; color: #223f2b; }

/* Open a memory as a spacious reader, with sharing and practical notes below it. */
.dialog-detail { width: min(100% - 48px, 960px); }
.dialog-detail .dialog-header { align-items: flex-start; padding: 30px 38px 24px; background: #efe9da; }
.dialog-detail .dialog-header h2 { font-size: clamp(1.8rem, 3vw, 2.5rem); line-height: 1.2; max-width: 24ch; }
.dialog-detail .dialog-body { padding: 26px 38px 34px; background: #fffcf4; scrollbar-gutter: stable; }
.detail-meta { gap: 8px 16px; font-size: .79rem; padding-bottom: 22px; border-bottom: 1px solid #e1d9c4; margin-bottom: 28px; }
.detail-body { max-width: 62ch; font-size: clamp(1.12rem, 1.3vw, 1.28rem); line-height: 1.85; color: #303c2d; margin-bottom: 30px; }
.detail-body.is-empty { font-size: .96rem; }
.detail-section { gap: 14px; margin-top: 26px; padding-top: 24px; }
.detail-section h3 { font-size: 1.3rem; color: #2c432f; }
.detail-audio { background: #efeedd; border: 1px solid #dad8bf; border-radius: 14px; padding: 20px 22px; }
.detail-audio audio { width: 100%; min-width: 0; }
.detail-photo img { max-height: 520px; max-width: 100%; width: auto; margin-inline: auto; object-fit: contain; border-radius: 4px; box-shadow: 0 14px 25px -20px #4b422b; }
.detail-prep { padding: 18px 20px; gap: 12px 22px; background: #f1eedf; border: 1px solid #ddd7c0; border-radius: 12px; }
.detail-prep dt { color: #5c694e; font-size: .82rem; }
.detail-prep dd { color: #334631; line-height: 1.7; min-width: 0; }
.detail-section:has(.share-form) { background: #f3eedf; border: 1px solid #dcd1b5; padding: 24px; border-radius: 16px; }
.share-form { gap: 14px; }
.share-form .field { flex-basis: 220px; }
.share-list { gap: 10px; margin-top: 6px; }
.share-item { padding: 14px; background: #fffbef; border-color: #e0d7be; }
.detail-actions { flex-direction: row; justify-content: space-between; align-items: center; }
.detail-actions .btn { white-space: normal; text-align: center; }
.dialog-footer .btn { text-align: center; }
:focus-visible { outline: 2px solid #b99240; outline-offset: 3px; }
.explore-switch button:focus-visible, #sceneMotion:focus-visible, .prompt-card:focus-visible { outline-color: #f1d694; box-shadow: 0 0 0 4px #10262b; }

@media (hover: none) {
  .memory-card:hover, .capture-action:hover, .prompt-card:hover { transform: none; }
}
@media (min-width: 1500px) {
  .main { padding-inline: clamp(42px, 5vw, 100px); }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 242px; }
  .sidebar { padding-inline: 18px; }
  .main { padding-inline: 26px; }
  .capture-action { padding: 18px 16px; }
  .library-select { flex-basis: 155px; }
}
@media (max-width: 900px) {
  .sidebar { border-right: 0; border-bottom: 1px solid var(--night-line); }
  .nav { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .nav-link { white-space: normal; font-size: .86rem; min-height: 44px; }
  .nav-link[aria-current="page"] { box-shadow: inset 0 -2px var(--starlight); }
  .main { padding: 28px 24px 56px; }
  .view-header .btn-primary { width: auto; }
  .constellation-stage { height: 380px; }
  .lang-toggle { align-self: center; }
}
@media (max-width: 640px) {
  .sidebar { gap: 9px; }
  .nav { display: flex; flex-direction: row; overflow-x: auto; scrollbar-width: thin; padding-bottom: 6px; }
  .nav-link { flex: 0 0 auto; width: auto; white-space: nowrap; padding: 8px 12px; }
  .account-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 10px 12px; }
  .account-label { display: none; }
  .account-name, .account-email { grid-column: 1; }
  .account-email { font-size: .74rem; }
  .account-card .btn { grid-column: 2; grid-row: 1 / 3; margin: 0; padding: 8px 10px; font-size: .76rem; }
  .main { padding-inline: 16px; }
  .view-header { gap: 20px; }
  .view-header > .btn { width: 100%; }
  .workspace-intro { margin-bottom: 6px; }
  .explore-switch { width: 100%; border-radius: 14px; }
  .explore-switch button { flex: 1 1 85px; padding-inline: 10px; border-radius: 10px; }
  .constellation-shell { border-radius: 16px; margin-bottom: 28px; }
  .constellation-copy { padding: 22px 20px 0; }
  .constellation-copy p { font-size: .86rem; }
  .constellation-stage { height: 320px; }
  .scene-footer { padding: 12px 18px; font-size: .74rem; }
  .capture-actions { grid-template-columns: 1fr; gap: 9px; }
  .capture-action { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 4px 12px; min-height: 0; padding: 16px; }
  .capture-action > :is(svg, .capture-icon, .capture-action-icon) { grid-column: 1; grid-row: 1 / 3; margin: 3px 0 0; }
  .capture-action > strong, .capture-action > span:not(.capture-icon):not(.capture-action-icon) { grid-column: 2; }
  .capture-action > strong { font-size: 1.2rem; }
  .prompt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prompt-card { padding: 15px; gap: 7px; }
  .prompt-card > strong { font-size: 1.05rem; }
  .library-toolbar { gap: 12px 10px; }
  .search-field { flex-basis: 100%; }
  .library-select { flex: 1 1 130px; min-width: 0; }
  .memory-grid { gap: 16px; }
  .memory-card { min-height: 210px; padding: 22px; }
  .timeline-group { padding-left: 18px; }
  .circle-grid, .preparation-grid { gap: 14px; }
  .person-card, .preparation-card { padding: 22px; }
  .dialog { width: 100%; height: 100%; max-width: 100%; max-height: 100vh; max-height: 100dvh; margin: 0; }
  .dialog-inner { height: 100%; max-height: 100vh; max-height: 100dvh; border: 0; border-radius: 0; }
  .dialog-compose .dialog-header, .dialog-detail .dialog-header { padding: 20px; gap: 14px; }
  .dialog-compose .dialog-body, .dialog-detail .dialog-body { padding: 22px 20px; }
  .dialog-compose .dialog-footer { padding: 16px 20px max(16px, env(safe-area-inset-bottom)); gap: 8px; }
  .dialog-detail .dialog-header h2 { font-size: 1.8rem; }
  .dialog-header .icon-btn { width: 44px; height: 44px; }
  .detail-meta { margin-bottom: 22px; padding-bottom: 18px; }
  .detail-body { font-size: 1.16rem; line-height: 1.8; }
  .detail-section:has(.share-form), .detail-audio { padding: 18px; }
  .detail-prep { grid-template-columns: 1fr; gap: 4px; padding: 18px; }
  .detail-prep dd { margin-bottom: 12px; }
  .detail-prep dd:last-child { margin-bottom: 0; }
  .detail-actions .btn { flex: 1 1 200px; }
  .compose-path-switch { width: 100%; border-radius: 14px; }
  .compose-path-switch button { flex: 1 1 75px; padding-inline: 9px; border-radius: 10px; }
}
@media (max-width: 380px) {
  .sidebar { padding-inline: 12px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-name { font-size: 1.2rem; }
  .lang-toggle button { padding-inline: 8px; font-size: .76rem; }
  .main { padding-inline: 12px; }
  .prompt-grid { grid-template-columns: 1fr; }
  .scene-footer { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .memory-card:hover, .capture-action:hover, .prompt-card:hover { transform: none; }
}
