/* «Пасьянс Медичи» (/praktika/pasyans-medichi/): карты, стол, экраны. Токены карт — свои для каждой темы сайта. */
:root {
  --card-face: #f8f0dd; --card-ink: #1d2350; --card-red: #a3263a; --card-edge: rgba(11, 14, 32, .28);
  --card-gild: #a8812c; --card-frame: rgba(201, 162, 58, .8); --card-back: #4b2e83; --card-back-gold: #e8c872;
  --table: radial-gradient(120% 90% at 50% 30%, #1f1a4a 0, #141432 55%, #0b0e20 100%);
  --table-line: rgba(232, 200, 114, .18);
  --card-shadow: 0 2px 4px rgba(3, 4, 14, .35), 0 8px 18px rgba(3, 4, 14, .35);
}
:root[data-theme="light"] {
  --card-face: #fcf5e6; --card-ink: #1d2350; --card-red: #b0283c; --card-edge: rgba(29, 35, 80, .2);
  --card-gild: #9a7420; --card-frame: rgba(201, 162, 58, .75); --card-back: #4b2e83; --card-back-gold: #e8c872;
  --table: radial-gradient(120% 90% at 50% 30%, #ece6f6 0, #e3dcf0 60%, #d8d0ea 100%);
  --table-line: rgba(75, 46, 131, .16);
  --card-shadow: 0 1px 2px rgba(29, 35, 80, .16), 0 6px 14px rgba(29, 35, 80, .12);
}
:root[data-theme="night"] {
  --card-face: #bf9a7e; --card-ink: #3a1d10; --card-red: #a1300f; --card-edge: rgba(0, 0, 0, .45);
  --card-gild: #6e3f17; --card-frame: rgba(201, 138, 76, .6); --card-back: #4a1d0e; --card-back-gold: #c98a4c;
  --table: radial-gradient(120% 90% at 50% 30%, #2a120b 0, #1c0b07 60%, #120705 100%);
  --table-line: rgba(227, 164, 98, .18);
  --card-shadow: 0 2px 4px rgba(0, 0, 0, .5), 0 8px 18px rgba(0, 0, 0, .45);
}

/* ---- карта: .mc + размер .mc--sm (мини, 52) / .mc--md (96) / .mc--lg (180); масть красная — .mc--red */
.mc { --w: 96px; position: relative; display: inline-block; flex: none; width: var(--w); height: calc(var(--w) * 88 / 63);
  border-radius: calc(var(--w) * .085); background: var(--card-face); color: var(--card-ink); isolation: isolate;
  box-shadow: inset 0 0 0 1px var(--card-edge); font-size: var(--w); line-height: 1; user-select: none; -webkit-user-select: none; }
.mc::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: var(--card-shadow); opacity: .9; pointer-events: none; z-index: -1; }
.mc--red { color: var(--card-red); }
.mc--sm { --w: 52px; box-shadow: inset 0 0 0 1px var(--card-edge), inset 0 0 0 3px var(--card-face), inset 0 0 0 4px var(--card-frame); }   /* золотая кайма — как у колоды художника */
.mc--md { --w: 96px; }
.mc--lg { --w: 180px; }
.mc svg { display: block; fill: currentColor; }
/* угловые индексы */
.mc__ix { position: absolute; top: .06em; left: .06em; display: flex; flex-direction: column; align-items: center; width: .2em; }
.mc__ix b { font: 700 .17em/1 var(--body); letter-spacing: -.04em; }
.mc__ix svg { width: .12em; height: .12em; margin-top: .02em; }
.mc__ix--b { top: auto; left: auto; bottom: .06em; right: .06em; transform: rotate(180deg); }
.mc__ix b.is-10 { letter-spacing: -.09em; font-size: .15em; }
/* значки мастей 6–10 */
.mc__pips { position: absolute; inset: .25em .33em; }
.mc__pips svg { position: absolute; width: .14em; height: .14em; margin: -.07em 0 0 -.07em; }
.mc__pips svg.is-dn { transform: rotate(180deg); }
/* фигуры и туз */
.mc__face { position: absolute; inset: .18em .2em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .04em; }
.mc__face .mc__em { width: .5em; height: .56em; color: var(--card-gild); }
.mc__face .mc__fs { width: .14em; height: .14em; flex: none; }
.mc__ace { position: absolute; inset: 0; display: grid; place-items: center; }
.mc__ace .mc__ring { position: absolute; width: .64em; height: .64em; color: var(--card-gild); }
.mc__ace .mc__as { width: .34em; height: .34em; }
/* мини-карта: индекс в центре */
.mc--sm .mc__ix, .mc--sm .mc__pips, .mc--sm .mc__face, .mc--sm .mc__ace { display: none; }
.mc__mini { display: none; }
.mc--sm .mc__mini { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05em; }
.mc--sm .mc__mini b { font: 700 .4em/1 var(--body); letter-spacing: -.04em; }
.mc--sm .mc__mini b.is-10 { font-size: .34em; letter-spacing: -.08em; }
.mc--sm .mc__mini svg { width: .26em; height: .26em; }
/* отметки на мини-карте */
.mc__eff { position: absolute; right: -.1em; bottom: -.08em; min-width: .36em; padding: .04em .06em; border-radius: .2em; background: var(--gold);
  color: var(--btn-text); font: 800 .2em/1.15 var(--ui); text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.mc--md .mc__eff { font-size: .13em; min-width: .26em; }
.mc__dot { position: absolute; left: .07em; top: .07em; width: .13em; height: .13em; border-radius: 50%; border: .025em solid currentColor; }
.mc__dot.is-mob { background: currentColor; }
.mc--target { box-shadow: inset 0 0 0 1px var(--card-edge), 0 0 0 2px var(--gold), 0 0 16px 2px rgba(232, 200, 114, .55); }
:root[data-theme="light"] .mc--target { box-shadow: inset 0 0 0 1px var(--card-edge), 0 0 0 2px #c9a23a, 0 0 14px 2px rgba(201, 162, 58, .5); }
.mc--dim { opacity: .38; }
/* рубашка */
.mc--back { background: none; box-shadow: none; color: var(--card-back-gold); }
.mc--back svg.mc__bk { width: 100%; height: 100%; }
/* колода художника (medici.js deckImg): рисунок поверх; пока грузится — пустая карта цвета бумаги, не загрузился — класс снимается */
.mc__img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; outline: 1px solid var(--card-edge); outline-offset: -1px; pointer-events: none; -webkit-user-drag: none; }
.mc.has-img > :not(.mc__img):not(.mc__eff):not(.mc__dot) { visibility: hidden; }
.mc--back.has-img { background: var(--card-back); }
/* ночью общий фильтр картинок сайта делает светлую бумагу серо-зелёной: сначала темнее, потом сепия — тон как у мини-карт (--card-face) */
:root[data-theme="night"] .mc__img { filter: brightness(.7) sepia(.8) saturate(1.3) hue-rotate(-10deg) brightness(.82); }

/* ================================================================ страница и экраны */
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.med-page .pr-note, .med-sheet .pr-note { font-family: var(--ui); }
.med-why ul { padding-left: 1.1em; margin: 0; display: grid; gap: 8px; }
.med-why h2 { font-size: 1.15rem; }
.med { margin-top: 18px; margin-bottom: 26px; }
.med-tabs { display: flex; gap: 2px; padding: 4px; overflow-x: auto; scrollbar-width: none; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 16px; }
.med-tab { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 4px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: 700 .92rem/1 var(--ui); cursor: pointer; white-space: nowrap; }
.med-tab.is-on { background: var(--gold); color: var(--btn-text); }
:root[data-theme="light"] .med-tab.is-on { background: var(--violet); color: #fff; }
.med-tab:focus-visible, .med-lnk:focus-visible, .med-opt:focus-visible, .med-cardbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.med-panel { min-height: 200px; }
.med-h { font-size: 1.25rem; margin: 6px 0 8px; }
.med-h--card { font-size: 1.15rem; margin-top: 4px; }
.med-sub { color: var(--muted); font: 500 .95rem/1.5 var(--ui); margin: 6px 0 12px; }
.med-note { color: var(--muted); font: 500 .86rem/1.45 var(--ui); margin: 6px 0; }
.med-cap { font: 600 .93rem/1.45 var(--ui); margin: 10px 0; color: var(--text); }
.med-warn, .med-warnline { border-left: 3px solid #e07a5f; padding: 8px 12px; border-radius: 6px; background: rgba(224, 122, 95, .12); font: 600 .9rem/1.45 var(--ui); }
.med-ctl { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.med-ctl--col { flex-direction: column; align-items: stretch; }
.med-ctl--main { justify-content: center; margin: 18px 0 8px; }
.med-lnk { border: 0; background: none; padding: 6px 2px; color: var(--link); font: 700 .92rem/1.2 var(--ui); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.med-lnk--danger { color: #e07a5f; }
.med-x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 1.3rem/1 var(--ui); cursor: pointer; }
.med-plate { position: relative; margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font: 500 .92rem/1.45 var(--ui); }
.med-plate p { margin: 0 0 8px; padding-right: 30px; }
.med-plate .btn { margin: 4px 8px 0 0; }
.med-plate .med-x { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; font-size: 1.1rem; }
.med-plate--soft { border-style: dashed; }
.med-ic { width: 1em; height: 1em; display: inline-block; vertical-align: -.12em; fill: currentColor; }
.med-ic.is-red { color: var(--card-red); }
:root:not([data-theme="light"]) .med-ic.is-red { color: #e0606e; }
:root[data-theme="night"] .med-ic.is-red { color: #d0703f; }
.med-field { display: grid; gap: 6px; margin: 8px 0; font: 600 .92rem/1.4 var(--ui); }
.med-field--row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.med-field input, .med-field textarea, .med-field select, .med-own textarea { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 500 1rem/1.4 var(--ui); }
.med-field--row input, .med-field--row select { width: auto; min-width: 80px; }
.med-check { display: block; position: relative; padding-left: 30px; margin: 10px 0; font: 500 .92rem/1.45 var(--ui); cursor: pointer; }
.med-check input { position: absolute; left: 0; top: 2px; margin: 0; width: 18px; height: 18px; accent-color: var(--gold); }
.med-check small, .med-chips small { color: var(--muted); }
.med-chips { border: 0; padding: 0; margin: 10px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.med-chips legend { font: 700 .85rem/1 var(--ui); color: var(--muted); margin-bottom: 8px; padding: 0; }
.med-chips label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font: 600 .88rem/1.2 var(--ui); cursor: pointer; }
.med-chips label:has(input:checked) { border-color: var(--gold); background: rgba(232, 200, 114, .14); }
:root[data-theme="light"] .med-chips label:has(input:checked) { border-color: var(--violet); background: rgba(75, 46, 131, .08); }
.med-more { margin: 12px 0; border-top: 1px solid var(--line-2); padding-top: 4px; }
.med-more > summary, .med-opts > summary, .med-adv > summary { cursor: pointer; padding: 10px 0; font: 700 .95rem/1.3 var(--ui); color: var(--text); }
.med-opts { margin: 12px 0; padding: 4px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.med-adv { margin: 6px 0 10px; }
.med-spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--gold); vertical-align: -2px; animation: med-rot .8s linear infinite; }
@keyframes med-rot { to { transform: rotate(360deg); } }
.med-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 14px; counter-reset: s; }
.med-steps li { flex: 1; padding: 6px 4px; border-bottom: 3px solid var(--line); color: var(--muted); font: 700 .8rem/1.2 var(--ui); text-align: center; counter-increment: s; }
.med-steps li::before { content: counter(s) ". "; }
.med-steps li.is-on { border-color: var(--gold); color: var(--text); }
.med-steps li.is-done { border-color: rgba(232, 200, 114, .45); }

/* ---- стол */
.med-table { position: relative; padding: 14px 12px; border-radius: 18px; background: var(--table); box-shadow: inset 0 0 0 1px var(--table-line), inset 0 10px 30px rgba(0, 0, 0, .18); isolation: isolate; }
:root[data-theme="light"] .med-table .med-cap { color: #1d2350; }
.med-row { display: flex; gap: 6px; align-items: flex-end; overflow-x: auto; padding: 6px 4px 10px; scroll-behavior: smooth; scrollbar-width: thin; }
.med-row > span { flex: none; }
.med-pile { position: relative; display: inline-block; }
.med-pile::before { content: ""; position: absolute; inset: 0; border-radius: 5px; transform: translate(calc(var(--d) * 1.5px), calc(var(--d) * 1.5px)); background: var(--card-face); box-shadow: inset 0 0 0 1px var(--card-edge), calc(var(--d) * -.8px) calc(var(--d) * -.8px) 0 0 rgba(0, 0, 0, .12); opacity: calc(min(var(--d), 1) * .85); }
.med-pile .mc { transition: transform .28s cubic-bezier(.3, .7, .2, 1); }
.med-pile.is-new .mc { animation: med-in .3s ease-out; }
.med-pile.is-landed .mc { animation: med-land .32s ease-out; }
.mc.is-flying { z-index: 3; }
@keyframes med-in { from { transform: translateY(-14px) scale(.96); opacity: 0; } }
@keyframes med-land { 40% { box-shadow: inset 0 0 0 1px var(--card-edge), 0 0 0 2px var(--gold), 0 0 18px 4px rgba(232, 200, 114, .6); } }
@media (prefers-reduced-motion: reduce) { .med-pile .mc, .med-pile.is-new .mc, .med-pile.is-landed .mc { animation: none; transition: none; } .med-spin { animation: none; } }
.med-mini .med-row { justify-content: flex-start; }
.med-ctl .btn { min-height: 44px; }

/* ---- цепочка по циклам */
.med-cycles { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.med-cyc { flex: 0 1 auto; max-width: 100%; padding: 8px 10px 10px; border-radius: 14px; background: var(--table); box-shadow: inset 0 0 0 1px var(--table-line); }
.med-cyc:nth-child(even) { background: linear-gradient(rgba(232, 200, 114, .05), rgba(232, 200, 114, .05)), var(--table); }
.med-cyc__h { margin: 0 0 6px; font: 700 .78rem/1.2 var(--ui); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
:root[data-theme="light"] .med-cyc__h { color: #4e4866; }
.med-var__c { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; justify-items: center; }
.med-cyc__c { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 369px) { .med-var__c { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.med-cc.is-done .mc { opacity: .45; }
.med-cc.is-now .mc { box-shadow: inset 0 0 0 1px var(--card-edge), 0 0 0 2px var(--teal); }
.med-hexes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 4px; }
.med-hexb { display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: 700 .85rem/1.2 var(--ui); cursor: pointer; }
.med-hexb span { font-weight: 500; font-size: .78rem; color: var(--muted); text-align: center; }
.med-hex { width: 40px; height: 44px; fill: currentColor; }

/* ---- мастер и варианты */
.med-tg { display: flex; gap: 14px; align-items: flex-start; margin: 10px 0; }
.med-tg p { margin: 0 0 6px; font: 500 .93rem/1.45 var(--ui); }
.med-vars { display: grid; gap: 12px; margin: 12px 0; }
.med-var { padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.med-var__h { font: 600 .88rem/1.4 var(--ui); margin-bottom: 10px; }
.med-var .med-ctl { margin-bottom: 0; }
.med-hexpick { margin: 10px 0; }
.med-hexgrid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.med-hexo { display: grid; justify-items: center; padding: 4px 0 2px; border: 1px solid var(--line-2); border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.med-hexo .med-hex { width: 22px; height: 24px; }
.med-hexo small { font: 600 .66rem/1.2 var(--ui); color: var(--muted); }
.med-hexo.is-on { border-color: var(--gold); background: rgba(232, 200, 114, .16); }
.med-hexo:disabled { opacity: .25; cursor: not-allowed; }

/* ---- выбор карты */
.med-grid9 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.med-grid4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 560px) { .med-grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.med-opt { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 12px 8px; min-height: 104px; overflow-wrap: anywhere; hyphens: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: 700 .88rem/1.2 var(--ui); text-align: center; cursor: pointer; }
.med-opt small { font-weight: 500; font-size: .74rem; line-height: 1.3; color: var(--muted); }
.med-opt__e { font-size: 1.6rem; line-height: 1; }
.med-opt:hover { border-color: var(--gold); }
.med-opt:disabled { opacity: .4; cursor: not-allowed; }
.med-inpick h3 { font-size: 1rem; margin: 8px 0; }
.med-deck { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; justify-items: center; }
.med-cardbtn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 6px; }
.med-cardbtn:disabled { opacity: .3; cursor: not-allowed; }
.med-cardbtn.is-sel .mc { box-shadow: inset 0 0 0 1px var(--card-edge), 0 0 0 3px var(--teal); }
.med-cardbtn.is-pin .mc::before { content: "📌"; position: absolute; top: -8px; right: -6px; font-size: 14px; }

/* ---- сегодня */
.med-top { margin-bottom: 10px; }
.med-kick { margin: 0 0 4px; font: 700 .8rem/1.3 var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--gold); overflow-wrap: anywhere; }
:root[data-theme="light"] .med-kick { color: var(--violet); }
.med-prog { margin: 0 0 6px; font: 500 .95rem/1.3 var(--ui); }
.med-pbar { height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.med-pbar span { display: block; height: 100%; background: var(--gold); border-radius: 6px; transition: width .4s; }
.med-mini { margin: 12px 0; padding: 8px 8px 2px; }
.med-mini .med-cap { margin: 0 4px 8px; font-size: .86rem; }
.med-now { display: grid; gap: 14px; align-items: start; margin: 14px 0 16px; }
@media (min-width: 640px) { .med-now { grid-template-columns: auto 1fr; gap: 22px; } }
.med-now__card { display: flex; justify-content: center; }
.med-tag { display: inline-block; margin: 0 0 4px; padding: 4px 10px; border-radius: 999px; background: var(--gold); color: var(--btn-text); font: 800 .78rem/1.2 var(--ui); letter-spacing: .04em; text-transform: uppercase; }
.med-tag--note { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.med-goal { color: var(--gold); font: 700 .92rem/1.3 var(--ui); margin: 4px 0; }
.med-mean p { margin: 0 0 6px; font: 500 .95rem/1.45 var(--ui); }
.med-mean .med-src { color: var(--muted); font-size: .82rem; }
.med-ex { font: 500 .93rem/1.5 var(--ui); margin: 8px 0; }
.med-pace, .med-ifnot { margin: 6px 0; font: 500 .9rem/1.4 var(--ui); }
.med-rc { margin: 0 0 16px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--teal); background: rgba(79, 209, 197, .08); font: 500 .92rem/1.45 var(--ui); }
.med-rc p { margin: 0; }
.med-start { margin: 8px 0; }
.med-start p { font: 500 .95rem/1.5 var(--ui); }
/* кнопка «Было ✓» и полоса-сообщение */
.med-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; justify-content: center; padding: 10px 16px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg0) 40%); }
:root[data-theme="light"] .med-bar { background: linear-gradient(rgba(243, 239, 230, 0), #f3efe6 40%); }
.med-was { width: min(100%, 420px); min-height: 56px; font-size: 1.1rem; justify-content: center; }
body.med-on .vk-sticky, body.med-app .vk-sticky { display: none !important; }
.med-snack { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 75; transform: translateX(-50%); width: min(calc(100% - 24px), 520px); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 10px 14px; border-radius: 16px; background: #1d2350; color: #f3efe6; box-shadow: var(--shadow); font: 600 .9rem/1.35 var(--ui); }
.med-snack.is-up { bottom: calc(84px + env(safe-area-inset-bottom)); }
.med-snack span { flex: 1 1 160px; }
.med-snack button { border: 0; background: none; color: #e8c872; font: 800 .9rem/1 var(--ui); padding: 10px 6px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
:root[data-theme="night"] .med-snack { background: #2a110a; color: #efc9a9; }
:root[data-theme="night"] .med-snack button { color: #e3a462; }
/* шторка */
.med-sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.med-sheet__bg { position: absolute; inset: 0; background: rgba(5, 6, 16, .62); }
.med-sheet__box { position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; padding: 18px 18px max(22px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; background: var(--bg1); box-shadow: var(--shadow); outline: none; animation: med-up .22s ease-out; }
.med-sheet__box h2 { padding-right: 44px; font-size: 1.2rem; overflow-wrap: anywhere; }
.med-sheet__box h3 { font-size: 1rem; margin: 16px 0 6px; }
.med-sheet__x { position: absolute; top: 12px; right: 12px; }
:root[data-theme="light"] .med-sheet__box { background: #fff; }
:root[data-theme="night"] .med-sheet__box { background: #1c0b07; }
@keyframes med-up { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .med-sheet__box { animation: none; } }
@media (min-width: 700px) { .med-sheet { align-items: center; padding: 20px; } .med-sheet__box { border-radius: 22px; padding: 24px 26px 26px; } }
.med-lock, .med-lock body { overflow: hidden; }

/* ---- вступление */
.med-intro { text-align: left; }
.med-fanback { display: block; margin: 0 auto 14px; transform: rotate(-4deg); }
.med-intro .mc--back.med-fanback::before, .med-intro .mc--back.med-fanback::after { content: ""; }
.med-tiles { display: grid; gap: 10px; }
@media (min-width: 700px) { .med-tiles { grid-template-columns: repeat(3, 1fr); } }
.med-tile { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.med-tile h3 { font-size: 1rem; margin: 0 0 6px; }
.med-tile p { margin: 0; font: 500 .9rem/1.5 var(--ui); }

/* ---- финал */
.med-fin { text-align: center; }
.med-fin__fan { position: relative; height: 170px; margin: 6px auto 10px; width: 220px; }
.med-fin__fan .mc { position: absolute; left: 40px; top: 10px; transform-origin: 50% 120%; animation: med-fan .7s ease-out both; }
.med-fin__fan .mc:nth-child(1) { transform: rotate(-14deg); }
.med-fin__fan .mc:nth-child(2) { transform: rotate(-7deg); animation-delay: .05s; }
.med-fin__fan .mc:nth-child(3) { transform: rotate(0); animation-delay: .1s; }
.med-fin__fan .mc:nth-child(4) { left: 120px; transform: rotate(9deg); animation-delay: .25s; }
@keyframes med-fan { from { transform: rotate(0) translateY(14px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .med-fin__fan .mc { animation: none; } }
.med-fin .med-field, .med-fin .med-more { text-align: left; }
.med-fin__ach { display: flex; gap: 12px; align-items: center; text-align: left; margin: 4px 0 16px; padding: 12px 14px; border: 1px solid var(--gold); border-radius: 16px; animation: med-ach-in .4s ease-out both; }
.med-fin__ach p { margin: 0; font-size: .92rem; line-height: 1.45; color: var(--muted); }
.med-fin__ach b { color: var(--text); }
.med-fin__badge { width: 56px; height: 56px; flex: none; border-radius: 50%; }
@keyframes med-ach-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .med-fin__ach { animation: none; } }
.med-feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.med-feed li { display: flex; gap: 10px; align-items: center; font: 500 .88rem/1.4 var(--ui); text-align: left; }

/* ---- дневник */
.med-day { margin: 14px 0; }
.med-day h3 { font-size: 1rem; margin: 0 0 8px; }
.med-mx { width: 100%; border-collapse: collapse; font: 600 .82rem/1.2 var(--ui); }
.med-mx th, .med-mx td { padding: 5px 4px; text-align: center; border-bottom: 1px solid var(--line-2); }
.med-mx th[scope=row] { text-align: left; white-space: nowrap; }
.med-mx th small { color: var(--muted); font-weight: 500; }
.med-mx td { background: rgba(232, 200, 114, calc(var(--a) * .5)); }
.med-mx td.is-zero { color: var(--muted); background: none; }
.med-minors, .med-closers, .med-list, .med-chains { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.med-minors li, .med-closers li { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font: 500 .88rem/1.4 var(--ui); }
.med-closers li div { flex: 1 1 200px; }
.med-list li { font: 500 .92rem/1.4 var(--ui); }
.med-chain { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.med-chain > span:last-child { display: grid; gap: 2px; font: 600 .92rem/1.3 var(--ui); overflow-wrap: anywhere; }
.med-chain small { color: var(--muted); font-weight: 500; }
.med-owndict { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 10px; }
.med-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.med-file { position: relative; cursor: pointer; }
.med-file:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- справка без JavaScript */
.med-static { margin: 24px auto 30px; }
.med-tbl { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font: 500 .92rem/1.45 var(--ui); }
.med-tbl caption { text-align: left; font: 700 .9rem/1.3 var(--ui); padding: 4px 0 8px; color: var(--muted); }
.med-tbl th, .med-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.med-tbl th { white-space: nowrap; }
.med-dl dt { font: 700 .95rem/1.4 var(--ui); margin-top: 10px; }
.med-dl dd { margin: 2px 0 0; font-size: .95rem; line-height: 1.55; }
.med-src li { margin: 4px 0; overflow-wrap: anywhere; }
.med-static details > p, .med-static ol { font-size: .97rem; line-height: 1.6; }

body.med-on { padding-bottom: 84px; }
.med-deckleft { position: relative; margin-left: auto; padding-left: 8px; opacity: .9; }
.med-deckleft b { position: absolute; right: -4px; bottom: -6px; min-width: 22px; padding: 2px 5px; border-radius: 10px; background: var(--bg2); color: var(--text); font: 800 .72rem/1.2 var(--ui); text-align: center; box-shadow: 0 0 0 1px var(--table-line); }
:root[data-theme="light"] .med-deckleft b { background: #fff; color: #1d2350; }

.med-fan { position: relative; height: 170px; width: 260px; margin: 0 auto 10px; }
.med-fan .mc { position: absolute; left: 82px; top: 8px; transform-origin: 50% 150%; animation: med-fan .8s cubic-bezier(.2, .8, .2, 1) both; }
.med-fan .mc:nth-child(1) { transform: rotate(-26deg); }
.med-fan .mc:nth-child(2) { transform: rotate(-13deg); animation-delay: .06s; }
.med-fan .mc:nth-child(3) { transform: rotate(0); animation-delay: .12s; }
.med-fan .mc:nth-child(4) { transform: rotate(13deg); animation-delay: .18s; }
.med-fan .mc:nth-child(5) { transform: rotate(26deg); animation-delay: .24s; }
@media (prefers-reduced-motion: reduce) { .med-fan .mc { animation: none; } }
.med-links { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 2px; justify-items: center; text-align: center; }
#med-keep { margin-top: 18px; }

.med-sheet__box p, .med-sheet__box li, .med-sheet__box dd { font-family: var(--ui); }
body.med-on .to-top { display: none; }
.med-rec { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--gold); color: var(--btn-text); font: 800 .7rem/1.4 var(--ui); letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; }
.med-var--rec { border-color: var(--gold); }
.med-var__f { display: block; margin-top: 4px; color: var(--muted); font-weight: 500; font-size: .8rem; }
.med-evnotes { margin: 8px 0 0; padding-left: 1.2em; display: grid; gap: 4px; font: 500 .88rem/1.4 var(--ui); color: var(--muted); }
.med-evnotes b { color: var(--text); font-weight: 700; margin-right: 4px; white-space: nowrap; }

@media (max-width: 380px) { .med-tab { font-size: .8rem; flex: 1 1 auto; padding: 6px 8px; } }   /* узко: ширина по слову, иначе «Составить» вылезает из своей вкладки */
.med-opt b { font-size: .84rem; overflow-wrap: anywhere; hyphens: auto; max-width: 100%; }
@media (max-width: 359px) { .med-grid9 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
