/* Real-life dialogues (js/dialogues.js) */
.dl-lib, .dl-read { display: grid; gap: 22px; }
.dl-read { max-width: 760px; margin-inline: auto; width: 100%; }
.dl-read .btn svg { width: 20px; height: 20px; vertical-align: -5px; margin-inline-end: 6px; }
.dl-read .btn.big { font-size: 1.05rem; padding: .95em 1.7em; }

/* ---------- library ---------- */
.dl-hero { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 26px 28px; border-radius: 26px;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
              radial-gradient(120% 140% at 100% 100%, color-mix(in srgb, var(--ok) 14%, transparent), transparent 60%), var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); box-shadow: var(--shadow); }
.dl-hero-text { min-width: 0; }
.dl-hero h1 { margin: 0 0 6px; font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.3rem); }
.dl-hero .lead { margin: 0; max-width: 46ch; }
.dl-hero-art { flex: none; width: 150px; height: 150px; object-fit: cover; object-position: 50% 30%; border-radius: 30px; transform: rotate(3deg);
  box-shadow: 0 18px 36px -20px var(--accent); border: 3px solid var(--surface); }
.dl-meter { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); flex-wrap: wrap; }
.dl-meter-bar { flex: 0 1 170px; min-width: 90px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.dl-meter-bar span { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .4s ease; }
.dl-filter { justify-content: flex-start; }
.dl-group { display: grid; gap: 12px; }
.dl-group-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 0; font-size: 1.2rem; }
.dl-group-h .pill { font-family: var(--font-target); }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 16px; }
.dl-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 16px; border-radius: 22px; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease; }
.dl-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--lv, var(--accent)); opacity: .85; }
.dl-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--lv, var(--accent)) 40%, transparent); }
.dl-card h3 { margin: 6px 0 0; font: 700 1.2rem/1.25 var(--font-target); text-align: start; }
.dl-card p { margin: 0; }
.dl-card-tr { font-weight: 500; }
.dl-card-scene { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.dl-card-top { display: flex; align-items: center; justify-content: space-between; }
.dl-ico { width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.5rem; border-radius: 15px; background: color-mix(in srgb, var(--lv, var(--accent)) 16%, var(--surface-2)); }
.dl-ico.big { width: 64px; height: 64px; font-size: 2.1rem; border-radius: 20px; }
.dl-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dl-card.is-done .dl-ico { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ok) 55%, transparent); }

/* ---------- one dialogue ---------- */
.dl-bar { display: flex; align-items: center; justify-content: space-between; }
.dl-head { text-align: center; display: grid; gap: 8px; justify-items: center; }
.dl-head h1 { margin: 4px 0 0; font: 800 clamp(1.7rem, 5vw, 2.4rem)/1.15 var(--font-display); }
.dl-head p { margin: 0; }
.dl-tr { color: var(--muted); font-size: 1.05rem; }
.dl-scene { max-width: 52ch; padding: 10px 16px; border-radius: 16px; background: var(--surface-2); line-height: 1.5; }
.dl-cast { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.dl-who { display: inline-flex; align-items: center; gap: 8px; padding: 4px; padding-inline-end: 12px; border-radius: 999px; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule) 70%, transparent); font-size: .9rem; }
.dl-who bdi { font: 600 .95rem var(--font-target); }
.dl-who .dl-av { width: 28px; height: 28px; font-size: .85rem; }
.dl-who .dl-av svg { width: 17px; height: 17px; }
.dl-modes { justify-self: center; display: flex; width: min(100%, 440px); }
.dl-modes button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: .95rem; padding: .75em 1em; }
.dl-modes svg { width: 18px; height: 18px; flex: none; }
.dl-body { display: grid; gap: 16px; min-width: 0; }
.dl-tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.dl-hint { text-align: center; margin: -6px 0 0; }

