/*
 * Postcard studio — оформление в дизайн-языке trillionwishes «Paper Deck».
 *
 * Токены (--paper, --ink, --stamp-red, шрифты Caveat/Cormorant/Inter/Special
 * Elite) приходят из paper-deck.css (:root, global) — здесь мы ими только
 * пользуемся. Всё оформление студии заскоуплено под .tw-studio, чтобы не
 * пересекаться с остальной страницей.
 *
 * ВАЖНО: компонент .postcard — это сама открытка (то, что собирают), а не
 * «хром» студии. Он рисуется через --card-* и обязан совпадать с серверным PNG
 * (CardRenderer), поэтому оставлен как есть: своя бумага, свои шрифты
 * (Literata / Caveat / Nunito Sans), свои пропорции. Переоформлен только хром
 * вокруг него: заголовки, чипы, кнопки, панели, поля, шеринг.
 */

.tw-studio {
    /* Переменные, которые нужны компоненту .postcard. --script (рукописный) —
       тот же Caveat, что и в остальном trillionwishes. */
    --script: 'Caveat', cursive;
    --radius-card: 16px;
    --shadow-card: 0 20px 46px -18px rgba(60, 40, 20, .5), 0 2px 4px rgba(60, 40, 20, .1);

    position: relative;
    z-index: 1;
    margin: 8px 0 10px;
    padding: 40px 0 52px;
    border-bottom: 1px dashed var(--rule);
}

.tw-studio .wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 28px;
}

/* hidden обязан скрывать: наши display:flex/grid перебивают [hidden]. */
.tw-studio [hidden] { display: none !important; }

.tw-studio .visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.tw-studio .hint {
    font: italic 400 15px/1.4 'Cormorant Garamond', serif;
    color: var(--ink-faint);
}

/* ------------------------------------------------------------------- hero */

.tw-studio .hero { margin-bottom: 26px; }
.tw-studio .hero h1 {
    font-family: 'Caveat', cursive;
    font-weight: 600;
    font-size: 62px;
    line-height: 1.02;
    color: var(--ink);
    margin: 0 0 6px;
    text-wrap: balance;
}
.tw-studio .hero h1 em {
    font-style: normal;
    color: var(--stamp-red);
}
.tw-studio .hero p {
    font: italic 400 21px/1.5 'Cormorant Garamond', serif;
    color: var(--ink-soft);
    max-width: 60ch;
    margin: 0;
    text-wrap: balance;
}

/* --------------------------------------------------------------- kickers */

.tw-studio .kicker {
    display: inline-flex; align-items: center; gap: 10px;
    font: 500 11px/1 'Inter', sans-serif;
    letter-spacing: 3px; text-transform: uppercase;
    color: var(--ink-faint);
}
.tw-studio .kicker::before {
    content: ""; width: 22px; height: 1px; background: var(--ink-faint); opacity: .5;
}
.tw-studio .mini-label {
    font: 500 10px/1 'Inter', sans-serif;
    letter-spacing: 2px; text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 8px;
}

/* --------------------------------------------------------------- templates */

.tw-studio .templates {
    margin: 0 0 28px;
    display: flex; flex-direction: column; gap: 10px;
}

/* ----------------------------------------------------------------- chips */

.tw-studio .chips {
    display: flex; flex-wrap: wrap; gap: 8px;
}

.tw-studio .chip {
    font: 500 13px/1 'Inter', sans-serif;
    letter-spacing: .2px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid rgba(60, 40, 20, .18);
    border-radius: 2px;
    padding: 9px 13px;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 2px 4px -2px rgba(60, 40, 20, .25);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
}
.tw-studio .chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 6px 10px -4px rgba(60, 40, 20, .35);
}
.tw-studio .chip[aria-pressed="true"] {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
    box-shadow: 0 2px 6px -2px rgba(60, 40, 20, .5);
}
/* «+N ещё» / «Свернуть» — тексто-ссылка, не карточка. */
.tw-studio .chip--link {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--stamp-red);
    font: italic 500 15px/1 'Cormorant Garamond', serif;
    letter-spacing: 0;
    padding: 9px 6px;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}
.tw-studio .chip--link:hover { transform: none; color: var(--stamp-red-deep); }

