.detail-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  flex: 1;
}

.detail-back {
  align-self: flex-start;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 1.1fr);
  gap: 1.5rem;
  align-items: start;
}

/* Stroke area --------------------------------------------------------- */
.stroke-area {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-card);
}

.svg-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Keep the kanji square and fit on one screen when the viewport is short.
     The 360px subtraction approximates header + back-btn + controls + nav + footer. */
  width: min(100%, calc(100vh - 360px));
  aspect-ratio: 1;
  margin: 0 auto;
  background:
    linear-gradient(to right, transparent calc(50% - .5px), #e5e7eb calc(50% - .5px), #e5e7eb calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), #e5e7eb calc(50% - .5px), #e5e7eb calc(50% + .5px), transparent calc(50% + .5px));
  border: 1px dashed #d1d5db;
  border-radius: 6px;
}
.svg-stage svg {
  width: 100%;
  height: 100%;
}

/* Stroke styling — we layer over the animCJK embedded styles via class
   selectors with higher specificity. Source SVG colours are #ccc for outlines
   and #000 for animated strokes. */
.svg-stage svg.acjk path[clip-path] {
  /* Drawn (active) strokes stay the default black; we keep this rule here so
     downstream overrides can target it. */
  stroke: #1a1a1a;
}
.svg-stage svg.acjk path[clip-path].is-drawing {
  stroke: var(--color-highlight);
  stroke-width: 144;          /* slightly thicker so it pops on big screens */
}
.svg-stage svg.acjk path[clip-path].is-highlight {
  stroke: var(--color-accent);
  stroke-width: 144;
}
/* When a highlight is pinned, dim everything else to ~30%. */
.svg-stage svg.acjk.has-highlight path[clip-path] {
  opacity: .25;
}
.svg-stage svg.acjk.has-highlight path[clip-path].is-highlight {
  opacity: 1;
}

/* Control panel */
.controls {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}
.controls-row .btn { min-height: 2.2rem; padding: .4rem .7rem; }
.controls-icon {
  font-size: 1rem;
  line-height: 1;
}
.speed-group {
  margin-left: auto;
  display: flex;
  gap: .3rem;
  align-items: center;
  font-size: .9rem;
  color: var(--color-muted);
}
.speed-group .btn { min-width: 2.5rem; padding: .35rem .55rem; }

.stroke-progress {
  font-size: .9rem;
  color: var(--color-muted);
}
.stroke-progress strong {
  color: var(--color-text);
  font-weight: 700;
}

/* Per-stroke buttons row for click-to-highlight */
.stroke-palette {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.stroke-palette .btn {
  min-width: 2.2rem;
  padding: .3rem .55rem;
  font-variant-numeric: tabular-nums;
}
.stroke-palette .btn.is-active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* Meta info -------------------------------------------------------- */
.meta-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-card);
}
.meta-block {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.meta-label {
  font-size: .8rem;
  color: var(--color-muted);
  letter-spacing: .04em;
  font-weight: 600;
}
.meta-value {
  font-size: 1.05rem;
  line-height: 1.5;
}
.reading-list {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .6rem;
}
.reading-chip {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: .15rem .55rem;
  border-radius: 4px;
  font-weight: 600;
}
.reading-chip.kunyomi {
  background: #fff;
  border: 1px solid var(--color-accent);
}
.reading-empty {
  color: var(--color-muted);
  font-style: italic;
}
.radical-line {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
}
.radical-char {
  font-size: 1.6rem;
  font-weight: 600;
}
.radical-names {
  color: var(--color-muted);
  font-size: .95rem;
}

/* Memo */
.memo-area {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.memo-area textarea {
  width: 100%;
  min-height: 6rem;
  padding: .6rem .8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  resize: vertical;
  font-family: var(--font-jp);
  font-size: 1rem;
  line-height: 1.5;
}
.memo-area textarea:focus {
  outline: 0;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.memo-hint {
  font-size: .8rem;
  color: var(--color-muted);
}

/* Navigation */
.detail-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .5rem;
}
.detail-nav .btn { min-width: 8rem; }
.detail-nav .nav-spacer { flex: 1; }
