/* Открытая карточка рунами: конструктор /cards/new и страница /c/код (card_studio_controller.js, card_view_controller.js).
   Как в демо Card Studio: карточка слева как оттиск на мольберте, настройки справа; на телефоне карточка сверху,
   настройки во вкладках, кнопки сохранения в нижней панели. Шрифты надписей карточки: Cinzel и Marcellus (OFL). */

@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 400 700; font-display: swap; src: url("../fonts/cinzel-normal-latin-ext-U4swwcn.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 400 700; font-display: swap; src: url("../fonts/cinzel-normal-latin-4HpB19A.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Marcellus'; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/marcellus-normal-latin-ext-b7ZwhZG.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Marcellus'; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/marcellus-normal-latin-zKQuygg.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

.cs { max-width: 1260px; margin: 0 auto; padding: 28px 20px 64px; }
.cs-work { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 40px; }
.cs-head { margin-bottom: 28px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.cs-head h1 { font-family: var(--font-display); font-weight: 500; font-size: 34px; margin: 0; }
.cs-head p { margin: 0; color: var(--text-muted); max-width: 56ch; }

.cs-stage { position: sticky; top: calc(var(--cs-top, 72px) + 16px); align-self: start; display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 0; }
.cs-easel { position: relative; width: 100%; display: flex; justify-content: center; }
.cs-easel::before { content: ''; position: absolute; inset: 8% 12%; background: radial-gradient(closest-side, var(--gold-soft), transparent); filter: blur(30px); pointer-events: none; }
.cs-canvas { position: relative; display: block; height: min(74vh, 860px); width: auto; max-width: 100%; aspect-ratio: 9 / 16; border-radius: 18px; box-shadow: 0 30px 80px #0000008c, 0 0 0 1px #ffffff0a; background: var(--night-0); }
.cs-meta { display: flex; gap: 10px; align-items: center; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; flex-wrap: wrap; justify-content: center; }
.cs-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.cs-actions .btn svg { width: 16px; height: 16px; flex: none; }

.cs-panel { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.cs-tabs { display: none; }
.cs-group { display: flex; flex-direction: column; gap: 10px; }
.cs-label { font-size: 11px; letter-spacing: .02em; color: var(--text-muted); font-weight: 600; display: flex; justify-content: space-between; gap: 10px; }
.cs-label em { font-style: normal; letter-spacing: .04em; text-transform: none; color: var(--text-faint); font-weight: 500; }
.cs-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cs-preset { border: 1px solid var(--line); background: var(--night-0); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 6px; font: 600 12px var(--font-ui); text-align: center; color: var(--text-muted); cursor: pointer; }
.cs-preset span { aspect-ratio: 9 / 11; border-radius: 6px; display: grid; place-items: center; font-size: 22px; line-height: 1; font-family: 'Noto Sans Runic', 'Segoe UI Historic', serif; }
.cs-preset[aria-pressed="true"] { border-color: var(--gold); color: var(--text); }
.cs-counter { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cs-bar { flex: 1; height: 3px; border-radius: 3px; background: var(--line); align-self: center; overflow: hidden; max-width: 140px; }
.cs-bar i { display: block; height: 100%; background: var(--gold); width: 0; transition: width .2s; }
.cs-counter.is-near { color: var(--danger); }
.cs-counter.is-near .cs-bar i { background: var(--danger); }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 11px; font: 500 13px var(--font-ui); color: var(--text-muted); display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.cs-chip:hover { color: var(--text); }
.cs-chip[aria-pressed="true"] { border-color: var(--gold); color: var(--text); background: var(--gold-soft); }
.cs-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px #ffffff2e; flex: none; }
.cs-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; background: var(--night-0); }
.cs-seg button { border: 0; background: transparent; border-radius: 7px; padding: 8px 6px; font: 600 13px var(--font-ui); color: var(--text-muted); cursor: pointer; }
.cs-seg button[aria-pressed="true"] { background: var(--night-2); color: var(--text); box-shadow: 0 0 0 1px var(--night-3); }
.cs-hint { font-size: 12px; color: var(--text-faint); margin: 0; }
.cs-slider { display: grid; grid-template-columns: 120px minmax(0, 1fr) 40px; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
.cs-slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-size: 12px; }
.cs-slider input { width: 100%; accent-color: var(--gold); }
.cs-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.cs-toggles label { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.cs-toggles input { accent-color: var(--gold); width: 16px; height: 16px; }
.cs-runes { font-size: 12px; color: var(--text-muted); word-break: break-word; }
.cs-runes b { color: var(--gold); font-weight: 500; letter-spacing: .1em; }
.cs-note { border-left: 2px solid var(--line); padding: 2px 0 2px 12px; color: var(--text-muted); font-size: 13px; margin: 0; }

.cs-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); background: var(--night-2); border: 1px solid var(--night-3); padding: 14px 18px; border-radius: 14px; width: max-content; max-width: min(520px, calc(100vw - 32px)); opacity: 0; pointer-events: none; transition: .25s; z-index: 40; box-shadow: 0 16px 40px #00000080; }
.cs-toast.is-shown { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.cs-toast a { color: var(--gold); }

.cs-modal { position: fixed; inset: 0; z-index: 35; background: #060708d1; display: grid; place-items: center; padding: 16px; }
.cs-modal[hidden] { display: none !important; }
.cs-box { background: var(--night-1); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.cs-box h2 { font-family: var(--font-display); font-size: 26px; font-weight: 500; margin: 0; }
.cs-box p { margin: 0; color: var(--text-muted); font-size: 14px; }
.cs-prog { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.cs-prog i { display: block; height: 100%; width: 0; background: var(--gold); }
.cs-box video { width: 100%; border-radius: 10px; max-height: 50vh; background: #000; }
.cs-link { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 14px; background: var(--night-0); font-size: 13px; }
.cs-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }

/* /c/код */
.cv { min-height: calc(100vh - 140px); display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 16px 48px; background: radial-gradient(ellipse at 50% 30%, var(--night-1), var(--night-0) 70%); }
.cv .cs-canvas { height: min(74vh, 860px); cursor: pointer; touch-action: manipulation; }
.cv-by { color: var(--text-muted); font-size: 13px; }
.cv-by a { color: var(--gold); }
.cv-hidden { max-width: 420px; text-align: center; color: var(--text-muted); padding: 80px 0; }
.cv-small { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 900px) {
  .cs { padding: 12px 16px 120px; }
  .cs-work { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .cs-head { margin-bottom: 8px; }
  .cs-head p { display: none; }
  .cs-head h1 { font-size: 26px; }
  .cs-stage { top: var(--cs-top, 64px); z-index: 5; background: var(--night-0); padding-block: 8px 10px; gap: 8px; margin-inline: -16px; }
  .cs-easel::before { display: none; }
  .cs-stage .cs-canvas { height: min(44vh, 520px); border-radius: 12px; }
  .cs-stage .cs-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: #0c0e10f0; backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .cs-stage .cs-actions .btn { padding: 8px 4px; min-height: 52px; font-size: 12px; flex-direction: column; gap: 3px; border-radius: 12px; white-space: normal; line-height: 1.15; }
  .cs-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .cs-tabs button { border: 1px solid var(--line); background: var(--night-1); border-radius: 10px; padding: 9px 4px; font: 600 13px var(--font-ui); color: var(--text-muted); }
  .cs-tabs button[aria-selected="true"] { color: var(--text); border-color: var(--gold); background: var(--gold-soft); }
  .cs-panel[data-tab] .cs-group[data-tab] { display: none; }
  .cs-panel[data-tab="style"] .cs-group[data-tab="style"],
  .cs-panel[data-tab="text"] .cs-group[data-tab="text"],
  .cs-panel[data-tab="look"] .cs-group[data-tab="look"],
  .cs-panel[data-tab="more"] .cs-group[data-tab="more"] { display: flex; }
  .cs-panel .cs-note { display: none; }
}
@media (max-width: 420px) {
  .cs-slider { grid-template-columns: 96px minmax(0, 1fr) 36px; }
  .cs-toggles { grid-template-columns: 1fr; }
}

/* Мои карточки под конструктором */
.cs-mine { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 22px; }
.cs-mine h2 { font-family: var(--font-display); font-weight: 500; font-size: 26px; margin: 0 0 12px; }
.cs-mine ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.cs-mine li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 14px; background: var(--night-1); min-width: 0; }
.cs-mine li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-family: var(--font-display); font-size: 18px; }

/* Мои карточки /cards (Oleh 28.10) */
.cards-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cards-head .title { margin: 0; }
.cards-list { margin-top: 8px; border-top: 0; padding-top: 0; }
.cards-empty { display: grid; justify-items: start; gap: 12px; margin-top: 8px; }

/* Сургуч и знак печати */
.cs-dot--auto { background: conic-gradient(#8e1f1f 0 25%, #22306e 0 50%, #a8461a 0 75%, #1c4d5c 0); }
.cs-stamp { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.cs-chips + .cs-label { margin-top: 12px; }