.tw-studio .chips--sub .chip {
    font-family: 'Cormorant Garamond', serif;
    font-size: 15px;
    font-weight: 500;
}

/* Подкатегории — «уточнение» повода, с линией слева. */
.tw-studio .substep {
    margin-top: 14px;
    padding-left: 16px;
    border-left: 2px solid var(--rule);
    display: flex; flex-direction: column; gap: 10px;
}
.tw-studio .substep__label {
    font: 500 10px/1 'Inter', sans-serif;
    letter-spacing: 2px; text-transform: uppercase;
    color: var(--ink-faint);
}

/* --------------------------------------------------------------- buttons */

.tw-studio .btn {
    font: 500 12px/1 'Inter', sans-serif;
    letter-spacing: 1.5px; text-transform: uppercase;
    padding: 12px 18px;
    border: 0; border-radius: 3px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
    text-decoration: none;
}

/* Главное действие — «восковой» красный рычаг. */
.tw-studio .btn--accent {
    background: linear-gradient(180deg, #b53a2c, #7a2418);
    color: #fff7d8;
    box-shadow: 0 6px 10px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.tw-studio .btn--accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 9px 15px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .22);
    color: #fff7d8;
}
.tw-studio .btn--accent:disabled { opacity: .6; cursor: default; transform: none; }

/* Второстепенное — бумажная кнопка-карточка. */
.tw-studio .btn--ghost {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid rgba(60, 40, 20, .22);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 2px 4px -2px rgba(60, 40, 20, .3);
}
.tw-studio .btn--ghost:hover {
    transform: translateY(-1px);
    color: var(--ink);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 6px 10px -4px rgba(60, 40, 20, .4);
}
.tw-studio .btn--ghost:disabled { opacity: .55; cursor: default; transform: none; }

/* Тёмное действие — чернильный штемпель. */
.tw-studio .btn--dark {
    background: var(--ink);
    color: var(--paper);
    box-shadow: 0 3px 8px -2px rgba(60, 40, 20, .5);
}
.tw-studio .btn--dark:hover { transform: translateY(-1px); color: var(--paper); }
.tw-studio .btn--dark:disabled { opacity: .6; cursor: default; transform: none; }

/* ------------------------------------------------------------ studio grid */

.tw-studio .studio {
    display: grid;
    grid-template-columns: minmax(0, 420px) 1fr;
    gap: 44px;
    align-items: start;
}
@media (max-width: 900px) {
    .tw-studio .studio { grid-template-columns: 1fr; gap: 32px; }
}

/* Левая колонка — превью-открытка, «прикноплена» и не уезжает при прокрутке. */
.tw-studio .studio__preview { position: sticky; top: 20px; }
@media (max-width: 900px) {
    .tw-studio .studio__preview { position: static; }
}

.tw-studio .studio__actions {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-top: 18px;
}

/* Правая колонка — «лист бумаги» с шагами, как заполняемый бланк. */
.tw-studio .studio__steps {
    display: flex; flex-direction: column; gap: 26px;
    background: var(--paper);
    border: 1px solid var(--rule);
    padding: 30px 30px 26px;
    box-shadow: 0 4px 0 -2px #c9bca0, 0 20px 30px -18px rgba(60, 40, 20, .5);
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.15 0 0 0 0 0.12 0 0 0 0 0.08 0 0 0 0.16 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    background-blend-mode: multiply;
}
.tw-studio .studio__steps > div { display: flex; flex-direction: column; gap: 12px; }

.tw-studio .studio__row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 22px;
}
@media (max-width: 520px) {
    .tw-studio .studio__row { grid-template-columns: 1fr; gap: 16px; }
}

