/* =========================================================
   名刺生成スタジオ - 断頭台のアウラ
   和紙の地色 × 朱のアクセント。印刷物を扱う道具としての静けさを重視。
   ========================================================= */

/* ---------- トークン ---------- */
:root {
    --bg: #f3f0e8;
    --surface: #fffdf8;
    --surface-2: #f8f5ee;
    --surface-3: #efeadf;
    --ink: #1f1d1a;
    --ink-2: #57534b;
    --ink-3: #8b867b;
    --line: #e4ded1;
    --line-strong: #cec6b5;
    --accent: #c43e28;
    --accent-hover: #a93320;
    --accent-ink: #ffffff;
    --accent-soft: #f8e4dd;
    --accent-line: #ecbcae;
    --success: #2f7a58;
    --success-soft: #e1f1e8;
    --danger: #b3261e;
    --danger-soft: #fae3e1;
    --focus: rgba(196, 62, 40, 0.32);
    --mat: #e8e3d7;
    --mat-line: rgba(80, 70, 50, 0.07);
    --mat-line-strong: rgba(80, 70, 50, 0.13);
    --paper: #ffffff;
    --paper-ink: #22201c;
    --shadow-sm: 0 1px 2px rgba(40, 32, 20, 0.06);
    --shadow-md: 0 1px 2px rgba(40, 32, 20, 0.06), 0 8px 24px -8px rgba(40, 32, 20, 0.14);
    --shadow-card: 0 1px 1px rgba(40, 32, 20, 0.08), 0 10px 30px -10px rgba(40, 32, 20, 0.28);

    --font-sans: "Inter", "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
    --font-serif: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --topbar-h: 60px;
    --compose-w: 440px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #141311;
        --surface: #1c1b18;
        --surface-2: #23211e;
        --surface-3: #2b2925;
        --ink: #f0ece3;
        --ink-2: #bdb7ab;
        --ink-3: #878176;
        --line: #33302b;
        --line-strong: #47433c;
        --accent: #e5664b;
        --accent-hover: #f07b61;
        --accent-ink: #1a0d09;
        --accent-soft: #3a1f18;
        --accent-line: #6b3325;
        --success: #6cc49a;
        --success-soft: #19302a;
        --danger: #f08a80;
        --danger-soft: #3a1c1a;
        --focus: rgba(229, 102, 75, 0.4);
        --mat: #0f0e0c;
        --mat-line: rgba(255, 245, 225, 0.035);
        --mat-line-strong: rgba(255, 245, 225, 0.07);
        --paper: #f7f4ee;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -8px rgba(0, 0, 0, 0.6);
        --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.5), 0 14px 34px -10px rgba(0, 0, 0, 0.8);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #141311;
    --surface: #1c1b18;
    --surface-2: #23211e;
    --surface-3: #2b2925;
    --ink: #f0ece3;
    --ink-2: #bdb7ab;
    --ink-3: #878176;
    --line: #33302b;
    --line-strong: #47433c;
    --accent: #e5664b;
    --accent-hover: #f07b61;
    --accent-ink: #1a0d09;
    --accent-soft: #3a1f18;
    --accent-line: #6b3325;
    --success: #6cc49a;
    --success-soft: #19302a;
    --danger: #f08a80;
    --danger-soft: #3a1c1a;
    --focus: rgba(229, 102, 75, 0.4);
    --mat: #0f0e0c;
    --mat-line: rgba(255, 245, 225, 0.035);
    --mat-line-strong: rgba(255, 245, 225, 0.07);
    --paper: #f7f4ee;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -8px rgba(0, 0, 0, 0.6);
    --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.5), 0 14px 34px -10px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
}

/* ---------- ベース ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    font-feature-settings: "palt";
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, figure, dl, dd, ol {
    margin: 0;
}

ol {
    padding: 0;
    list-style: none;
}

img {
    max-width: 100%;
}

button,
input,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.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;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -48px;
    z-index: 100;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--bg);
    text-decoration: none;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 12px;
}

.kbd {
    padding: 1px 6px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    opacity: 0.7;
    white-space: nowrap;
}

/* ---------- ボタン ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--ink-3);
}

.btn-sm {
    min-height: 30px;
    padding: 0 10px;
    gap: 6px;
    font-size: 12.5px;
}

.btn-sm .icon {
    width: 15px;
    height: 15px;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    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(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-seal {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 2px solid var(--accent);
    border-radius: 7px;
    color: var(--accent);
    font-family: var(--font-serif);
    font-size: 19px;
    font-weight: 700;
    line-height: 1;
    transform: rotate(-4deg);
    box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3px var(--accent-line);
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.brand-name {
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-sub {
    color: var(--ink-3);
    font-size: 11.5px;
    letter-spacing: 0.08em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 10px;
    margin-right: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    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;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun {
        display: none;
    }

    :root:not([data-theme="light"]) .icon-moon {
        display: block;
    }
}

/* ---------- レイアウト ---------- */
.workspace {
    display: grid;
    grid-template-columns: var(--compose-w) minmax(0, 1fr);
    align-items: start;
}

