/* Memory map follows the study app's existing paper, ink, and forest palette. */
.memory-dialog {
  --map-ink: var(--ink, #172720);
  --map-sub: var(--sub, #58645c);
  --map-paper: var(--paper, #fff);
  --map-bg: var(--bg, #f5f6f2);
  --map-line: var(--line, #dce2da);
  --map-green: var(--green, #26583d);
  --map-high: #cce3d1;
  --map-mid: #e6ecdf;
  --map-low: #f1e5d7;
  --map-none: #f3f4f0;
  position:fixed;
  inset:0;
  margin:0;
  width:100%;
  height:100%;
  height:100dvh;
  max-width:none;
  max-height:none;
  padding:0;
  border:0;
  background:var(--map-bg);
  color:var(--map-ink);
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-width:thin;
}
.memory-dialog [hidden] { display:none !important; }
.memory-wrap {
  box-sizing:border-box;
  max-width:1100px;
  min-width:0;
  margin:0 auto;
  padding:max(28px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(35px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));
}
.memory-header {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:24px;
}
.memory-heading h2 {
  font-size:clamp(27px,4vw,39px);
  font-weight:680;
  letter-spacing:-.045em;
  line-height:1.1;
  margin:0;
}
.memory-description { color:var(--map-sub); font-size:14px; line-height:1.45; margin:8px 0 0; }
.memory-close {
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  flex:none;
  border:1px solid var(--map-line);
  border-radius:50%;
  background:var(--map-paper);
  font-size:24px;
  line-height:1;
}
.memory-close span { display:block; transform:translateY(-1px); }
.memory-layout {
  display:grid;
  grid-template-columns:minmax(0, .97fr) minmax(0, 1.03fr);
  align-items:start;
  gap:16px;
}
.memory-map,.memory-detail,.memory-disclosure {
  min-width:0;
  border:1px solid var(--map-line);
  border-radius:18px;
  background:var(--map-paper);
}
.memory-map,.memory-detail { padding:18px; }
.memory-head-row {
  min-height:26px;
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:8px;
}
.memory-eyebrow {
  margin:0;
  color:var(--map-sub);
  font-size:11px;
  font-weight:700;
  letter-spacing:.095em;
  text-transform:uppercase;
}
.memory-horizon {
  color:var(--map-green);
  font-weight:700;
  font-size:14px;
  font-variant-numeric:tabular-nums;
}
.memory-control { margin-bottom:15px; }
.memory-range {
  display:block;
  width:100%;
  margin:0;
  min-height:28px;
  accent-color:var(--map-green);
  cursor:pointer;
}
.memory-stops {
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  gap:2px;
  margin-inline:-3px;
}
.memory-stop {
  padding:5px 1px;
  min-height:35px;
  color:var(--map-sub);
  font-size:12px;
  font-weight:630;
  border-radius:7px;
}
.memory-stop[aria-pressed="true"] { background:var(--green-bg, #deece2); color:var(--map-green); }
.memory-stop:hover,.memory-close:hover,.memory-back:hover { background:#eef3ed; }
.memory-note { color:var(--map-sub); font-size:13px; line-height:1.5; margin:9px 0 0; }
.memory-grid {
  display:grid;
  grid-template-columns:repeat(10,minmax(0,1fr));
  gap:4px;
  scroll-margin-top:13px;
}
.memory-cell {
  min-width:0;
  width:100%;
  aspect-ratio:1;
  padding:0;
  border:1px solid transparent;
  border-radius:5px;
  display:grid;
  place-items:center;
  font:400 clamp(14px,2.15vw,21px)/1 "Kanji Mincho",var(--serif,serif);
  background:var(--map-none);
  color:var(--map-ink);
  white-space:nowrap;
}
.memory-cell[data-band="high"],.memory-tone-high { background:var(--map-high); }
.memory-cell[data-band="middle"],.memory-tone-middle { background:var(--map-mid); }
.memory-cell[data-band="low"],.memory-tone-low { background:var(--map-low); }
.memory-cell[data-band="unseen"],.memory-tone-unseen { background:var(--map-none); }
.memory-cell[data-band="unseen"] { color:#626e65; }
.memory-cell:hover { border-color:#91a397; }
.memory-cell[aria-pressed="true"] { border-color:var(--map-green); box-shadow:inset 0 0 0 1px var(--map-green); }
.memory-cell:focus-visible { outline-offset:1px; }
.memory-legend {
  list-style:none;
  display:flex;
  flex-wrap:wrap;
  gap:6px 12px;
  padding:0;
  margin:15px 0 0;
  color:var(--map-sub);
  font-size:11px;
}
.memory-legend li { display:inline-flex; gap:5px; align-items:center; }
.memory-swatch {
  width:12px;
  height:12px;
  display:inline-block;
  border:1px solid #233b2216;
  border-radius:3px;
}
.memory-count {
  font-size:12px;
  color:var(--map-sub);
  margin:12px 0 0;
  min-height:1.3em;
  font-variant-numeric:tabular-nums;
}
.memory-detail { scroll-margin-top:12px; }
.memory-back {
  display:none;
  padding:0 10px;
  min-height:40px;
  border-radius:8px;
  color:var(--map-green);
  font-size:13px;
  font-weight:650;
}
.memory-cardhead { display:flex; align-items:center; min-height:62px; gap:11px; }
.memory-glyph {
  flex:none;
  min-width:62px;
  height:62px;
  padding:3px;
  display:grid;
  place-items:center;
  background:var(--map-bg);
  border:1px solid var(--map-line);
  border-radius:12px;
  white-space:nowrap;
  font:400 40px/1 "Kanji Mincho",var(--serif,serif);
}
.memory-detail-title {
  font-size:clamp(20px,3vw,25px);
  line-height:1.13;
  letter-spacing:-.035em;
  margin:4px 0 0;
  overflow-wrap:anywhere;
}
.memory-facts {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:5px;
  margin:15px 0 16px;
  padding:11px 0;
  border-block:1px solid var(--map-line);
}
.memory-facts dt { font-size:11px; line-height:1.25; color:var(--map-sub); }
.memory-facts dd { font-size:15px; font-weight:700; margin:3px 0 0; font-variant-numeric:tabular-nums; }
.memory-facts > div:first-child dd { color:var(--map-green); }
.memory-empty { margin:13px 0 5px; }
.memory-chart { min-width:0; }
.memory-study {
  min-height:40px;
  padding:7px 13px;
  margin:12px 0 0;
  border:1px solid var(--map-line);
  border-radius:10px;
  color:var(--map-green);
  font-size:13px;
  font-weight:650;
}
.memory-study:hover { background:#eef3ed; }
.memory-insights {
  display:grid;
  grid-template-columns:minmax(0,.97fr) minmax(0,1.03fr);
  gap:16px;
  margin-top:16px;
}
.memory-disclosure { align-self:start; }
.memory-disclosure > summary {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:13px 17px;
  min-height:63px;
  cursor:pointer;
  list-style:none;
  border-radius:17px;
}
.memory-disclosure > summary::-webkit-details-marker { display:none; }
.memory-disclosure > summary::after {
  content:"";
  display:block;
  flex:none;
  width:7px;
  height:7px;
  border-right:1.5px solid var(--map-sub);
  border-bottom:1.5px solid var(--map-sub);
  transform:rotate(45deg);
}
.memory-disclosure[open] > summary::after { transform:rotate(225deg); }
.memory-disclosure-label > strong { font-size:14px; }
.memory-disclosure-label > .memory-note { display:block; margin-top:2px; font-size:12px; }
.memory-insight-body { padding:0 17px 16px; }
.memory-insight-body > :first-child { margin-top:0; }
.memory-insight-caption { color:var(--map-sub); font-size:12px; margin:0 0 10px; }
.memory-activity {
  display:grid;
  grid-template-columns:repeat(14,minmax(0,1fr));
  align-items:end;
  gap:4px;
  list-style:none;
  height:74px;
  margin:0;
  padding:0;
  border-bottom:1px solid var(--map-line);
}
.memory-activity li { position:relative; height:100%; }
.memory-activity-bar {
  position:absolute;
  bottom:0;
  inset-inline:0;
  height:calc(1px + var(--fill) * 68px);
  background:#72a487;
  border-radius:3px 3px 0 0;
}
.memory-activity-axis { display:flex; justify-content:space-between; color:var(--map-sub); font-size:11px; margin:4px 0 0; }
.memory-calibration {
  width:100%;
  margin:9px 0 0;
  border-collapse:collapse;
  font-size:13px;
  font-variant-numeric:tabular-nums;
  text-align:left;
}
.memory-calibration th,.memory-calibration td { padding:7px 2px; border-bottom:1px solid var(--map-line); }
.memory-calibration td:last-child,.memory-calibration th:last-child { text-align:right; }
@media(max-width:760px) {
  .memory-wrap {
    width:min(100%,560px);
    padding:max(14px,env(safe-area-inset-top)) max(13px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(13px,env(safe-area-inset-left));
  }
  .memory-header { margin-bottom:13px; }
  .memory-description { margin-top:4px; }
  .memory-layout,.memory-insights { grid-template-columns:minmax(0,1fr); gap:10px; }
  .memory-insights { margin-top:10px; }
  .memory-map,.memory-detail { padding:12px; }
  .memory-grid { gap:3px; }
  .memory-cell { font-size:clamp(15px,4.1vw,22px); }
  .memory-control { margin-bottom:10px; }
  .memory-legend { margin-top:11px; gap:4px 8px; }
  .memory-count { margin-top:8px; }
  .memory-back { display:flex; align-items:center; margin:-5px 0 5px -5px; }
}
@media(max-width:350px) {
  .memory-grid { grid-template-columns:repeat(8,minmax(0,1fr)); }
}

.memory-calibration-chart {
  display:block;
  width:100%;
  max-height:230px;
  margin:8px 0 3px;
  overflow:visible;
}
.memory-calibration-chart text { fill:var(--map-sub); font:11px var(--sans,sans-serif); }
.memory-calibration-grid { stroke:var(--map-line); }
.memory-calibration-match { stroke:#86988c; stroke-dasharray:4 4; }
.memory-calibration-dot { fill:var(--map-green); stroke:var(--map-paper); stroke-width:1.5; }