.tw-studio .studio__style {
    display: grid; grid-template-columns: auto 1fr; gap: 18px 26px; align-items: start;
}
@media (max-width: 520px) {
    .tw-studio .studio__style { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ inputs */

/* Поля имён. Раньше это была «печатная машинка» на пунктирной строке — красиво,
   но посетитель не понимал, что туда можно печатать. Теперь — явная заполняемая
   рамка (бумажный бланк) с подписью сверху, примером в плейсхолдере и фокус-
   обводкой; шрифт-машинка оставлен ради характера. */
.tw-studio .field { display: flex; flex-direction: column; gap: 6px; }
.tw-studio .field__label {
    font: 500 10px/1 'Inter', sans-serif;
    letter-spacing: 2px; text-transform: uppercase;
    color: var(--ink-faint);
}
.tw-studio .input {
    width: 100%;
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: #fffdf8;
    font: 400 17px/1.3 'Special Elite', 'Courier New', monospace;
    color: var(--ink);
    padding: 11px 13px;
    outline: none;
    box-shadow: inset 0 1px 2px rgba(60, 40, 20, .09);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.tw-studio .input::placeholder { color: var(--ink-faint); opacity: .7; }
.tw-studio .input:focus {
    border-color: var(--ink);
    box-shadow: inset 0 1px 2px rgba(60, 40, 20, .1), 0 0 0 3px rgba(181, 57, 43, .14);
}
.tw-studio .sheet__link .input { font-size: 13px; padding: 8px 10px; background: var(--linen); }

/* ------------------------------------------------------------ palettes */

.tw-studio .swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.tw-studio .swatches > div { text-align: center; }
.tw-studio .swatch {
    width: 42px; height: 42px;
    border: 1px solid rgba(60, 40, 20, .25);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px -1px rgba(60, 40, 20, .35), inset 0 1px 0 rgba(255, 255, 255, .4);
    transition: transform .18s ease, box-shadow .18s ease;
}
.tw-studio .swatch:hover { transform: translateY(-2px) scale(1.05); }
.tw-studio .swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--stamp-red);
}
.tw-studio .swatch__name {
    margin-top: 5px;
    font: 500 9px/1 'Inter', sans-serif;
    letter-spacing: 1px; text-transform: uppercase;
    color: var(--ink-faint);
}

/* ------------------------------------------------------------ scenes */

.tw-studio .scenes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
}
.tw-studio .scene {
    padding: 0;
    border: 1px solid rgba(60, 40, 20, .2);
    background: var(--linen);
    cursor: pointer;
    overflow: hidden;
    line-height: 0;
    box-shadow: 0 2px 4px -2px rgba(60, 40, 20, .35);
    transition: transform .18s ease, box-shadow .18s ease;
}
.tw-studio .scene:hover { transform: translateY(-2px) rotate(-1deg); }
.tw-studio .scene img { width: 100%; height: auto; display: block; }
.tw-studio .scene--on {
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--stamp-red);
}

/* ------------------------------------------------------------ postcard
   Сама открытка. НЕ трогать без сверки с CardRenderer — превью обязано
   совпадать с серверным PNG. */

