/* =========================================================
   COTOME 作成画面（index.html）
   共通トークン・ボタン・ロゴは brand.css。ここでは作業机としての組みを扱う。
   左：インデックス付箋のような入力 / 右：ドット紙の作業マットに名刺を留める。
   ========================================================= */

:root {
    --topbar-h: 64px;
    /* フルHDで左に寄りすぎないよう画面幅に合わせて広げる。1行が長くなりすぎないよう600pxで止める */
    --compose-w: clamp(440px, 30vw, 600px);
    --pad: clamp(16px, 3vw, 40px);
}

body {
    font-size: 15px;
}

h1, h2, h3, p, figure, dl, dd, ol, ul {
    margin: 0;
}

ol,
ul {
    padding: 0;
    list-style: none;
}

.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kbd {
    padding: 1px 6px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-2);
    transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--ink);
}

/* ---------- トップバー ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 20px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.3) blur(10px);
    border-bottom: 1px solid var(--line);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 10px;
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.topbar-link:hover {
    color: var(--accent);
}

.topbar .btn-ghost {
    min-height: 40px;
}

.api-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 10px;
    margin: 0 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 12px;
    white-space: nowrap;
}

.api-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink-3);
}

.api-status[data-status="ok"] .api-dot {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}

.api-status[data-status="error"] {
    border-color: var(--danger);
    color: var(--danger);
}

.api-status[data-status="error"] .api-dot {
    background: var(--danger);
}

.api-status[data-status="pending"] .api-dot {
    animation: pulse 1.2s ease-in-out infinite;
}

.icon-moon {
    display: none;
}

:root[data-theme="dark"] .icon-sun {
    display: none;
}

:root[data-theme="dark"] .icon-moon {
    display: block;
}

/* ---------- アカウント（はじめる／利用状況） ---------- */
.account-panel {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 440px);
    align-items: center;
    gap: 20px clamp(20px, 4vw, 56px);
    padding: clamp(24px, 3.5vw, 40px) var(--pad);
    border-bottom: 1px solid var(--line);
    background-color: var(--lav-soft);
    background-image: radial-gradient(color-mix(in srgb, var(--lav) 40%, transparent) 1.1px, transparent 1.5px);
    background-size: 20px 20px;
    scroll-margin-top: var(--topbar-h);
}

.auth-mode-anchor {
    position: absolute;
    top: 0;
    scroll-margin-top: var(--topbar-h);
}

.account-intro {
    display: grid;
    grid-template-columns: clamp(110px, 12vw, 160px) minmax(0, 1fr);
    align-items: center;
    gap: clamp(16px, 2.5vw, 32px);
    max-width: 680px;
    justify-self: end;
}

.account-mascot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        url("assets/mascot-wave.webp") center / 92% no-repeat,
        radial-gradient(circle, var(--surface) 0 64%, transparent 65%);
}

.account-copy {
    display: grid;
    gap: 10px;
}

.account-title {
    font-family: var(--font-display);
    font-size: clamp(21px, 2.3vw, 28px);
    font-weight: 900;
    line-height: 1.4;
}

.account-title span {
    display: inline-block;
}

.account-steps {
    display: grid;
    gap: 6px;
    margin-top: 4px;
}

.account-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
}

.account-steps span {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 13px;
    font-weight: 700;
}

.account-steps li:nth-child(2) span { background: #7a62c9; color: #fff; }
.account-steps li:nth-child(3) span { background: #2b7f66; color: #fff; }

.account-free {
    margin-top: 2px;
    color: var(--ink-2);
    font-size: 14px;
}

.account-main {
    position: relative;
    display: grid;
    gap: 12px;
    width: 100%;
    max-width: 440px;
    padding: 22px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.25s;
}

.account-main::before {
    content: "";
    position: absolute;
    top: -11px;
    left: 50%;
    width: 84px;
    height: 22px;
    background: var(--tape);
    transform: translateX(-50%) rotate(-2deg);
    clip-path: polygon(3% 0, 97% 6%, 100% 94%, 0 100%);
}

.account-panel.is-attention .account-main {
    box-shadow: 0 0 0 4px var(--focus), var(--shadow-md);
}

.account-entry {
    display: grid;
    gap: 12px;
}

.account-entry-title {
    font-size: 18px;
    line-height: 1.4;
    font-weight: 700;
}

.account-entry-title:focus {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.account-entry .auth-note {
    font-size: 12px;
}

.auth-choice,
.social-buttons .btn.auth-choice {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #747775;
    border-radius: 999px;
    box-shadow: none;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
}

.social-buttons .btn.auth-choice {
    font-family: 'Google Sans', var(--font-sans);
    justify-content: flex-start;
    gap: 10px;
}

.auth-choice img {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.auth-choice span {
    flex: 1;
    margin-right: 30px;
    text-align: center;
}

.email-choice {
    position: relative;
    background: var(--surface);
    color: var(--ink);
}

.email-choice .icon {
    position: absolute;
    right: 14px;
    width: 16px;
    height: 16px;
    transition: transform 0.15s;
}

.email-choice[aria-expanded="true"] .icon {
    transform: rotate(180deg);
}

#resetPasswordBtn {
    padding-left: 0;
}

.account-form {
    display: grid;
    gap: 12px;
}

.auth-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    border-radius: 999px;
    background: var(--surface-3);
}

.auth-switch-btn {
    min-height: 40px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 700;
    transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.auth-switch-btn[aria-pressed="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.account-form:not([data-mode]) .auth-switch {
    display: none;
}

.account-field {
    display: grid;
    gap: 5px;
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 700;
}

.account-field input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 14px;
    border: 1.5px solid var(--control-line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 16px;
    font-weight: 400;
}

.account-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
    /* 通常は見えない。強制カラー（Windowsのハイコントラスト）では影と枠の色が消えるので、代わりにこの線が出る */
    outline: 2px solid transparent;
}

.account-hint {
    color: var(--ink-3);
    font-size: 13px;
}

.account-hint--register,
.account-hint--login {
    display: none;
}

.account-form[data-mode="register"] .account-hint--register,
.account-form[data-mode="login"] .account-hint--login {
    display: block;
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
}

.account-submit {
    flex: 1 1 100%;
}

.account-submit-register {
    display: none;
}

.account-form[data-mode="register"] .account-submit-register {
    display: inline;
}

.account-form[data-mode="register"] .account-submit-login {
    display: none;
}

/* モード切替が動いているときは、送信ボタン1つで登録／ログインを行う */
.account-form[data-mode] #registerBtn,
.account-form[data-mode="register"] #resetPasswordBtn {
    display: none;
}

.account-status {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--butter-soft);
    color: var(--ink);
    font-size: 14px;
}