/* chat */
.dl-chat { display: grid; gap: 14px; padding: 22px clamp(12px, 3.5vw, 26px); border-radius: 24px; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); box-shadow: var(--shadow); min-width: 0; }
.dl-msg { display: flex; align-items: flex-end; gap: 10px; max-width: min(90%, 580px); min-width: 0; }
.dl-msg.is-a { justify-self: start; }
.dl-msg.is-b { justify-self: end; flex-direction: row-reverse; }
.dl-av { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 700 .95rem/1 var(--font-target); }
.dl-av svg { width: 20px; height: 20px; }
.is-a .dl-av { background: color-mix(in srgb, var(--lv, var(--accent)) 24%, var(--surface-2)); color: var(--ink); }
.is-b .dl-av, .dl-turn-k .dl-av { background: var(--accent); color: var(--accent-ink); }
.dl-col { display: grid; gap: 4px; min-width: 0; justify-items: start; }
.is-b .dl-col { justify-items: end; }
.dl-name { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; color: var(--muted); padding-inline: 8px; }
.dl-bubble { appearance: none; border: 1.5px solid transparent; cursor: pointer; display: grid; gap: 6px; padding: 11px 15px; border-radius: 20px;
  font: inherit; color: var(--ink); max-width: 100%; min-width: 0; text-align: start; transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease; }
.is-a .dl-bubble { background: var(--surface-2); border-end-start-radius: 6px; }
.is-b .dl-bubble { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-end-end-radius: 6px; }
.dl-bubble:hover { border-color: color-mix(in srgb, var(--lv, var(--accent)) 45%, transparent); }
.dl-bubble:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dl-msg.now .dl-bubble { border-color: var(--lv, var(--accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--lv, var(--accent)) 20%, transparent); }
.dl-en { font: 500 clamp(1.02rem, 2.6vw, 1.12rem)/1.5 var(--font-target); text-align: left; overflow-wrap: anywhere; }
.dl-tl { font-size: .92rem; line-height: 1.45; color: var(--muted); text-align: start; padding-top: 6px; overflow-wrap: anywhere;
  border-top: 1px solid color-mix(in srgb, var(--rule) 75%, transparent); }
.dl-msg.enter { animation: dl-in .35s ease both; }
@keyframes dl-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dl-mark { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: .7rem; font-weight: 700; line-height: 1; }
.dl-mark.ok { background: var(--ok-soft); color: var(--ok); }
.dl-mark.miss { background: var(--bad-soft); color: var(--bad); }
.dl-dots3 { display: inline-flex; align-items: center; gap: 5px; padding: 15px 16px; cursor: default; }
.dl-dots3 i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .45; animation: dl-blink 1.1s ease-in-out infinite; }
.dl-dots3 i:nth-child(2) { animation-delay: .15s; }
.dl-dots3 i:nth-child(3) { animation-delay: .3s; }
@keyframes dl-blink { 30% { opacity: 1; transform: translateY(-3px); } }