/* ---------- 入力パネル ---------- */
.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);
}

.compose-scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.step {
    border-bottom: 1px solid var(--line);
}

.step-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    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 {
    color: var(--accent);
    font-family: var(--font-serif);
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.step-title {
    font-size: 15px;
    font-weight: 700;
    transition: color 0.15s;
}

.step-status {
    margin-left: auto;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 11.5px;
    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 20px 22px;
}

.step-lead {
    color: var(--ink-3);
    font-size: 12.5px;
}

/* フォーム */
.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: 12.5px;
    font-weight: 600;
}

.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.counter {
    color: var(--ink-3);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.field input,
.field textarea,
.revise-input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.field textarea,
.revise-input {
    resize: vertical;
    min-height: 76px;
    line-height: 1.6;
}

.field input::placeholder,
.field textarea::placeholder,
.revise-input::placeholder {
    color: var(--ink-3);
    opacity: 0.8;
}

.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);
    outline: none;
}

.hint {
    color: var(--ink-3);
    font-size: 12px;
}

/* 選択肢（レイアウト・プリセット） */
.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;
}

.layout-option,
.preset {
    position: relative;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.layout-option input,
.preset input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.layout-option:hover,
.preset:hover {
    border-color: var(--ink-3);
}

.layout-option:has(input:checked),
.preset:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.layout-option:has(input:focus-visible),
.preset:has(input:focus-visible) {
    box-shadow: 0 0 0 3px var(--focus);
}

.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: 12.5px;
    font-weight: 700;
    line-height: 1.3;
}

.layout-desc {
    color: var(--ink-3);
    font-size: 10.5px;
    line-height: 1.3;
}

.preset {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    min-width: 0;
}

.preset-swatch {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    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);
}

.preset-swatch--none {
    background: repeating-linear-gradient(135deg, transparent 0 4px, var(--line) 4px 5px);
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

.preset-text {
    display: grid;
    min-width: 0;
    line-height: 1.35;
}

.preset-name {
    font-size: 13px;
    font-weight: 700;
}

.preset-desc {
    overflow: hidden;
    color: var(--ink-3);
    font-size: 11px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.preset-loading {
    grid-column: 1 / -1;
    color: var(--ink-3);
    font-size: 12.5px;
}

/* 画像スロット */
.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: 1px 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);
}

.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: -7px;
    right: -7px;
    display: none;
    place-items: center;
    width: 24px;
    height: 24px;
    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: 1px dashed var(--line);
}

.extra-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-2);
}

.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 -8px 16px -12px rgba(40, 32, 20, 0.25);
}

.summary {
    overflow: hidden;
    color: var(--ink-2);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-generate {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
    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;
}

/* ---------- スタジオ（右側） ---------- */
.studio {
    display: grid;
    gap: 20px;
    align-content: start;
    min-width: 0;
    min-height: calc(100vh - var(--topbar-h));
    padding: 28px clamp(16px, 3vw, 44px) 40px;
    background-color: var(--mat);
    background-image:
        linear-gradient(var(--mat-line-strong) 1px, transparent 1px),
        linear-gradient(90deg, var(--mat-line-strong) 1px, transparent 1px),
        linear-gradient(var(--mat-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--mat-line) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    background-position: -1px -1px;
}

.stage {
    scroll-margin-top: calc(var(--topbar-h) + 12px);
    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: 22px;
}

.stage-head {
    display: grid;
    gap: 4px;
    max-width: 640px;
}

.eyebrow {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.badge {
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 10.5px;
    letter-spacing: 0.08em;
}

.stage-title {
    font-family: var(--font-serif);
    font-size: clamp(20px, 2.2vw, 26px);
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.35;
}

.stage-note {
    color: var(--ink-2);
    font-size: 13px;
}

/* 表裏の並び */
.pair {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(20px, 4vw, 56px);
    padding: clamp(12px, 3vw, 32px) 0;
}

.pair-item {
    display: grid;
    justify-items: center;
    gap: 12px;
}

.pair-item figcaption {
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2em;
}

/* ラフ */
.draft,
.skeleton {
    position: relative;
    overflow: hidden;
    border-radius: 3px;
    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-serif);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.12em;
    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: #b9b3a6 !important;
    font-weight: 500;
}

/* 生成中 */
.skeleton {
    background: linear-gradient(100deg, var(--paper) 30%, #f1ece2 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(#e7e1d5, #e7e1d5) 0 0 / 40% 7% no-repeat,
        linear-gradient(#ece7dc, #ece7dc) 0 45% / 70% 12% no-repeat,
        linear-gradient(#ece7dc, #ece7dc) 0 100% / 55% 5% no-repeat;
}

.skeleton .crop {
    position: absolute;
    inset: 6px;
    border: 1px dashed rgba(196, 62, 40, 0.35);
    border-radius: 2px;
}

.loading-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.elapsed {
    color: var(--ink-2);
    font-size: 13px;
}

.elapsed span {
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---------- 結果 ---------- */
.result {
    display: grid;
    gap: 20px;
}

.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: 13px;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
}

.segmented button {
    min-height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
    transition: background-color 0.15s, color 0.15s;
}

.segmented button[aria-pressed="true"] {
    background: var(--ink);
    color: var(--surface);
}

.sheets {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(20px, 3vw, 40px);
    padding: 8px 0;
}

.sheet {
    display: grid;
    gap: 12px;
    min-width: 0;
}

/* 同じ高さで並ぶよう、縦横の比率に応じて幅を配分 */
.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: 3px;
    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: 3px;
}

.sheet-frame:hover {
    transform: translateY(-3px);
}

.sheet-zoom {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(20, 18, 15, 0.72);
    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: 13px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.sheet-label small {
    color: var(--ink-3);
    font-size: 11px;
    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 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    color: var(--ink-2);
    font-size: 12.5px;
}

.print-spec .icon {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    color: var(--ink-3);
}

.meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--line);
}

.meta div {
    padding: 10px 14px;
    background: var(--surface);
    min-width: 0;
}

.meta dt {
    color: var(--ink-3);
    font-size: 11px;
}

.meta dd {
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 修正 */
.revise {
    display: grid;
    gap: 10px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.revise-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.revise-head h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
}

.revise-head .icon {
    color: var(--accent);
}

.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: 28px;
    padding: 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 12px;
    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);
}

/* ---------- 履歴 ---------- */
.history {
    display: grid;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line-strong);
}

.history-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
}