.account-status:empty {
    display: none;
}

.account-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.account-link {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    font-size: 13.5px;
    font-weight: 700;
}

/* 未ログイン時は購入リンク等を出さない（購入にはログインが必要） */
:root:not([data-auth="signed-in"]) .account-tools {
    display: none;
}

/* 確認中：案内を出さずに待つ */
:root[data-auth="checking"] .account-intro,
:root[data-auth="checking"] .account-entry {
    display: none;
}

:root[data-auth="checking"] .account-main::after {
    content: "ログイン状態を確認しています…";
    color: var(--ink-2);
    font-size: 14px;
}

/* 確認中・ログイン後：1行の利用状況チケット */
:root[data-auth="checking"] .account-panel,
:root[data-auth="signed-in"] .account-panel {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 14px;
    padding-bottom: 14px;
    background-image: none;
}

:root[data-auth="signed-in"] .account-intro {
    display: none;
}

:root[data-auth="checking"] .account-main,
:root[data-auth="signed-in"] .account-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    max-width: none;
    padding: 10px 12px 10px 18px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    box-shadow: none;
}

:root[data-auth="checking"] .account-main::before,
:root[data-auth="signed-in"] .account-main::before {
    display: none;
}

:root[data-auth="signed-in"] .account-status {
    position: relative;
    flex: 1 1 360px;
    padding: 6px 0 6px 30px;
    background: transparent;
    font-weight: 600;
}

:root[data-auth="signed-in"] .account-status::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 20px;
    height: 14px;
    border-radius: 3px;
    background:
        radial-gradient(circle at 0 50%, var(--surface) 3px, transparent 3.5px),
        radial-gradient(circle at 100% 50%, var(--surface) 3px, transparent 3.5px),
        var(--mint);
    transform: translateY(-50%);
}

.pending-jobs {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
}

.pending-jobs:empty {
    display: none;
}

.pending-jobs p {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 14px;
    border-left: 4px solid var(--lav);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
}

/* 外部ログイン（無効時は hidden のまま。CSSで表示しない） */
.social-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.social-buttons .btn {
    flex: 1 1 180px;
    min-height: 46px;
    border: 1px solid #747775;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.social-google {
    background: #fff;
    color: #1f1f1f;
}

.social-apple {
    background: #000;
    color: #fff;
}

.auth-note,
.auth-divider {
    color: var(--ink-2);
    font-size: 13.5px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--line);
}

/* ---------- スマホ用のミニタブ ---------- */
.mobile-tabs {
    display: none;
}

/* ---------- レイアウト ---------- */
.workspace {
    display: grid;
    /* 中央の0幅の列は境目（.compose-splitter）。帯は左右にはみ出して重なり、既存の境界線の見た目を保つ */
    grid-template-columns: var(--compose-w) 0 minmax(0, 1fr);
    align-items: start;
}

/* ---------- 入力欄の幅を変える境目（PCのみ。compose-splitter.js） ---------- */
.compose-splitter {
    position: sticky;
    top: var(--topbar-h);
    z-index: 5;
    width: 10px;
    height: calc(100vh - var(--topbar-h));
    height: calc(100dvh - var(--topbar-h));
    margin: 0 -5px;
    cursor: col-resize;
    touch-action: none;
}

/* 当たり判定は10px、見える線は中央の細線と取っ手 */
.compose-splitter::before {
    content: "";
    position: absolute;
    inset: 0 4px;
    background: transparent;
    transition: background-color 0.15s ease;
}

.compose-splitter::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 36px;
    border-radius: 999px;
    background: var(--line-strong);
    transform: translate(-50%, -50%);
    transition: background-color 0.15s ease;
}

.compose-splitter:hover::before,
.compose-splitter:focus-visible::before,
.compose-splitter.is-dragging::before {
    background: var(--accent);
}

.compose-splitter:hover::after,
.compose-splitter:focus-visible::after,
.compose-splitter.is-dragging::after {
    background: var(--accent);
}

.compose-splitter:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    box-shadow: 0 0 0 4px var(--focus);
}

/* ドラッグ中は本文の文字選択とポインターの形の揺れを止める */
body.is-resizing-compose {
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
}

/* ---------- 入力パネル ---------- */
.compose {
    position: sticky;
    top: var(--topbar-h);
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h));
    height: calc(100dvh - var(--topbar-h));
    background: var(--surface);
    border-right: 1px solid var(--line);
    scroll-margin-top: calc(var(--topbar-h) + 52px);
    /* 幅は境目で変えられるので、中の並びは画面幅でなくパネルの幅で切り替える */
    container: compose / inline-size;
}

