/* ── The card (phaseb.css:185-247 .dk-modal, 342-410 front, 511-660 back, 686-816 kanji,
   1485-1515 phone). Trimmed: no badge pills, no report rules (the motion is in
   player-motion.css). One element per field for both faces: `.is-back` on #card (or on the
   copy of a rated card in flight, `.pl-flight`) turns on the back, two columns when the
   right one has something (`.has-right`), else one. ── */
.dk-modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 36px 44px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  --dk-paper-a1: 0.52;
  --dk-paper-a2: 0.48;
  background:
    radial-gradient(130% 90% at 18% 8%, rgba(74,72,120,0.03), transparent 60%),
    radial-gradient(120% 90% at 88% 100%, rgba(74,72,120,0.045), transparent 55%),
    linear-gradient(176deg, rgba(248,249,253,var(--dk-paper-a1)) 0%, rgba(236,238,247,var(--dk-paper-a2)) 100%);
  -webkit-backdrop-filter: blur(13px) saturate(1.05);
  backdrop-filter: blur(13px) saturate(1.05);
  border: 1px solid rgba(210,213,228,0.6);
  border-radius: 16px 18px 14px 17px / 18px 14px 17px 15px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 2px 6px rgba(74,72,120,0.08),
    0 16px 40px -16px rgba(74,72,120,0.22);
}
/* phaseb.css:240-244: on the dark tiers the paper is nearly opaque, so the dark inks stay legible. */
:root:has(.atmosphere.is-night) .dk-modal,
:root:has(.atmosphere.is-caught-up) .dk-modal {
  --dk-paper-a1: 0.92;
  --dk-paper-a2: 0.90;
}
#card:not(.is-back) #panel { cursor: pointer; }
:is(#card, .pl-flight).is-back.has-right .dk-modal { max-width: 880px; }
.dk-back-only { display: none; }
:is(#card, .pl-flight).is-back .dk-back-only { display: block; }
:is(#card, .pl-flight).is-back .dk-back-only.hidden,
:is(#card, .pl-flight).is-back .dk-back-only:empty { display: none; }  /* a line with no value is not shown (B1) */

.dk-spread { text-align: center; }
:is(#card, .pl-flight).is-back.has-right .dk-spread {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
}
.dk-col-left, .dk-col-right { min-width: 0; }
.dk-col-right {
  text-align: left;
  border-left: 1px solid rgba(74,72,120,0.08);
  padding-left: 32px;
}

/* phaseb.css:300-339: the front's label band keeps its height with no label in it, so the word
   sits where the old card's does. Its one label is "Seen before", on a set-aside word coming
   back: a dusk-rose pill that drifts down once. */
.dk-badge-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-height: 22px;
  margin: -16px 0 12px;
}
:is(#card, .pl-flight).is-back .dk-badge-row { display: none; }
.dk-compound-badge {
  font-family: var(--lav-ui);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--lav-purple);
  background: rgba(74,72,120,0.08);
  border: 1px solid rgba(74,72,120,0.18);
  border-radius: 6px;
  padding: 4px 10px;
}
.dk-reintro-badge {
  color: #8d6a80;
  background: rgba(160,116,142,0.09);
  border-color: rgba(160,116,142,0.20);
  letter-spacing: 1px;
  animation: dk-reintro-settle 720ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes dk-reintro-settle {
  from { opacity: 0; transform: translateY(-5px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .dk-reintro-badge { animation: none; }
}

.dk-source {
  font-family: var(--lav-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--stone);
  margin-bottom: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  min-height: 1em;
}

/* Word group: headword, romaji, reading, and on the back meaning + function line. It is the
   headword's size container on both faces (a block, full width of its column). */
.dk-word-group {
  container-type: inline-size;
  text-align: center;
}
:is(#card, .pl-flight).is-back .dk-word-group {
  padding: 0 0 24px;
  border-bottom: 1px solid var(--lav-hairline);
  margin-bottom: 28px;
}
.dk-surface {
  font-family: var(--lav-jp);
  font-weight: 900;
  /* aag-1956: one line always; a long word steps the size down to fit the column.
     --hw-base: the max size; --hw-len: the character count (headwordFit in the page). */
  --hw-base: 76px;
  white-space: nowrap;
  font-size: var(--hw-base);
  line-height: 1;
  color: var(--dk-hero-ink, #293b66);
  text-shadow: 0 1px 2px rgba(12,20,48,0.22);
  margin: 0;
  letter-spacing: -0.02em;
}
@supports (width: 1cqi) {
  .dk-surface { font-size: min(var(--hw-base), calc(100cqi * 0.95 / var(--hw-len, 1))); }
}
:is(#card, .pl-flight).is-back .dk-surface { --hw-base: 56px; margin: 0 0 8px; }
.dk-surface mark {
  background: none;
  color: var(--lav-accent, #6c5ce7);
  text-decoration: none;
}

/* Romaji hints (shown when the learner's romaji is on; the deck leaves them out otherwise) */
.pb-romaji {
  font-family: var(--lav-ui);
  font-size: 13px;
  font-weight: 500;
  color: #4a8a6e;
  margin: 4px 0 0;
  letter-spacing: 0.02em;
}
.pb-romaji:empty { display: none; }

.dk-reading {
  font-family: var(--lav-jp);
  font-size: 18px;
  font-weight: 500;
  color: #4a8a6e;
  margin: 0 0 8px;
}
.dk-reading:empty { display: none; }
#card:not(.is-back) .dk-reading { margin: 10px 0 0; }
.dk-meaning {
  font-family: var(--lav-ui);
  font-size: 22px;
  font-weight: 500;
  color: var(--lav-ink-soft);
  line-height: 1.2;
  letter-spacing: 0.01em;
  margin: 4px 0 0;
}
.dk-atom-gloss {
  font-family: var(--lav-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--lav-accent, #6c5ce7);
  margin: 2px 0 0;
}

/* Sentence: the front's .dk-vertical look, the back's .dk-sentence look. Plain text, no bold. */
.dk-sent-group { text-align: center; }
.dk-sentence {
  font-family: var(--lav-jp);
  font-size: 17px;
  line-height: 1.7;
  color: var(--lav-ink-soft);
  letter-spacing: 0.01em;
  white-space: pre-line;
  margin: 20px 0 0;
}
:is(#card, .pl-flight).is-back .dk-sent-group { padding-top: 4px; }
:is(#card, .pl-flight).is-back .dk-sentence {
  font-size: 18px;
  line-height: 1.65;
  color: var(--lav-ink);
  letter-spacing: 0;
  margin: 0;
}
.dk-translation {
  font-family: var(--lav-ui);
  font-size: 14px;
  color: var(--lav-ink-muted);
  margin: 8px 0 0;
  line-height: 1.5;
}
.dk-translation:not(:empty)::before { content: '\201c'; color: var(--lav-purple); margin-right: 2px; }
.dk-translation:not(:empty)::after  { content: '\201d'; color: var(--lav-purple); margin-left: 2px; }

/* Right column blocks: Notes, guides, Kanji */
.dk-block { margin: 0 0 26px; min-width: 0; }
.dk-block:last-child { margin-bottom: 0; }
.dk-block-h {
  font-family: var(--lav-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lav-purple);
  margin-bottom: 10px;
  opacity: 0.7;  /* r66: 0.6 (the old app's) measured 2.96:1, under the player's 3:1 bar */
}
.dk-notes-text {
  font-family: var(--lav-ui);
  font-size: 14px;
  line-height: 1.6;
  color: var(--lav-ink);
  margin: 0;
}
.dk-casual-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--lav-jp);
  font-size: 14px;
  line-height: 1.6;
  color: var(--lav-ink);
  overflow-wrap: anywhere;
}

.dk-kanji-row { display: flex; flex-direction: column; gap: 20px; }
.dk-kanji { display: flex; align-items: center; gap: 16px; }
.dk-kanji__char {
  font-family: var(--lav-jp);
  font-weight: 600;
  font-size: 40px;
  line-height: 1;
  color: var(--lav-ink);
  flex-shrink: 0;
}
.dk-kanji__gloss {
  font-family: var(--lav-ui);
  font-weight: 600;
  font-size: 14px;
  color: var(--lav-ink);
  line-height: 1.2;
}
.dk-kanji__parts {
  font-family: var(--lav-jp);
  font-size: 12px;
  color: var(--lav-ink-muted);
  margin-top: 3px;
  line-height: 1.4;
}
.dk-kanji__ateji {
  font-family: var(--lav-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--lav-ink-soft);
}
.dk-kanji__role {
  font-family: var(--lav-ui);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: 1px;
}
.dk-kanji__role--m { color: var(--lav-purple); background: var(--lav-purple-tint); }
.dk-kanji__role--s { color: var(--lav-ink-muted); background: rgba(238,232,249,0.6); }
.dk-kanji__role--sm { color: var(--lav-purple); background: rgba(238,232,249,0.6); }

/* Role tooltip (phaseb.css:764-816). Opens on hover (pointer devices), on tap (`.tip-open`,
   the page's click handler) and on keyboard focus. No fade: shown or not. */
.dk-kanji__role[data-tip] { position: relative; cursor: help; }
.dk-kanji__role[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 200px;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--lav-ui);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  color: var(--lav-ink-soft);
  background: #fff;
  border: 1px solid var(--lav-hairline);
  box-shadow: 0 4px 16px rgba(74,72,120,0.12);
  pointer-events: none;
  z-index: 90;
  white-space: normal;
  display: none;
}
.dk-kanji__role[data-tip]::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1px);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--lav-hairline);
  pointer-events: none;
  z-index: 91;
  display: none;
}
.dk-kanji__role[data-tip].tip-open::after,
.dk-kanji__role[data-tip].tip-open::before,
.dk-kanji__role[data-tip]:focus-visible::after,
.dk-kanji__role[data-tip]:focus-visible::before { display: block; }
@media (hover: hover) {
  .dk-kanji__role[data-tip]:hover::after,
  .dk-kanji__role[data-tip]:hover::before { display: block; }
}

/* ── Card on narrower screens (phaseb.css:1485-1515) ── */
@media (max-width: 900px) {
  .dk-modal { padding: 32px 28px; }
  :is(#card, .pl-flight).is-back .dk-modal { padding: 28px 28px; }
  :is(#card, .pl-flight).is-back.has-right .dk-modal { max-width: 540px; }
  :is(#card, .pl-flight).is-back.has-right .dk-spread { grid-template-columns: 1fr; gap: 24px; }
  .dk-col-right { border-left: none; padding-left: 0; }
  :is(#card, .pl-flight).is-back .dk-surface { --hw-base: 52px; }
  .dk-meaning { font-size: 20px; }
}
@media (max-width: 540px) {
  .dk-modal, :is(#card, .pl-flight).is-back .dk-modal { padding: 28px 20px; border-radius: 16px; }
  .dk-surface { --hw-base: 64px; }
  .dk-sentence { font-size: 15px; }
  :is(#card, .pl-flight).is-back .dk-surface { --hw-base: 48px; }
  .dk-reading { font-size: 18px; }
  .dk-meaning { font-size: 18px; }
  /* A tooltip on a phone spans its kanji's row, not centred on its pill, so it never runs
     off the screen edge. */
  .dk-kanji { position: relative; }
  .dk-kanji__parts, .dk-kanji__role[data-tip] { position: static; }
  .dk-kanji__role[data-tip]::after { left: 0; transform: none; max-width: 100%; box-sizing: border-box; }
  /* r66: and it opens under its row, so it never covers the "Kanji" heading above the first. */
  .dk-kanji__role[data-tip]::after { top: calc(100% + 8px); bottom: auto; }
  .dk-kanji__role[data-tip]::before { display: none !important; }
}


/* The sentence clip's button, the old study page's (phaseb.css:415-444, the stylesheet that
   page loads): 24px under the sentence on the front, 36px on the back (.dk-audio--back). The
   row stays when the button is hidden, as the old page's does. */
.dk-audio {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 24px 0 0;
}
:is(#card, .pl-flight).is-back .dk-audio { margin: 36px 0 0; }
.dk-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(74,72,120,0.15);
  border-radius: 8px;
  color: var(--lav-purple);
  cursor: pointer;
  font-family: var(--lav-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.18s ease;
}
.dk-audio-btn:hover {
  border-color: var(--lav-purple);
  background: rgba(74,72,120,0.06);
}
/* two classes, more specific than .dk-audio-btn's display above, so a hidden button stays hidden */
.dk-audio-btn.hidden { display: none; }