.history-head h2 {
    font-size: 14px;
    font-weight: 700;
}

.history-count {
    color: var(--ink-2);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.history-note {
    margin-left: auto;
    color: var(--ink-3);
    font-size: 11.5px;
}

.history-strip {
    display: flex;
    gap: 12px;
    padding: 4px 2px 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
}

.history-strip li {
    flex: none;
    scroll-snap-align: start;
}

.thumb {
    display: grid;
    gap: 6px;
    width: 132px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.thumb:hover {
    border-color: var(--ink-3);
    transform: translateY(-2px);
}

.thumb[aria-current="true"] {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.thumb-img {
    display: grid;
    place-items: center;
    height: 84px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--surface-3);
}

.thumb-img img {
    max-height: 100%;
    object-fit: contain;
}

.thumb-meta {
    color: var(--ink-2);
    font-size: 11px;
    white-space: nowrap;
}

.thumb-meta b {
    margin-right: 5px;
    color: var(--ink);
}

/* ---------- ダイアログ ---------- */
.dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35);
}

.dialog[open] {
    animation: pop 0.25s var(--ease);
}

.dialog::backdrop {
    background: rgba(20, 17, 12, 0.5);
    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-serif);
    font-size: 20px;
}

.guide {
    display: grid;
    gap: 14px;
    padding: 8px 24px 8px;
    counter-reset: guide;
}

.guide li {
    position: relative;
    display: grid;
    gap: 2px;
    padding-left: 38px;
    counter-increment: guide;
}

.guide li::before {
    content: counter(guide, decimal-leading-zero);
    position: absolute;
    left: 0;
    top: 0;
    color: var(--accent);
    font-family: var(--font-serif);
    font-size: 15px;
    font-weight: 700;
}

.guide b {
    font-size: 14px;
}

.guide span {
    color: var(--ink-2);
    font-size: 13px;
}

.guide-foot {
    margin: 12px 24px 22px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 12.5px;
}

.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: 3px;
    background: #fff;
}

.zoom-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

/* ---------- 通知 ---------- */
.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: 3px solid var(--ink-3);
    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: 13px;
}

.toast > .icon {
    margin-top: 2px;
}

.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: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    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 (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- レスポンシブ ---------- */
@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;
    }

    .meta {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 860px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .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: 24px 16px 32px;
    }

    .api-status {
        display: none;
    }

    .history-note {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .topbar {
        padding: 0 12px;
    }

    .brand-sub,
    #helpBtn span {
        display: none;
    }

    #helpBtn {
        width: 36px;
        padding: 0;
    }

    .step-head {
        padding: 14px 16px;
    }

    .step-body {
        padding: 0 16px 20px;
    }

    .compose-footer {
        padding: 12px 16px 14px;
    }

    .field-grid,
    .choice-grid--preset {
        grid-template-columns: 1fr;
    }

    .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(42vw, 180px);
    }

    .revise-foot .btn {
        width: 100%;
    }
}