.compose-scroll {
    flex: 1;
    overflow-y: auto;
    /* 入力欄はログイン欄の下から始まり、ページを下まで送るまでは下端が画面の外にはみ出す。そのはみ出した分に
       生成ボタンの帯（下端に固定）が重なるので、端まで送ったホイールはページへ引き継ぎ、入力欄を上端の固定位置まで
       上げて最後の欄まで見せる（containにすると、ホイールを入力欄の上で回す限り最後の欄が帯の裏に残る） */
    scrollbar-gutter: stable;
    padding: 6px 0 12px;
}

.compose-guide {
    padding: 16px 20px 8px;
    font-size: 14px;
    color: var(--ink-2);
    line-height: 1.7;
}

.compose-guide-title { color: var(--ink); font-weight: 700; font-size: 17px; }
.draft-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; margin-top: 10px; }
#draftStatus { flex: 1 1 100%; font-size: 13px; }
#draftStatus[data-state="error"],
#draftStatus[data-state="delete-error"],
#draftStatus[data-state="unverified"] { color: var(--accent); }
.draft-note { font-size: 12px; }
.step-status { max-width: 48%; overflow: hidden; text-overflow: ellipsis; }

.step {
    --tab: var(--pink-soft);
    --tab-ink: var(--accent-strong);
    position: relative;
    margin: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.step:nth-of-type(2) { --tab: var(--lav-soft); --tab-ink: #6a4fc0; }
.step:nth-of-type(3) { --tab: var(--mint-soft); --tab-ink: #26745d; }
.step:nth-of-type(4) { --tab: var(--butter-soft); --tab-ink: #7d6000; }

:root[data-theme="dark"] .step:nth-of-type(2) { --tab-ink: var(--lav); }
:root[data-theme="dark"] .step:nth-of-type(3) { --tab-ink: var(--mint); }
:root[data-theme="dark"] .step:nth-of-type(4) { --tab-ink: var(--butter); }

.step[open] {
    box-shadow: inset 4px 0 0 var(--tab), var(--shadow-sm);
}

.step-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 10px 16px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.step-head::-webkit-details-marker {
    display: none;
}

.step-head:hover .step-title {
    color: var(--accent);
}

.step-no {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--tab);
    color: var(--tab-ink);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.step-title {
    font-family: var(--font-display);
    font-size: 16.5px;
    font-weight: 900;
    transition: color 0.15s;
}

.step-status {
    margin-left: auto;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 12px;
    white-space: nowrap;
}

.step-chevron {
    width: 16px;
    height: 16px;
    color: var(--ink-3);
    transition: transform 0.2s var(--ease);
}

.step:not([open]) .step-chevron {
    transform: rotate(-90deg);
}

.step-body {
    display: grid;
    gap: 16px;
    padding: 0 18px 20px;
}

.step-lead {
    color: var(--ink-3);
    font-size: 13px;
}

/* フォーム */
.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.field--full {
    grid-column: 1 / -1;
}

.field label,
.field-label-row label {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
}

.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.counter {
    color: var(--ink-3);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.field input,
.field textarea,
.revise-input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1.5px solid var(--control-line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.field textarea,
.revise-input {
    resize: vertical;
    min-height: 84px;
    line-height: 1.65;
}

.field input::placeholder,
.field textarea::placeholder,
.revise-input::placeholder {
    color: var(--ink-3);
    /* 入力例の文字も4.5:1以上にする。ブラウザー既定の薄さも打ち消す */
    opacity: 1;
}

.field input:hover,
.field textarea:hover,
.revise-input:hover {
    border-color: var(--ink-3);
}

.field input:focus,
.field textarea:focus,
.revise-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus);
    /* 通常は見えない。強制カラー（Windowsのハイコントラスト）では影と枠の色が消えるので、代わりにこの線が出る */
    outline: 2px solid transparent;
}

.field select,
.revise select,
.auth-fields select {
    max-width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1.5px solid var(--control-line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: inherit;
}

.hint {
    color: var(--ink-3);
    font-size: 12.5px;
}

/* QRの生成：チェックをオンにしたときだけ選択肢を出す */
.qr-field {
    gap: 8px;
}

.field .qr-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.field .qr-toggle input {
    width: 18px;
    min-height: 0;
    height: 18px;
    padding: 0;
    accent-color: var(--accent);
}

.qr-options {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
}

.qr-options[hidden] {
    display: none;
}

.qr-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
}

.qr-choice {
    display: grid;
    gap: 4px;
}

/* 選択肢（レイアウト・プリセット） */
.choice-grid {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.choice-grid--layout {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.choice-grid--preset {
    grid-template-columns: 1fr 1fr;
}

/* 用途（名刺・ショップカード等）。2列×2行の小さなカード型の選択肢。選択中は手順の見出しと同じ色（--tab） */
.purpose-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-width: 0;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

.purpose-legend {
    grid-column: 1 / -1;
    margin-bottom: 2px;
    padding: 0;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
}

.purpose-option {
    position: relative;
    display: grid;
    gap: 2px;
    padding: 9px 12px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.purpose-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.purpose-option:hover {
    border-color: var(--line-strong);
}

.purpose-option:has(input:checked) {
    border-color: var(--tab-ink);
    background: var(--tab);
    box-shadow: 2px 2px 0 var(--accent-line);
}

.purpose-option:has(input:focus-visible) {
    /* 選んだ状態と見分けられるよう、ほかの選択肢と同じ枠線で示す */
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.purpose-name {
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

.purpose-option:has(input:checked) .purpose-name {
    color: var(--tab-ink);
}

.purpose-desc {
    color: var(--ink-3);
    font-size: 12px;
    line-height: 1.5;
}

/* 用途別の欄は .field の display:grid より優先して隠す（purpose-ui.js が hidden を切り替える） */
.compose [data-purpose][hidden] {
    display: none;
}

.layout-option,
.preset {
    position: relative;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.layout-option input,
.preset input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.layout-option:hover,
.preset:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.layout-option:has(input:checked),
.preset:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 2px 2px 0 var(--accent-line);
}

.layout-option:has(input:focus-visible),
.preset:has(input:focus-visible) {
    /* 選んだ状態と見分けられるよう、ほかの部品と同じ枠線で示す（地の色と3:1以上） */
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.layout-option {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 10px 4px 9px;
    text-align: center;
}

.layout-figure {
    width: 100%;
    max-width: 72px;
    height: auto;
    margin-bottom: 4px;
}

.layout-figure rect {
    stroke-width: 1.2;
}

.lf-front {
    fill: var(--surface-3);
    stroke: var(--ink-2);
}

.lf-back {
    fill: none;
    stroke: var(--ink-3);
    stroke-dasharray: 2 1.6;
}

.layout-figure text {
    fill: var(--ink-2);
    font-size: 7px;
    font-weight: 700;
    text-anchor: middle;
}

.layout-option:has(input:checked) .lf-front {
    fill: var(--accent);
    stroke: var(--accent);
}

.layout-option:has(input:checked) .lf-back {
    stroke: var(--accent);
}

.layout-option:has(input:checked) .layout-figure text:first-of-type {
    fill: var(--accent-ink);
}

.layout-name {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
}

.layout-desc {
    color: var(--ink-3);
    font-size: 11px;
    line-height: 1.35;
}

.preset {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 10px 11px;
    min-width: 0;
}

.preset-swatch {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sw1) 0 50%, var(--sw2) 50% 100%);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 2px var(--surface);
}

.preset-swatch--none {
    background: repeating-linear-gradient(135deg, transparent 0 4px, var(--line-strong) 4px 5px);
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

.preset-text {
    display: grid;
    min-width: 0;
    line-height: 1.4;
}

.preset-name {
    font-size: 13.5px;
    font-weight: 700;
    /* 長い名前（「写真・イラストを主役に」）を文節の切れ目で折り返す */
    word-break: auto-phrase;
}

.preset-desc {
    color: var(--ink-3);
    font-size: 11.5px;
    /* 説明は選ぶ手がかりなので、途中で切らずに最後まで見せる。折り返しは文節の切れ目で */
    word-break: auto-phrase;
}

.preset-loading {
    grid-column: 1 / -1;
    color: var(--ink-3);
    font-size: 13px;
}

/* 選択中プリセットの指示本文（水色・点線枠） */
.preset-prompt {
    --pp-bg: #eaf5fc;
    --pp-line: #5f9fc6;
    --pp-title: #1d5a80;
    display: grid;
    gap: 8px;
    padding: 12px 14px 12px;
    border: 1.5px dashed var(--pp-line);
    border-radius: var(--radius);
    background: var(--pp-bg);
    animation: pop 0.2s var(--ease);
}

:root[data-theme="dark"] .preset-prompt {
    --pp-bg: #1c2e3b;
    --pp-line: #6fa9cc;
    --pp-title: #a9d6f2;
}

.preset-prompt-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
}

.preset-prompt-title {
    margin: 0;
    color: var(--pp-title);
    font-size: 13px;
    font-weight: 700;
}

.preset-prompt-name {
    padding: 0 8px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 700;
}

.preset-prompt-body {
    margin: 0;
    color: var(--ink);
    font-size: 13.5px;
    line-height: 1.75;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.preset-prompt-body.is-collapsed {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.preset-prompt-body.is-unavailable {
    color: var(--ink-2);
}

.preset-prompt-toggle {
    justify-self: start;
    min-height: 32px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--pp-title);
    font-size: 13px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.preset-prompt-note {
    margin: 0;
    color: var(--ink-2);
    font-size: 12px;
}

.preset-prompt-none {
    margin: -4px 0 0;
}

/* SNS欄（行の追加・削除） */
.social-field {
    margin: 0;
    padding: 0;
    border: 0;
}

.social-legend {
    padding: 0;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
}

.social-legend small {
    margin-left: 4px;
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 600;
}

.social-list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.social-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 6px;
}

.social-remove {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-2);
}

.social-remove:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.social-remove .icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.social-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* 作成・修正に使える回数 */
.compose-credit {
    margin: 0;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
}

.compose-credit[data-state="empty"] {
    color: var(--danger);
}

.revise-credit-note a {
    margin-left: 4px;
}

/* ラフの裏面：SNSが多くても枠からはみ出さない */
.draft-body--back .draft-contact {
    max-width: 100%;
    max-height: 42%;
    overflow: hidden;
}

.draft-body--back .draft-small {
    overflow-wrap: anywhere;
}

/* 画像スロット */
.slot-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.slot {
    position: relative;
    min-width: 0;
}

.slot-drop {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    overflow: hidden;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--ink-3);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.slot-drop:hover,
.slot.is-dragover .slot-drop {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.slot input:focus-visible + .slot-drop {
    box-shadow: 0 0 0 3px var(--focus);
    border-color: var(--accent);
    /* 通常は見えない。強制カラー（Windowsのハイコントラスト）でフォーカスの位置を示す */
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.slot-empty {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px;
    line-height: 1.25;
}

.slot-empty .icon {
    width: 20px;
    height: 20px;
    margin-bottom: 3px;
}

.slot-empty b {
    color: var(--ink);
    font-size: 12px;
}

.slot-empty small {
    font-size: 10.5px;
}

.slot-img {
    position: absolute;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
    padding: 8px;
    object-fit: contain;
    background: var(--surface);
}

.slot-img--cover {
    padding: 0;
    object-fit: cover;
}

.slot.has-file .slot-img {
    display: block;
}

.slot.has-file .slot-drop {
    border-style: solid;
    border-color: var(--line-strong);
}

.slot-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    display: none;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--ink);
    color: var(--surface);
}

.slot-remove .icon {
    width: 12px;
    height: 12px;
    stroke-width: 2.6;
}

.slot.has-file .slot-remove {
    display: grid;
}

.slot-remove:hover {
    background: var(--danger);
}

.extra {
    display: grid;
    gap: 10px;
    padding-top: 14px;
    border-top: 1.5px dashed var(--line);
}

.extra-title {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
}

.extra-title small {
    margin-left: 6px;
    color: var(--ink-3);
    font-weight: 400;
}

.slot--mini .slot-empty .icon {
    width: 16px;
    height: 16px;
    margin: 0;
}

/* 生成ボタン */
.compose-footer {
    position: sticky;
    bottom: 0;
    display: grid;
    gap: 10px;
    padding: 14px 20px 16px;
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 18px -14px rgba(60, 40, 30, 0.35);
}

/* 生成済みのとき、生成ボタンは新規作成なので修正の場所を案内する */
.compose-revise-hint {
    color: var(--ink-2);
    font-size: 12.5px;
    line-height: 1.5;
}

.compose-revise-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.btn-generate {
    width: 100%;
    min-height: 54px;
    font-size: 16px;
    letter-spacing: 0.04em;
}

.btn-generate .icon {
    width: 20px;
    height: 20px;
}

.btn-generate .kbd {
    margin-left: 6px;
    font-size: 10.5px;
    letter-spacing: 0;
}

.btn-generate:disabled .icon {
    animation: spin 1.4s linear infinite;
}

.compose-auth-hint {
    display: none;
    color: var(--ink-2);
    font-size: 13px;
    text-align: center;
}

:root[data-auth="signed-out"] .compose-auth-hint {
    display: block;
}

/* ---------- スタジオ（右側の作業マット） ---------- */
.studio {
    display: grid;
    gap: 28px;
    align-content: start;
    min-width: 0;
    min-height: calc(100vh - var(--topbar-h));
    padding: 32px var(--pad) 48px;
    background-color: var(--mat);
    background-image: radial-gradient(var(--dot) 1.1px, transparent 1.5px);
    background-size: 22px 22px;
}

.stage {
    scroll-margin-top: calc(var(--topbar-h) + 56px);
    outline: none;
}

.stage-panel {
    display: none;
    animation: rise 0.35s var(--ease);
}

.stage[data-state="idle"] .stage-idle,
.stage[data-state="loading"] .stage-loading,
.stage[data-state="result"] .stage-result {
    display: grid;
    gap: 24px;
}

.stage-head {
    display: grid;
    gap: 6px;
    max-width: 680px;
}

.badge {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 11px;
    letter-spacing: 0.08em;
}

.stage-title {
    font-family: var(--font-display);
    font-size: clamp(22px, 2.4vw, 30px);
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.stage-note {
    color: var(--ink-2);
    font-size: 14.5px;
}

/* 表裏の並び（名刺をテープで留める） */
.pair {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(24px, 4vw, 56px);
    padding: clamp(16px, 3vw, 36px) 0 clamp(8px, 2vw, 20px);
}

.pair-item {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 14px;
}

.pair-item::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    z-index: 2;
    width: 64px;
    height: 20px;
    background: var(--tape);
    transform: translateX(-50%) rotate(-3deg);
    clip-path: polygon(3% 0, 97% 6%, 100% 94%, 0 100%);
}

.pair-item + .pair-item::before {
    background: var(--tape-alt);
    transform: translateX(-50%) rotate(4deg);
}

.pair-item figcaption {
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.2em;
}

/* ラフ */
.draft,
.skeleton {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: var(--paper);
    color: var(--paper-ink);
    box-shadow: var(--shadow-card);
}

.draft--landscape,
.skeleton--landscape {
    width: clamp(240px, 30vw, 364px);
    aspect-ratio: 91 / 55;
}

.draft--portrait,
.skeleton--portrait {
    width: clamp(150px, 18vw, 220px);
    aspect-ratio: 55 / 91;
}

.draft-bg {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
    opacity: 0.35;
}

.draft-body {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    padding: 9% 9%;
    font-family: var(--font-sans);
}

.draft--portrait .draft-body {
    padding: 14% 11%;
}

.draft-body p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.draft-top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.draft-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.draft--portrait .draft-main {
    justify-items: start;
}

.draft-company {
    min-width: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.draft-company--lg {
    font-size: 14px;
    text-align: center;
}

.draft-role {
    color: #6d685f;
    font-size: 10px;
}

.draft-name {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.1em;
    line-height: 1.3;
}

.draft--portrait .draft-name {
    font-size: 19px;
}

.draft-small {
    color: #6d685f;
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
}

.draft-contact {
    display: grid;
    gap: 1px;
    padding-top: 6px;
    border-top: 1px solid #e3ddd0;
}

.draft-body--back {
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.draft-free {
    max-width: 100%;
    color: #57534b;
    font-size: 9.5px;
    line-height: 1.5;
    white-space: pre-line !important;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.draft-logo {
    max-width: 44px;
    max-height: 22px;
    object-fit: contain;
}

.draft-logo--lg {
    max-width: 60%;
    max-height: 28%;
}

.draft-icon {
    width: 38px;
    height: 38px;
    margin-bottom: 6px;
    border-radius: 50%;
    object-fit: cover;
}

.is-placeholder {
    color: #b3ad9f !important;
    font-weight: 500;
}

/* 空状態のヒント（付箋） */
.idle-tips {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.idle-tips li {
    position: relative;
    display: grid;
    gap: 4px;
    padding: 16px 16px 18px;
    border-radius: 4px 4px 14px 4px;
    background: var(--butter-soft);
    color: var(--ink-2);
    font-size: 13.5px;
    box-shadow: var(--shadow-sm);
    transform: rotate(-0.8deg);
}

.idle-tips li:nth-child(2) {
    background: var(--lav-soft);
    transform: rotate(0.6deg);
}

.idle-tips li:nth-child(3) {
    background: var(--mint-soft);
    transform: rotate(-0.4deg);
}

.idle-tips b {
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 900;
}

.idle-tip-no {
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

/* 生成中 */
.skeleton {
    background: linear-gradient(100deg, var(--paper) 30%, #f3ece0 50%, var(--paper) 70%);
    background-size: 300% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
}

.skeleton::before {
    content: "";
    position: absolute;
    inset: 12%;
    border-radius: 2px;
    background:
        linear-gradient(#ebe3f6, #ebe3f6) 0 0 / 40% 7% no-repeat,
        linear-gradient(#f2ece2, #f2ece2) 0 45% / 70% 12% no-repeat,
        linear-gradient(#e2f2ec, #e2f2ec) 0 100% / 55% 5% no-repeat;
}

.skeleton .crop {
    position: absolute;
    inset: 6px;
    border: 1px dashed rgba(194, 65, 45, 0.35);
    border-radius: 2px;
}

.loading-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.elapsed {
    color: var(--ink-2);
    font-size: 14px;
}

.elapsed span {
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- 結果 ---------- */
.result {
    display: grid;
    gap: 22px;
}

.result-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
}

.result-heading {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.result-note {
    max-width: 60ch;
    color: var(--ink-2);
    font-size: 14px;
}

.segmented {
    display: inline-flex;
    padding: 4px;
    border-radius: 999px;
    background: var(--surface-3);
}

.segmented button {
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
    transition: background-color 0.15s, color 0.15s;
}

.segmented button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.sheets {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(24px, 3vw, 44px);
    padding: 16px 0 8px;
}

.sheet {
    position: relative;
    display: grid;
    gap: 14px;
    min-width: 0;
}

.sheet::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    z-index: 2;
    width: 72px;
    height: 22px;
    background: var(--tape);
    transform: translateX(-50%) rotate(-3deg);
    clip-path: polygon(3% 0, 97% 6%, 100% 94%, 0 100%);
    pointer-events: none;
}

.sheet + .sheet::before {
    background: var(--tape-alt);
    transform: translateX(-50%) rotate(3deg);
}

/* 同じ高さで並ぶよう、縦横の比率に応じて幅を配分 */
.sheet--portrait {
    flex: 63 1 0;
    max-width: 300px;
    min-width: 150px;
}

.sheet--landscape {
    flex: 159 1 0;
    max-width: 500px;
    min-width: 240px;
}

.sheet-frame {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #fff;
    box-shadow: var(--shadow-card);
    cursor: zoom-in;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.sheet-frame img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.sheet-frame:hover {
    transform: translateY(-3px) rotate(-0.4deg);
}

.sheet-zoom {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(43, 36, 56, 0.75);
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
}

.sheet-frame:hover .sheet-zoom,
.sheet-frame:focus-visible .sheet-zoom {
    opacity: 1;
}

.sheet-caption {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sheet-label {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.sheet-label small {
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0;
}

.sheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.print-spec {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    color: var(--ink-2);
    font-size: 13.5px;
}

.print-spec .icon {
    width: 16px;
    height: 16px;
    margin-top: 3px;
    color: var(--ink-3);
}

/* 版の情報：1行の定義リスト */
.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 22px;
    padding: 0 4px;
}

.meta div {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.meta dt {
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 700;
}

.meta dd {
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 修正：メモ帳 */
.revise {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 26px 20px 20px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.revise::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background:
        radial-gradient(circle at 10px 5px, var(--mat) 3px, transparent 3.5px) 0 0 / 24px 10px repeat-x,
        var(--butter);
}

.revise > label {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 700;
}

.revise-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.revise-head h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 900;
}

.revise-head .icon {
    color: var(--accent);
}

.revise-input {
    background-color: var(--surface);
    background-image: repeating-linear-gradient(transparent 0 calc(1.65em - 1px), var(--line) calc(1.65em - 1px) 1.65em);
    background-position: 0 10px;
    background-attachment: local;
}

.revise-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.revise-foot > .btn {
    margin-left: auto;
}

.chip {
    min-height: 34px;
    padding: 0 13px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 13px;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.chip:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

/* プレビューの直下から修正欄へ案内する。取得欄を挟むため、気づける位置に置く */
.revise-jump {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}

.revise-jump:hover {
    border-color: var(--accent);
    transform: translateY(1px);
}

.revise-jump > .icon {
    flex: none;
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.revise-jump-text {
    display: grid;
    flex: 1;
    gap: 2px;
    color: var(--ink-2);
    font-size: 13px;
}

.revise-jump-text b {
    color: var(--ink);
    font-size: 15px;
    font-weight: 900;
}

.result .revise {
    scroll-margin-top: calc(var(--topbar-h) + 56px);
}

/* 修正ではなく別の名刺を一から作る：修正メモより控えめな破線カード */
.next-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    padding: 18px 20px;
    border: 1.5px dashed var(--line);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.next-card-text {
    flex: 1 1 280px;
}

/* 選んだ版の印刷データ：ミントのチケット */
.revise.acquisition {
    padding: 22px 22px 18px;
    border: 1.5px dashed color-mix(in srgb, var(--mint) 75%, var(--ink) 25%);
    background: var(--mint-soft);
    box-shadow: none;
}

.revise.acquisition::before {
    display: none;
}

.revise.acquisition:empty {
    display: none;
}

.acquisition h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 900;
}

.acquisition p {
    margin: 0;
    line-height: 1.75;
}

.acquisition > .btn {
    justify-self: start;
    white-space: normal;
    text-align: center;
}

.acquisition-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.acquisition .btn {
    white-space: normal;
    text-align: center;
}

/* デジタル名刺（画像）・印刷用の各ブロック。間を点線で区切る */
.acquisition-block {
    display: grid;
    gap: 10px;
}

.acquisition-block > .btn {
    justify-self: start;
}

.acquisition-block + .acquisition-block {
    padding-top: 14px;
    border-top: 1.5px dashed color-mix(in srgb, var(--mint) 60%, var(--ink) 20%);
}

.acquisition-qr {
    display: grid;
    gap: 6px;
    justify-items: start;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.acquisition-error {
    color: var(--danger);
    font-weight: 700;
}

.acquisition-note {
    color: var(--ink-2);
    font-size: 13px;
}

/* 購入データの無料修正・スタッフへの相談 */
.acquisition-correction,
.acquisition-support {
    min-width: 0;
    overflow-wrap: anywhere;
    display: grid;
    gap: 8px;
    justify-items: start;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.acquisition-correction h3,
.acquisition-support h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 900;
}

.acquisition-choices {
    display: grid;
    gap: 4px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.acquisition-choices legend {
    margin-bottom: 4px;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
}

.acquisition-choices label {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    line-height: 1.6;
}

.acquisition-choices input {
    margin-top: 0.3em;
}

.acquisition-support label {
    font-size: 13px;
    font-weight: 700;
}

.acquisition-support textarea {
    width: 100%;
    min-height: 96px;
    padding: 10px 12px;
    border: 1.5px solid var(--control-line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    resize: vertical;
}

/* 過去の版を組み合わせる参考画像 */
.reference-picker {
    min-width: 0;
    margin: 4px 0;
    padding: 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
}

.reference-picker legend {
    padding: 0 6px;
    font-weight: 700;
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px;
}

.reference-choice {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 6px;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.reference-choice label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    cursor: pointer;
    font-size: 13px;
}

.reference-choice img {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    height: 90px;
    object-fit: contain;
}

.reference-choice input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.reference-choice:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.reference-choice:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.reference-choice span {
    font-size: 13px;
    overflow-wrap: anywhere;
}

.reference-status {
    margin: 10px 0 0;
    font-size: 13px;
}

/* ---------- 履歴：コンタクトシート ---------- */
.history {
    display: grid;
    gap: 14px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    scroll-margin-top: calc(var(--topbar-h) + 56px);
}

.history-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
}

.history-head h2 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 900;
}

.history-count {
    color: var(--ink-2);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.history-note {
    margin-left: auto;
    color: var(--ink-3);
    font-size: 12.5px;
}

.history-strip {
    display: flex;
    gap: 16px;
    padding: 8px 4px 12px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
}

.history-strip li {
    flex: none;
    scroll-snap-align: start;
}

.thumb {
    display: grid;
    gap: 8px;
    width: 144px;
    padding: 8px 8px 10px;
    border: 0;
    border-radius: 4px;
    background: var(--paper);
    color: var(--paper-ink);
    text-align: left;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.15s, transform 0.15s;
}

.history-strip li:nth-child(odd) .thumb {
    transform: rotate(-1deg);
}

.history-strip li:nth-child(even) .thumb {
    transform: rotate(1deg);
}

.history-strip li .thumb:hover {
    transform: translateY(-3px) rotate(0deg);
}

.thumb[aria-current="true"] {
    box-shadow: 0 0 0 3px var(--accent), var(--shadow-md);
}

.thumb-img {
    display: grid;
    place-items: center;
    height: 88px;
    overflow: hidden;
    border-radius: 2px;
    background: #f3eee5;
}

.thumb-img img {
    max-height: 100%;
    object-fit: contain;
}

.thumb-meta {
    color: #5e5668;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumb-meta b {
    margin-right: 5px;
    color: #2b2438;
}

/* ---------- ダイアログ ---------- */
.dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 60px -12px rgba(30, 20, 40, 0.4);
}

.dialog[open] {
    animation: pop 0.25s var(--ease);
}

.dialog::backdrop {
    background: rgba(43, 36, 56, 0.45);
    backdrop-filter: blur(2px);
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px 24px;
}

.dialog-head h2 {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 900;
}

.guide {
    display: grid;
    gap: 14px;
    padding: 8px 24px;
    counter-reset: guide;
}

.guide li {
    position: relative;
    display: grid;
    gap: 2px;
    padding-left: 44px;
    counter-increment: guide;
}

.guide li::before {
    content: counter(guide, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 0;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 900;
}

.guide b {
    font-size: 15px;
}

.guide span {
    color: var(--ink-2);
    font-size: 14px;
}

.guide-foot {
    margin: 12px 24px 22px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 13px;
}

.dialog--zoom {
    width: auto;
    max-width: calc(100vw - 32px);
    padding: 16px;
    background: var(--surface-2);
}

.dialog--zoom img {
    display: block;
    max-width: calc(100vw - 64px);
    max-height: calc(100vh - 80px);
    border-radius: 4px;
    background: #fff;
}

.zoom-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

/* ログイン方法の追加 */
.auth-dialog {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
}

.auth-dialog-body {
    padding: 0 24px 24px;
    line-height: 1.75;
}

.auth-fields {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.auth-fields label {
    display: grid;
    gap: 5px;
    font-size: 14px;
    font-weight: 600;
}

.auth-fields input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border: 1.5px solid var(--control-line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: inherit;
}

.auth-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.auth-consent input {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 4px;
    accent-color: var(--accent);
}

/* ---------- 通知 ---------- */
.toast-region {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 50;
    display: grid;
    gap: 10px;
    width: min(400px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 10px 12px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--lav);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    animation: slide-in 0.3s var(--ease);
}

.toast p {
    flex: 1;
    font-size: 14px;
}

.toast > .icon {
    margin-top: 3px;
}

.toast--success {
    border-left-color: var(--success);
}

.toast--success > .icon {
    color: var(--success);
}

.toast--error {
    border-left-color: var(--danger);
}

.toast--error > .icon {
    color: var(--danger);
}

.toast-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-3);
}

.toast-close:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.toast-close .icon {
    width: 14px;
    height: 14px;
}

/* ---------- アニメーション ---------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    50% { opacity: 0.35; }
}

@keyframes shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes pop {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: none; }
}

@keyframes slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 1180px) {
    :root {
        --compose-w: 400px;
    }

    .choice-grid--layout {
        grid-template-columns: 1fr 1fr;
    }

    .layout-option {
        grid-template-columns: 56px 1fr;
        justify-items: start;
        column-gap: 10px;
        padding: 10px;
        text-align: left;
    }

    .layout-figure {
        grid-row: span 2;
        margin: 0;
    }

    .idle-tips {
        grid-template-columns: minmax(0, 1fr);
        max-width: 520px;
    }
}

/* 広い画面でも境目で入力欄を狭めたときは、1180px以下と同じ2列のレイアウト選択にする */
@container compose (max-width: 420px) {
    .choice-grid--layout {
        grid-template-columns: 1fr 1fr;
    }

    .layout-option {
        grid-template-columns: 56px 1fr;
        justify-items: start;
        column-gap: 10px;
        padding: 10px;
        text-align: left;
    }

    .layout-figure {
        grid-row: span 2;
        margin: 0;
    }
}

@media (max-width: 960px) {
    .account-panel {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
    }

    .account-intro {
        justify-self: center;
    }
}

@media (max-width: 860px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    /* 1カラムでは幅を変えない（compose-splitter.js も同じ条件で指定を外す） */
    .compose-splitter {
        display: none;
    }

    .compose {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .compose-scroll {
        overflow: visible;
    }

    .compose-footer {
        z-index: 10;
    }

    .studio {
        min-height: auto;
        padding: 28px 16px 36px;
    }

    .api-status {
        display: none;
    }

    .history-note {
        margin-left: 0;
        width: 100%;
    }

    .mobile-tabs {
        position: sticky;
        top: var(--topbar-h);
        z-index: 15;
        display: flex;
        gap: 6px;
        padding: 8px 12px;
        background: color-mix(in srgb, var(--bg) 92%, transparent);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--line);
    }

    .mobile-tabs a {
        display: inline-grid;
        flex: 1;
        place-items: center;
        min-height: 40px;
        border-radius: 999px;
        background: var(--surface);
        color: var(--ink);
        font-size: 14px;
        font-weight: 700;
        text-decoration: none;
        box-shadow: var(--shadow-sm);
    }

    :root:has(#historySection[hidden]) .mobile-tabs [data-tab-history] {
        display: none;
    }
}

@media (max-width: 600px) {
    .compose-guide { padding: 14px 16px 6px; }
    .field input, .field textarea, .field select, .revise-input { font-size: 16px; }
    :root {
        --topbar-h: 58px;
    }

    .topbar {
        gap: 8px;
        padding: 0 10px 0 12px;
    }

    .topbar .dev-badge,
    #helpBtn span {
        display: none;
    }

    .topbar-link {
        padding: 0 6px;
        font-size: 13px;
    }

    #helpBtn {
        width: 44px;
        padding: 0;
    }

    .account-panel {
        padding: 22px 14px;
    }

    .account-intro {
        grid-template-columns: 88px minmax(0, 1fr);
        align-items: start;
        gap: 14px;
    }

    .account-title {
        font-size: 19px;
    }

    .account-title br {
        display: none;
    }

    .account-steps li {
        align-items: flex-start;
        font-size: 14px;
    }

    .account-main {
        padding: 20px 16px;
    }

    :root[data-auth="signed-in"] .account-panel {
        padding: 10px 12px;
    }

    :root[data-auth="signed-in"] .account-main {
        padding: 10px 12px;
    }

    :root[data-auth="signed-in"] .account-status {
        flex-basis: 100%;
        font-size: 13.5px;
    }

    .step {
        margin: 8px 10px;
    }

    .step-head {
        padding: 10px 12px;
    }

    .step-body {
        padding: 0 14px 18px;
    }

    .compose-footer {
        padding: 12px 14px 14px;
    }

    .field-grid,
    .choice-grid--preset,
    .purpose-switch {
        grid-template-columns: 1fr;
    }

    .layout-option {
        grid-template-columns: 44px 1fr;
        column-gap: 8px;
    }

    .slot-grid {
        grid-template-columns: 1fr 1fr;
    }

    .slot-grid--mini {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .btn-generate .kbd {
        display: none;
    }

    .sheet--portrait,
    .sheet--landscape {
        flex-basis: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .sheet--portrait {
        max-width: 260px;
    }

    .draft--landscape,
    .skeleton--landscape {
        width: min(100%, 320px);
    }

    .draft--portrait,
    .skeleton--portrait {
        width: min(40vw, 180px);
    }

    .revise {
        padding: 24px 14px 16px;
    }

    .revise-foot .btn,
    .next-card > .btn,
    .acquisition > .btn,
    .acquisition-block > .btn {
        width: 100%;
    }

    .next-card {
        padding: 16px 14px;
    }

    .history {
        padding: 16px 12px;
    }

    .toast-region {
        right: 16px;
        bottom: 16px;
    }
}

@media (max-width: 380px) {
    .topbar-link {
        display: none;
    }
}
