/* Герметическое Таро · Расклады — чёрное зеркало и золотая линия, как Theme.xaml программы. */

:root {
    --bg: #060507;
    --panel: #0C0A0E;
    --gold: #C9A227;
    --gold-hi: #EBD48C;
    --gold-lo: #6B5518;
    --text: #E4DAC2;
    --dim: #8C8270;
    --btn: #120F16;
    --btn-hover: #1D1726;
    --btn-press: #2A2033;
    --field: #0A0810;
    --sep: #221B12;
    --serif: Georgia, "Times New Roman", "Noto Serif", "DejaVu Serif", serif;
    --gline: linear-gradient(90deg, rgba(201,162,39,0), #C9A227 50%, rgba(201,162,39,0));
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--serif); }
body { -webkit-text-size-adjust: 100%; }
button, input, textarea { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- текст ---------- */

.rubric { font-size: 11px; color: var(--gold); opacity: .85; letter-spacing: .02em; }
.dim { color: var(--dim); }
.gline { height: 1px; background: var(--gline); }
.gline.short { width: 260px; margin: 10px auto 0; }

/* ---------- кнопки и поля ---------- */

.gold-btn {
    font-size: 12.5px; color: var(--gold-hi); background: var(--btn);
    border: 1px solid var(--gold-lo); padding: 8px 14px; cursor: pointer;
    transition: background .12s, border-color .12s;
}
.gold-btn:hover:not(:disabled) { border-color: var(--gold); background: var(--btn-hover); }
.gold-btn:active:not(:disabled) { background: var(--btn-press); }
.gold-btn:disabled { opacity: .35; cursor: default; }
.gold-btn.wide { width: 100%; display: block; }
.gold-btn.select { display: inline-flex; align-items: center; height: 26px; padding: 0 6px 0 8px; font-size: 12px; text-align: left; }
.gold-btn.select > span:not(.rubric) { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-right: 10px; }
.tri { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--gold); flex: none; }

.field {
    width: 100%; background: var(--field); color: var(--text); border: 1px solid var(--gold-lo);
    padding: 6px 7px; font-size: 12px; outline: none; caret-color: var(--gold); border-radius: 0;
}
.field:focus { border-color: var(--gold); }
.field::placeholder { color: var(--gold-lo); font-size: 11px; }
.question { height: 62px; resize: vertical; font-size: 13px; padding: 7px 8px; display: block; }

.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; cursor: pointer; margin-top: 14px; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box { width: 14px; height: 14px; border: 1px solid var(--gold-lo); background: var(--field); position: relative; flex: none; }
.check input:checked + .box::after {
    content: ""; position: absolute; left: 4px; top: 0; width: 4px; height: 8px;
    border: solid var(--gold-hi); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg);
}
.check input:focus-visible + .box { border-color: var(--gold); }

/* ---------- раскладка страницы ---------- */

#app { display: flex; flex-direction: column; min-height: 100vh; }