.postcard {
    --card-bg: #fffdf8;
    --card-panel: #fdf1e0;
    --card-ink: #2c3f47;
    --card-accent: #e8604c;
    --card-soft: #75685a;
    --card-family: 'Literata', Georgia, serif;
    --card-weight: 400;
    --card-size: 17.5px;
    --card-lh: 1.6;

    width: 100%;
    background: var(--card-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 5.2%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background .3s;
}
.postcard--fixed { aspect-ratio: var(--ratio, 4 / 5); }
.postcard__panel {
    background: var(--card-panel);
    border-radius: 14px;
    overflow: hidden;
    flex: none;
    transition: background .3s;
}
.postcard__art {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 320 / 170;
    object-fit: cover;
    background: var(--card-panel);
}
.postcard__body {
    display: flex; flex-direction: column; flex: 1;
    justify-content: center;
    padding: 18px 8px 4px;
    min-height: 0;
}
.postcard__hello { font: 600 30px var(--script); color: var(--card-accent); margin-bottom: 4px; }
.postcard__hello:empty { display: none; }
.postcard__text {
    width: 100%;
    background: transparent; border: none; outline: none; resize: none;
    overflow: hidden; padding: 0; margin: 0;
    font-family: var(--card-family);
    font-weight: var(--card-weight);
    font-size: var(--card-size);
    line-height: var(--card-lh);
    color: var(--card-ink);
}
.postcard__sign { text-align: right; font: 600 22px var(--script); color: var(--card-soft); margin-top: 10px; }

/* ------------------------------------------------------------ progress */

.tw-studio .progress { margin-top: 18px; }
.tw-studio .progress__label {
    display: block;
    font: 500 10px/1 'Inter', sans-serif;
    letter-spacing: 2px; text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 7px;
}
.tw-studio .progress__track {
    height: 6px;
    background: var(--kraft-deep);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(60, 40, 20, .25);
}
.tw-studio .progress__bar {
    height: 100%;
    width: 20%;
    background: linear-gradient(90deg, var(--stamp-red), var(--gold));
    transition: width .4s cubic-bezier(.2, .7, .2, 1);
}

/* ------------------------------------------------------------ teaser */

.tw-studio .teaser {
    background: var(--linen);
    border-left: 3px solid var(--gold);
    padding: 14px 18px;
    box-shadow: 0 8px 18px -14px rgba(60, 40, 20, .4);
}
.tw-studio .teaser__title {
    font: 500 16px/1.3 'Cormorant Garamond', serif;
    color: var(--ink);
    margin-bottom: 2px;
}
.tw-studio .teaser__text {
    font: italic 400 14px/1.4 'Cormorant Garamond', serif;
}
.tw-studio .teaser__text a { color: var(--stamp-red); border-bottom: 1px dotted; }

/* ------------------------------------------------------------ share sheet */

.tw-studio .sheet {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(20, 15, 10, .5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.tw-studio .sheet__box {
    position: relative;
    width: min(420px, 100%);
    background: var(--paper);
    border: 1px solid var(--ink);
    padding: 30px 28px 26px;
    box-shadow: 0 6px 0 -2px #c9bca0, 0 24px 50px rgba(20, 15, 10, .45);
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.15 0 0 0 0 0.12 0 0 0 0 0.08 0 0 0 0.16 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    background-blend-mode: multiply;
}
.tw-studio .sheet__title {
    font-family: 'Caveat', cursive; font-weight: 600; font-size: 34px;
    color: var(--ink); margin: 0 0 4px;
}
.tw-studio .sheet__hint {
    font: italic 400 15px/1.4 'Cormorant Garamond', serif;
    color: var(--ink-soft); margin: 0 0 20px;
}
.tw-studio .sheet__targets { display: flex; gap: 10px; margin-bottom: 16px; }
.tw-studio .sheet__targets .btn { flex: 1; }
.tw-studio .sheet__link { display: flex; gap: 8px; }
.tw-studio .sheet__link .input { flex: 1; }
.tw-studio .sheet__close {
    position: absolute; top: 8px; right: 10px;
    border: 0; background: transparent; cursor: pointer;
    font-size: 20px; line-height: 1; color: var(--ink-faint);
}
.tw-studio .sheet__close:hover { color: var(--stamp-red); }

/* ------------------------------------------------------------ toast */

.tw-studio .toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
    z-index: 3000;
    background: #fff7d8; color: var(--ink);
    border: 1px solid #d9c682;
    padding: 10px 16px;
    font: 500 12px/1 'Inter', sans-serif; letter-spacing: 1px;
    box-shadow: 0 8px 18px rgba(60, 40, 20, .3);
    border-radius: 2px;
}

/* ------------------------------------------------ recipient page (/c/{slug}) */

.tw-studio.greeting { text-align: center; border-bottom: 0; }
.tw-studio .greeting__envelope {
    font: 500 11px/1 'Inter', sans-serif;
    letter-spacing: 3px; text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 20px;
}
.tw-studio .greeting__card {
    width: min(460px, 100%);
    margin: 0 auto;
}
.tw-studio .greeting__actions {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
    margin: 26px 0 10px;
}
.tw-studio .greeting__hint {
    margin: 0 0 30px;
}
.tw-studio .greeting__related {
    margin-top: 40px; padding-top: 26px;
    border-top: 1px dashed var(--rule);
    text-align: left;
}
.tw-studio .greeting__related .kicker { margin-bottom: 16px; }
.tw-studio .related {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
@media (max-width: 760px) { .tw-studio .related { grid-template-columns: 1fr; } }
.tw-studio .related__item {
    display: block;
    background: var(--paper);
    border: 1px solid var(--rule);
    padding: 16px 18px;
    box-shadow: 0 6px 10px -8px rgba(60, 40, 20, .3);
    transition: transform .2s ease, box-shadow .2s ease;
}
.tw-studio .related__item:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 20px -12px rgba(60, 40, 20, .45);
}
.tw-studio .related__text {
    font: 400 16px/1.45 'Cormorant Garamond', serif;
    color: var(--ink); margin: 0;
}