/* role-play */
.dl-intro { display: flex; align-items: center; gap: 20px; padding: 22px; border-radius: 24px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--lv, var(--accent)) 14%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--lv, var(--accent)) 30%, transparent); box-shadow: var(--shadow); }
.dl-intro img { flex: none; width: 128px; height: 128px; object-fit: cover; object-position: 50% 30%; border-radius: 28px; transform: rotate(-3deg); border: 3px solid var(--surface); }
.dl-intro-text { display: grid; gap: 10px; justify-items: start; min-width: 0; }
.dl-intro h2 { margin: 0; font-size: 1.35rem; }
.dl-intro ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; counter-reset: dl; }
.dl-intro li { position: relative; padding-inline-start: 34px; line-height: 1.45; counter-increment: dl; }
.dl-intro li::before { content: counter(dl); position: absolute; inset-inline-start: 0; top: -1px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--lv, var(--accent)); color: var(--surface); font: 700 .8rem/1 var(--font-target); }
.dl-intro p { margin: 0; }
.dl-progress { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dl-steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.dl-steps li { width: 30px; height: 8px; border-radius: 999px; background: var(--surface-2); transition: background-color .3s ease; }
.dl-steps li.now { background: var(--accent); }
.dl-steps li.ok { background: var(--ok); }
.dl-steps li.miss { background: color-mix(in srgb, var(--bad) 70%, var(--surface-2)); }
.dl-turn { display: grid; gap: 12px; padding: 18px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 50%, var(--rule)); animation: dl-in .3s ease both; }
.dl-turn.is-ok { border-style: solid; border-color: color-mix(in srgb, var(--ok) 60%, var(--rule)); }
.dl-turn.is-miss { border-style: solid; border-color: color-mix(in srgb, var(--bad) 45%, var(--rule)); }
.dl-turn-k { margin: 0; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dl-turn-k .dl-av { width: 30px; height: 30px; }
.dl-turn-k .dl-av svg { width: 18px; height: 18px; }
.dl-opts { display: grid; gap: 10px; }
.dl-opt { min-height: 54px; padding: 12px 16px; border-radius: 16px; font: 500 1.02rem/1.4 var(--font-target); text-align: left; overflow-wrap: anywhere; }
.dl-opt:hover:not(:disabled) { border-color: var(--accent); }
.dl-opt.dim { opacity: .5; }
.dl-opt.right { animation: dl-pop .35s ease; }
@keyframes dl-pop { 50% { transform: scale(1.02); } }
.dl-fb { display: grid; gap: 12px; justify-items: start; }
.dl-fb:empty { display: none; }
.dl-fb p { margin: 0; }
.dl-fb-ok { color: var(--ok); font-weight: 700; font-size: 1.05rem; }
.dl-fb-box { display: grid; gap: 4px; width: 100%; padding: 12px 16px; border-radius: 16px; background: color-mix(in srgb, var(--bad-soft) 70%, var(--surface));
  border-inline-start: 4px solid color-mix(in srgb, var(--bad) 60%, transparent); }
.dl-fb-k { font-weight: 600; }
.dl-fb-en { font: 600 1.06rem/1.45 var(--font-target); text-align: left; }
.dl-fb-tr { color: var(--muted); font-size: .92rem; }
.dl-result { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 22px; background: color-mix(in srgb, var(--ok) 10%, var(--surface-2)); }
.dl-result img { width: 110px; height: 110px; object-fit: cover; border-radius: 22px; flex: none; }
.dl-result-text { display: grid; gap: 6px; justify-items: start; min-width: 0; }
.dl-result p { margin: 0; }
.dl-score { font-size: 1.25rem; font-weight: 700; }
.dl-badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dl-gems { display: inline-block; font-weight: 700; padding: .3em .9em; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.dl-res-acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

/* phrases */
.dl-phrases h2 { margin: 0 0 4px; font-size: 1.2rem; }
.dl-phrases ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 8px; }
.dl-phrases li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--surface-2); min-width: 0; }
.dl-ph { flex: 1; min-width: 0; display: grid; gap: 1px; }
.dl-ph b { font: 600 1.02rem var(--font-target); justify-self: start; overflow-wrap: anywhere; }
.dl-ph span { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }

/* games page card */
.g-dialogues .dl-game-art { width: 100%; height: 120px; object-fit: cover; object-position: 50% 26%; border-radius: 16px; }

@media (max-width: 640px) {
  .dl-hero { padding: 20px; }
  .dl-hero-art { width: 92px; height: 92px; border-radius: 22px; }
  .dl-intro { flex-direction: column; text-align: start; align-items: stretch; padding: 18px; }
  .dl-intro img { width: 84px; height: 84px; border-radius: 22px; align-self: center; }
  .dl-intro .btn.big { justify-self: stretch; }
  .dl-result { flex-direction: column; text-align: center; }
  .dl-result-text { justify-items: center; }
  .dl-res-acts { justify-content: center; }
  .dl-msg { max-width: 94%; gap: 8px; }
  .dl-av { width: 30px; height: 30px; font-size: .85rem; }
  .dl-av svg { width: 17px; height: 17px; }
  .dl-turn { padding: 14px; }
  .dl-steps li { width: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .dl-card, .dl-bubble, .dl-meter-bar span, .dl-steps li { transition: none; }
  .dl-card:hover { transform: none; }
  .dl-msg.enter, .dl-turn, .dl-opt.right, .dl-dots3 i { animation: none; }
}
.pref-calm .dl-card:hover { transform: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.dl-hero-art, .dl-game-art, .dl-intro img, .dl-result img) { filter: brightness(.86); } }
:root[data-theme="dark"] :is(.dl-hero-art, .dl-game-art, .dl-intro img, .dl-result img) { filter: brightness(.86); }