.top {
    min-height: 54px; background: var(--panel); display: flex; align-items: center;
    justify-content: space-between; gap: 14px; padding: 0 14px 0 22px; position: relative; z-index: 20;
}
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--gline); }
.brand { display: flex; align-items: center; white-space: nowrap; }
.star { width: 18px; height: 18px; }
.brand-name { font-size: 16px; font-weight: bold; color: var(--gold-hi); margin-left: 12px; }
.brand-dot { color: var(--gold-lo); font-size: 16px; margin: 0 10px; }
.brand-sub { font-size: 12px; }
.top-right { display: flex; align-items: center; gap: 0; }
.picker { position: relative; display: flex; align-items: center; margin-right: 18px; }
.picker > .rubric { margin-right: 8px; }
.deck-select { width: 260px; }
.set-select { width: 200px; }
.hint { margin-right: 18px; max-width: 320px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fs { padding: 6px 12px; }

.pop {
    position: absolute; top: calc(100% + 2px); left: 0; background: #0C0A12; border: 1px solid var(--gold);
    padding: 10px; z-index: 40; box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.picker .pop { left: auto; right: 0; }
.picker:first-child .pop { left: 52px; right: auto; }
.deck-pop { width: 380px; }
.set-pop { width: 320px; }
.pop-count { margin: 8px 2px 6px; }
.set-pop .pop-count { margin-top: 0; }
.pop-list { max-height: 460px; overflow-y: auto; outline: none; }
.set-pop .pop-list { max-height: 330px; }
.pop-list .row {
    padding: 9px 12px; margin-bottom: 6px; background: var(--field); border: 1px solid #241D12; cursor: pointer;
    border-left: 2px solid transparent;
}
.pop-list .row:hover { border-color: var(--gold-lo); }
.pop-list .row.on { background: #161122; border-color: var(--gold); }
.row-name { font-size: 12.5px; color: var(--gold-hi); }
.row-note { font-size: 11px; color: var(--dim); margin-top: 2px; }

.body { flex: 1; display: grid; grid-template-columns: 308px 1fr 392px; min-height: 0; }

/* левая колонка */
.left { background: var(--panel); border-right: 1px solid var(--sep); display: flex; flex-direction: column; min-height: 0; }
.spread-pick, .list-close { display: none !important; }
.picker-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.left-top { padding: 18px 20px 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.left-top .field { margin-top: 8px; }
.toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.toggle button {
    font-size: 11.5px; color: var(--gold-lo); background: var(--field); border: 1px solid var(--gold-lo);
    padding: 7px 0; cursor: pointer; position: relative;
}
.toggle button:hover { border-color: var(--gold); color: var(--gold-hi); }
.toggle button.on { background: var(--btn-hover); border-color: var(--gold); color: var(--gold-hi); }
.toggle button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--gline); }

.spread-list { flex: 1; overflow-y: auto; padding: 0 10px 0 14px; outline: none; min-height: 0; overscroll-behavior: contain; }
.spread-list .group { font-size: 11px; color: var(--gold); opacity: .9; margin: 10px 0 7px; padding-bottom: 5px; position: relative; }
.spread-list .group::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--gline); }
.spread-list .item {
    padding: 10px 12px; margin-bottom: 6px; background: var(--field); border: 1px solid #241D12;
    cursor: pointer; position: relative;
}
.spread-list .item:hover { border-color: var(--gold-lo); }
.spread-list .item.on { background: #161122; border-color: var(--gold); }
.spread-list .item.on::before { content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 2px; background: var(--gold); }
.item-title {
    font-size: 13.5px; line-height: 18.5px; color: var(--gold-hi); max-height: 37px; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.item-sub { font-size: 11.5px; color: var(--dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.left-bottom { padding: 16px 20px 20px; }
.left-bottom > .gline { margin-bottom: 16px; }
.left-bottom > label.rubric { display: block; margin-bottom: 7px; }
#dealBtn { margin-top: 16px; }
.left-bottom .gold-btn + .gold-btn, .left-bottom .two { margin-top: 7px; }
.two { display: grid; grid-template-columns: 1fr; gap: 7px; }
.left-bottom .two .gold-btn { margin-top: 0; }

/* стол */
.center {
    display: flex; flex-direction: column; min-width: 0; min-height: 0;
    background: radial-gradient(ellipse 75% 80% at 50% 42%, #15121A 0%, #0A0810 55%, #040305 100%);
}
.table-head { padding: 18px 16px 6px; text-align: center; }
.t-title { font-size: 18px; font-weight: bold; color: var(--gold-hi); max-width: 880px; margin: 0 auto; }
.t-question { margin: 6px auto 0; max-width: 620px; }
.table { position: relative; flex: 1; min-height: 0; margin: 0 6px 6px; }

/* правая колонка */
.right { background: var(--panel); border-left: 1px solid var(--sep); overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.panel { padding: 22px 20px 26px 26px; }
.panel .rubric { margin-bottom: 6px; }
.p-title { font-size: 19px; font-weight: bold; color: var(--gold-hi); margin-bottom: 8px; }
.para { font-size: 13.5px; line-height: 20px; margin-bottom: 10px; white-space: pre-line; overflow-wrap: anywhere; }
.para.dim { color: var(--dim); }
.para.italic { font-style: italic; }
.para.main { font-size: 15px; color: var(--gold-hi); }
.para.accent { color: var(--gold-hi); font-style: italic; }
.para.small { font-size: 12px; }
.p-line { margin: 12px 0 16px; }
.pos-row { font-size: 13px; line-height: 19px; margin-bottom: 7px; }
.pos-head { color: var(--gold-hi); }
.pos-sense { color: var(--dim); }
.mt6 { margin-top: 6px; } .mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; }
.mt18 { margin-top: 18px; } .mt22 { margin-top: 22px; }
.panel .para.mt6 { font-size: 11.5px; }

/* ---------- карты на столе ---------- */

.card { position: absolute; cursor: pointer; transform-origin: 50% 50%; -webkit-tap-highlight-color: transparent; }
.card .shadow { position: absolute; left: 4px; top: 6px; right: -4px; bottom: -6px; background: #000; opacity: .55; }
.card .flip { position: absolute; inset: 0; transform-origin: 50% 50%; }
.card .back, .card .face { position: absolute; inset: 0; }
.card .face { display: none; background: #000; overflow: hidden; }
.card.open .face { display: block; }
.card.open .back { display: none; }
.card .face img { width: 100%; height: 100%; display: block; object-fit: fill; user-select: none; }
.card .face img.rev { transform: rotate(180deg); }
.card .fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--gold-hi); font-size: 12px; padding: 8px; }
.back { background: #07060A; }
.back i { position: absolute; border: 1px solid var(--gold-lo); }
.back .b1 { inset: 0; }
.back .b2 { inset: 5px; border-color: var(--gold); opacity: .75; }
.back .b3 { inset: 9px; opacity: .5; }
.back svg { position: absolute; inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); }
.back svg .g { fill: none; stroke: var(--gold); }
.back svg .gs { fill: none; stroke: var(--gold-lo); }
.card .ring { position: absolute; inset: 0; border: 2px solid var(--gold-hi); display: none; pointer-events: none; }
.card.selected .ring { display: block; }
.card .flip { transition: box-shadow .18s; }
.card:hover .flip { box-shadow: 0 0 26px rgba(201,162,39,.55); }
.card.selected .flip { box-shadow: 0 0 26px rgba(201,162,39,.8); }
.card.selected:hover .flip { box-shadow: 0 0 26px rgba(201,162,39,.95); }
.card .rbadge {
    position: absolute; left: 50%; bottom: -11px; transform: translateX(-50%); display: none;
    background: rgba(10,8,16,.8); border: 1px solid var(--gold-lo); padding: 1px 6px; font-size: 10px; color: var(--gold); pointer-events: none;
}
.card.open.reversed .rbadge { display: block; }

.place { position: absolute; border: 1px dashed var(--gold-lo); background: rgba(12,10,18,.16); display: flex; align-items: center; justify-content: center; }
.place span { color: var(--gold-lo); opacity: .7; }

.label { position: absolute; text-align: center; pointer-events: none; line-height: 1.2; }
.label .num { color: var(--gold); }
.label .name { color: var(--gold-hi); font-style: italic; margin-top: 5px; }

/* ---------- крупный просмотр ---------- */

.viewer { position: fixed; inset: 0; background: #050409; z-index: 60; overflow: auto; }
.v-grid { display: grid; grid-template-columns: 1fr 440px; gap: 30px; position: absolute; inset: 40px 60px; }
.v-frame {
    align-self: center; justify-self: center; background: #07060A; border: 1px solid var(--gold); padding: 6px;
    box-shadow: 0 0 40px rgba(201,162,39,.35); max-height: 100%; overflow: hidden; line-height: 0;
}
.v-frame img { max-height: calc(100vh - 100px); max-width: 100%; display: block; transition: transform .15s; }
.v-side { display: flex; flex-direction: column; min-height: 0; }
.v-name { font-size: 26px; font-weight: bold; color: var(--gold-hi); margin: 6px 0 14px; }
.v-scroll { flex: 1; overflow-y: auto; margin-top: 14px; min-height: 0; }
.v-buttons { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.v-hint { position: fixed; bottom: 12px; left: 0; right: 0; text-align: center; color: var(--gold-lo); }
body.viewing { overflow: hidden; }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: #120F16; border: 1px solid var(--gold); color: var(--gold-hi); padding: 10px 16px; font-size: 13px;
    z-index: 80; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* тонкие полосы прокрутки */
* { scrollbar-width: thin; scrollbar-color: var(--gold-lo) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--gold-lo); border-left: 2px solid var(--panel); border-right: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- широкий экран: всё в одном окне, как в программе ---------- */

@media (min-width: 1200px) {
    html, body { height: 100%; overflow: hidden; }
    #app { height: 100vh; }
    .left, .right, .center { min-height: 0; }
    .body { overflow: hidden; }
}
@media (min-width: 1200px) and (max-height: 760px) {
    .left-bottom { padding-top: 10px; }
    .left-bottom > .gline { margin-bottom: 10px; }
    .question { height: 44px; }
    .two { grid-template-columns: 1fr 1fr; }
}

/* ---------- средний экран: толкование под столом ---------- */

@media (max-width: 1199px) {
    .body { grid-template-columns: 280px minmax(0, 1fr); grid-template-areas: "left center" "left right"; }
    .left { grid-area: left; position: sticky; top: 0; height: 100vh; }
    .center { grid-area: center; }
    .table { flex: none; margin-bottom: 60px; }
    .right { grid-area: right; border-left: 0; border-top: 1px solid var(--sep); overflow: visible; }
    .panel { max-width: 760px; }
    .top { flex-wrap: wrap; padding: 8px 14px; }
    .hint { display: none; }
    .deck-select { width: 220px; }
    .set-select { width: 180px; }
}

/* ---------- телефон: одна колонка, список раскладов поверх ---------- */

@media (max-width: 759px) {
    .top { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 16px; }
    .brand-dot, .brand-sub { display: none; }
    .top-right { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
    .picker { flex-direction: column; align-items: stretch; margin: 0; position: static; }
    .picker > .rubric { margin: 0 0 4px; }
    .deck-select, .set-select { width: 100%; height: 34px; }
    .fs { height: 34px; }
    .pop, .picker:first-child .pop { left: 8px; right: 8px; width: auto; top: auto; }
    .pop-list { max-height: 55vh; }

    .body { display: flex; flex-direction: column; }
    .left { position: static; height: auto; border-right: 0; }
    .spread-pick { display: flex !important; width: auto; margin: 12px 16px 0; height: 40px; gap: 10px; }
    .spread-pick .rubric { flex: none; margin: 0; }
    .spread-pick #pickName { font-size: 13px; }
    .picker-pane { display: none; }
    body.list-open { overflow: hidden; }
    body.list-open .picker-pane {
        display: flex; position: fixed; inset: 0; z-index: 50; background: var(--panel);
    }
    .list-close { display: inline-block !important; padding: 5px 10px; font-size: 12px; }
    .left-top { padding: 14px 16px 10px; }
    .spread-list { padding: 0 12px 20px 16px; }
    .left-bottom { padding: 12px 16px 14px; }
    .left-bottom > .gline { display: none; }
    .two { grid-template-columns: 1fr 1fr; }
    .gold-btn.wide { padding: 10px 14px; }
    .table-head { padding-top: 14px; }
    .table { margin: 0 4px 56px; }
    .panel { padding: 20px 16px 30px; }

    .v-grid { position: static; display: block; padding: 16px 16px 60px; }
    .v-frame { display: block; margin: 0 auto; width: fit-content; max-width: 100%; }
    .v-frame img { max-height: 70vh; }
    .v-side { margin-top: 18px; }
    .v-name { font-size: 21px; }
    .v-scroll { overflow: visible; }
    .v-buttons { position: sticky; bottom: 0; background: #050409; padding: 10px 0; }
    .v-hint { display: none; }
}
