.builder-main { padding-bottom: 80px; }
.builder-intro { padding: 24px 0 27px; display: flex; justify-content: space-between; align-items: end; gap: 35px; }
.builder-eyebrow { margin: 0 0 4px; color: var(--blue-600); font-size: 9px; font-weight: 950; letter-spacing: .17em; }
.builder-intro h1 { margin: 0; color: var(--blue-950); font-size: clamp(28px, 4vw, 42px); line-height: 1.35; letter-spacing: -.045em; }
.builder-intro h1 strong { color: var(--blue-700); }
.builder-intro > div:first-child > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.builder-intro__steps { padding: 13px 16px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 12px; background: white; white-space: nowrap; }
.builder-intro__steps span { display: inline-flex; align-items: center; gap: 6px; color: #3f5569; font-size: 10px; font-weight: 800; }
.builder-intro__steps b { width: 23px; height: 23px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; color: white; background: var(--blue-700); font-size: 9px; }
.builder-intro__steps i { color: #9cafbd; font-style: normal; }

.deck-source-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(350px, .82fr); align-items: stretch; gap: 18px; }
.photo-import-card, .deck-import-card { min-width: 0; padding: 20px 22px; border: 1px solid #b9d3e4; border-radius: 15px; background: linear-gradient(105deg, white, var(--blue-050)); box-shadow: 0 11px 30px rgba(16,57,91,.07); }
.photo-import-card { position: relative; overflow: hidden; background: linear-gradient(125deg, #fff 0%, #eefaff 64%, #e7f8f1 100%); }
.deck-import-card { display: flex; flex-direction: column; gap: 14px; }
.deck-import-card__heading { display: flex; align-items: baseline; gap: 8px; }
.deck-import-card__heading span { color: var(--blue-600); font-size: 8px; font-weight: 950; letter-spacing: .15em; }
.deck-import-card__heading h2 { margin: 0; color: var(--blue-950); font-size: 17px; }
.feature-badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; color: #116142; background: #d9f5e7; font-size: 8px; font-weight: 950; letter-spacing: .08em; }
.photo-import-card__copy h2 { margin: 8px 0 3px; color: var(--blue-950); font-size: 20px; }
.photo-import-card__copy p { margin: 0 0 12px; color: var(--muted); font-size: 10px; line-height: 1.65; }
.photo-import-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 10px; }
.photo-dropzone { min-height: 92px; padding: 10px 13px; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 1fr 1fr; column-gap: 11px; align-items: center; border: 1.5px dashed #83b6d4; border-radius: 11px; background: rgba(255,255,255,.82); cursor: pointer; transition: .18s ease; }
.photo-dropzone:hover, .photo-dropzone.is-dragging { border-color: var(--blue-700); background: white; box-shadow: 0 0 0 3px rgba(22,130,196,.09); }
.photo-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.photo-preview-list { width: 152px; height: 72px; grid-row: 1 / 3; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 3px; }
.photo-preview-list[hidden] { display: none; }
.photo-preview-list[data-count="1"] { width: 72px; grid-template-columns: 1fr; }
.photo-preview-list[data-count="2"] { width: 112px; grid-template-columns: repeat(2, 1fr); }
.photo-preview-list img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: cover; border-radius: 5px; }
.photo-dropzone.has-preview .photo-dropzone__icon { display: none; }
.photo-dropzone__icon { width: 42px; height: 54px; grid-row: 1 / 3; display: inline-flex; align-items: center; justify-content: center; border: 2px solid #b9d8e9; border-radius: 7px; color: var(--blue-700); background: #edf8fd; font-size: 22px; font-weight: 500; transform: rotate(-3deg); }
.photo-dropzone strong { align-self: end; color: var(--blue-900); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-dropzone small { align-self: start; color: var(--muted); font-size: 8px; }
.photo-import-form > button { min-width: 148px; padding: 0 18px; border: 0; border-radius: 9px; color: white; background: linear-gradient(90deg, var(--blue-800), var(--blue-600)); cursor: pointer; font-size: 10px; font-weight: 950; }
.photo-import-form > button:hover:not(:disabled) { background: linear-gradient(90deg, var(--blue-900), var(--blue-700)); }
.photo-import-form > button:disabled { cursor: not-allowed; opacity: .45; }
.photo-privacy-note { margin: 8px 0 0; color: #6c7f8e; font-size: 8px; line-height: 1.55; }
.deck-import-form { margin-top: auto; }
.deck-import-form label { display: block; margin-bottom: 6px; color: var(--blue-900); font-size: 11px; font-weight: 900; }
.deck-import-form__control { height: 48px; display: flex; overflow: hidden; border: 1px solid #bdcedb; border-radius: 9px; background: white; }
.deck-import-form__control:focus-within { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(22,130,196,.12); }
.deck-import-form__control input { width: 100%; min-width: 0; padding: 0 14px; border: 0; outline: 0; color: var(--blue-950); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; font-weight: 800; letter-spacing: .02em; }
.deck-import-form__control button, .sample-load-button { padding: 0 22px; border: 0; color: white; background: var(--blue-700); cursor: pointer; font-size: 11px; font-weight: 900; white-space: nowrap; }
.deck-import-form__control button:hover { background: var(--blue-900); }
.deck-import-form__control button:disabled { cursor: wait; opacity: .7; }
.deck-import-form > p { margin: 5px 0 0; color: var(--muted); font-size: 9px; }
.sample-load-button { height: 42px; border: 1px solid var(--blue-700); border-radius: 8px; color: var(--blue-800); background: white; }
.sample-load-button:hover { background: var(--blue-100); }
.builder-status { margin-top: 13px; padding: 10px 14px; border-radius: 8px; color: #31566c; background: #e4f5fc; font-size: 11px; font-weight: 700; }
.builder-status.is-error { color: #892f3b; background: #fff0f2; }

.builder-workspace { margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1fr) 460px; align-items: start; gap: 22px; }
.deck-editor, .recipe-maker { border: 1px solid var(--border); border-radius: 17px; background: white; box-shadow: 0 11px 32px rgba(16,57,91,.06); }
.deck-editor { min-width: 0; overflow: hidden; }
.deck-editor__header, .recipe-maker__header { padding: 19px 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); background: #fbfdff; }
.deck-editor__header > div:first-child > span, .recipe-maker__header > div > span, .card-add-panel header > div > span { display: block; color: var(--blue-600); font-size: 8px; line-height: 1.2; font-weight: 950; letter-spacing: .15em; }
.deck-editor__header h2, .recipe-maker__header h2 { margin: 2px 0 0; color: var(--blue-950); font-size: 21px; line-height: 1.35; }
.deck-editor__header .deck-total { width: auto; height: auto; margin: 0; padding: 0; display: flex; gap: 5px; align-items: baseline; border-radius: 0; color: var(--blue-900); background: transparent; }
.deck-editor__header .deck-total strong { font-size: 29px; line-height: 1; }
.deck-editor__header .deck-total span { color: var(--muted); font-size: 10px; font-weight: 800; }
.deck-editor__header .deck-total.is-complete strong { color: #208256; }
.deck-editor__header .deck-total.is-over strong { color: #c03f51; }

.deck-title-field { padding: 17px 22px 13px; display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; gap: 11px; align-items: center; }
.deck-title-field label { color: var(--blue-900); font-size: 10px; font-weight: 900; }
.deck-title-field input { height: 39px; min-width: 0; padding: 0 11px; border: 1px solid #cad9e4; border-radius: 7px; outline: 0; font-weight: 800; }
.deck-title-field input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(22,130,196,.1); }
.deck-title-field > span { color: var(--muted); font-size: 8px; white-space: nowrap; }
.deck-title-field > span.is-saved { color: #23805a; }
.deck-progress { height: 4px; margin: 0 22px 18px; overflow: hidden; border-radius: 999px; background: #e9f0f5; }
.deck-progress span { width: 0; height: 100%; display: block; border-radius: inherit; background: var(--blue-600); transition: width .2s ease, background .2s ease; }
.deck-progress span.is-complete { background: #3da474; }
.deck-progress span.is-over { background: #d45262; }

.editor-empty { min-height: 410px; padding: 80px 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.editor-empty__mark { width: 76px; height: 96px; display: flex; align-items: center; justify-content: center; border: 4px solid var(--blue-100); border-radius: 11px; color: var(--blue-700); background: var(--blue-050); box-shadow: 9px 9px 0 #eef6fb; font-size: 27px; font-weight: 950; transform: rotate(-3deg); }
.editor-empty h3 { margin: 23px 0 4px; color: var(--blue-950); font-size: 17px; }
.editor-empty p { margin: 0; color: var(--muted); font-size: 11px; }
.deck-sections { padding: 0 22px 5px; }
.deck-category { margin-bottom: 15px; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.deck-category__header { padding: 9px 12px; display: flex; justify-content: space-between; align-items: center; color: var(--blue-900); background: var(--blue-050); }
.deck-category__header h3 { margin: 0; font-size: 12px; }
.deck-category__header strong { font-size: 10px; }
.deck-category__list { margin: 0; padding: 0; list-style: none; }
.deck-card-row { min-height: 45px; padding: 7px 9px 7px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; border-top: 1px solid #e7eef3; }
.deck-card-row__name { min-width: 0; color: #2f4659; font-size: 11px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-card-row__review { margin-left: 7px; padding: 2px 5px; border-radius: 4px; color: #835b16; background: #fff0c7; font-size: 7px; font-weight: 900; vertical-align: 1px; }
.deck-card-row__rename { padding: 5px 7px; border: 1px solid #c6d9e7; border-radius: 6px; color: var(--blue-800); background: #f5f9fc; cursor: pointer; font-size: 8px; font-weight: 900; white-space: nowrap; }
.deck-card-row__rename:hover { background: var(--blue-100); }
.deck-card-row__counter { display: flex; align-items: center; overflow: hidden; border: 1px solid #cbd9e3; border-radius: 7px; }
.deck-card-row__counter button { width: 28px; height: 28px; padding: 0; border: 0; color: var(--blue-800); background: #f5f9fc; cursor: pointer; font-size: 16px; font-weight: 800; }
.deck-card-row__counter button:hover { background: var(--blue-100); }
.deck-card-row__counter span { width: 29px; text-align: center; font-size: 11px; font-weight: 900; }
.deck-card-row__remove { width: 29px; height: 29px; padding: 0; border: 0; border-radius: 7px; color: #8b5d62; background: #fff1f2; cursor: pointer; font-size: 14px; }
.deck-card-row__remove:hover { color: white; background: #c84d5d; }

.card-add-panel { margin: 8px 22px 18px; border: 1px solid #bfd5e5; border-radius: 11px; overflow: hidden; }
.card-add-panel header { padding: 11px 13px; display: flex; justify-content: space-between; align-items: center; background: var(--blue-050); }
.card-add-panel header h3 { margin: 1px 0 0; color: var(--blue-950); font-size: 13px; }
.card-add-panel header button { padding: 5px 12px; border: 1px solid #abc8dc; border-radius: 6px; color: var(--blue-800); background: white; cursor: pointer; font-size: 9px; font-weight: 900; }
.card-add-panel__body { padding: 13px; }
.card-search-controls { display: grid; grid-template-columns: minmax(0, 1fr) 155px auto; gap: 8px; align-items: end; }
.card-search-controls label > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 8px; font-weight: 800; }
.card-search-controls input, .card-search-controls select { width: 100%; height: 38px; padding: 0 9px; border: 1px solid #c7d7e3; border-radius: 7px; background: white; outline: 0; font-size: 11px; }
.card-search-controls button { height: 38px; padding: 0 14px; border: 0; border-radius: 7px; color: white; background: var(--blue-700); cursor: pointer; font-size: 10px; font-weight: 900; }
.card-search-results { margin-top: 10px; display: grid; gap: 6px; }
.card-search-result { padding: 8px 9px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 8px; }
.card-search-result strong { display: block; color: #2e465a; font-size: 10px; }
.card-search-result small { display: block; color: var(--muted); font-size: 8px; }
.card-search-result button { padding: 5px 10px; border: 0; border-radius: 6px; color: white; background: var(--blue-700); cursor: pointer; font-size: 9px; font-weight: 900; }
.card-search-message { padding: 12px; color: var(--muted); background: #f8fbfd; border-radius: 7px; text-align: center; font-size: 10px; }
.deck-editor__actions { padding: 0 22px 22px; display: flex; align-items: center; gap: 10px; }
.deck-editor__actions button, .deck-editor__actions a { min-height: 38px; padding: 7px 13px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--blue-700); border-radius: 7px; color: var(--blue-800); background: white; cursor: pointer; font-size: 9px; font-weight: 900; }
.deck-editor__actions a { margin-left: auto; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.deck-editor__actions .official-register-button { border-color: #16704d; color: white; background: #20845d; }
.deck-editor__actions .official-register-button:hover:not(:disabled) { background: #156b49; }
.deck-editor__actions .official-register-button:disabled { cursor: not-allowed; opacity: .45; }
.official-register-result { margin: -9px 22px 22px; padding: 11px 13px; border: 1px solid #b9dfca; border-radius: 9px; color: #276147; background: #eefaf3; font-size: 10px; line-height: 1.65; }
.official-register-result strong { display: block; color: #15553b; font-size: 12px; }
.official-register-result a { color: var(--blue-800); font-weight: 900; }
.official-register-result.is-warning { border-color: #ecd7a4; color: #765d25; background: #fff9e9; }

.recipe-maker { position: sticky; top: 147px; overflow: hidden; }
.recipe-maker__format { color: var(--muted); font-size: 8px; }
.canvas-wrap { padding: 16px; background: #eaf1f5; }
.canvas-wrap canvas { width: 100%; height: auto; display: block; border-radius: 7px; background: var(--blue-900); box-shadow: 0 9px 24px rgba(8,47,87,.18); }
.theme-picker { margin: 0; padding: 15px 17px 12px; display: flex; gap: 8px; border: 0; border-bottom: 1px solid var(--border); }
.theme-picker legend { width: 100%; margin-bottom: 5px; color: var(--muted); font-size: 8px; font-weight: 900; }
.theme-picker label { flex: 1; min-width: 0; padding: 7px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.theme-picker label.is-selected { border-color: var(--blue-600); box-shadow: 0 0 0 2px rgba(22,130,196,.1); }
.theme-picker input { position: absolute; opacity: 0; pointer-events: none; }
.theme-picker b { overflow: hidden; color: #3d5266; font-size: 8px; text-overflow: ellipsis; }
.theme-swatch { width: 20px; height: 20px; flex: 0 0 auto; border-radius: 6px; background: linear-gradient(135deg, #07395d, #0b8b99); }
.theme-swatch--leaf { background: linear-gradient(135deg, #174d3a, #71a84b); }
.theme-swatch--midnight { background: linear-gradient(135deg, #171d2c, #58477d); }
.image-policy-note { margin: 14px 17px 12px; padding: 10px; display: flex; gap: 8px; align-items: flex-start; border-radius: 8px; background: #f4f9fc; }
.image-policy-note span { flex: 0 0 auto; padding: 1px 6px; border-radius: 4px; color: #206a4b; background: #d9f3e5; font-size: 7px; font-weight: 900; }
.image-policy-note p { margin: 0; color: var(--muted); font-size: 8px; line-height: 1.6; }
.download-image-button { width: calc(100% - 34px); min-height: 45px; margin: 0 17px; border: 0; border-radius: 9px; color: white; background: linear-gradient(90deg, var(--blue-800), var(--blue-600)); cursor: pointer; font-size: 11px; font-weight: 950; box-shadow: 0 7px 18px rgba(12,99,166,.2); }
.download-image-button:hover:not(:disabled) { background: linear-gradient(90deg, var(--blue-900), var(--blue-700)); }
.download-image-button:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }
.download-status { min-height: 25px; margin: 5px 17px 8px; color: #29805c; text-align: center; font-size: 8px; }

.builder-toast { position: fixed; z-index: 300; left: 50%; bottom: 26px; padding: 9px 16px; color: white; background: var(--blue-950); border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.24); opacity: 0; transform: translate(-50%, 14px); pointer-events: none; transition: .2s ease; font-size: 10px; font-weight: 900; }
.builder-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.deck-card-row__candidates { grid-column: 1 / -1; display: grid; grid-template-columns: 86px repeat(3, minmax(0, 1fr)); gap: 6px; padding: 2px 0 3px; overflow-x: auto; }
.deck-card-row__candidates > small { grid-column: 1 / -1; color: #6d8190; font-size: 8px; font-weight: 850; }
.deck-card-row__source { min-height: 61px; padding: 5px; display: grid; place-items: center; gap: 3px; border: 1px solid #dccb9d; border-radius: 8px; background: #fffaf0; }
.deck-card-row__source small { color: #795f25; font-size: 7px; font-weight: 900; }
.deck-card-row__source canvas { width: 48px; height: 67px; display: block; border-radius: 3px; background: #e8eff3; object-fit: cover; }
.catalog-candidate { min-width: 0; min-height: 61px; padding: 5px; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 6px; align-items: center; border: 1px solid #c8dce9; border-radius: 8px; color: #2f4659; background: #f7fbfd; cursor: pointer; text-align: left; }
.catalog-candidate:hover { border-color: var(--blue-600); background: #edf8fd; box-shadow: 0 0 0 2px rgba(22,130,196,.08); }
.catalog-candidate img { width: 38px; height: 52px; display: block; object-fit: contain; border-radius: 3px; background: #e8eff3; }
.catalog-candidate span { min-width: 0; }
.catalog-candidate strong, .catalog-candidate small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-candidate strong { font-size: 8px; }
.catalog-candidate small { margin-top: 2px; color: #718391; font-size: 7px; }

@media (max-width: 1020px) {
    .builder-workspace { grid-template-columns: minmax(0, 1fr) 390px; }
    .card-search-controls { grid-template-columns: 1fr 130px; }
    .card-search-controls button { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
    .builder-intro { align-items: flex-start; flex-direction: column; }
    .builder-intro__steps { width: 100%; justify-content: center; }
    .deck-source-grid { grid-template-columns: 1fr; }
    .photo-import-form { grid-template-columns: minmax(0, 1fr) 180px; }
    .builder-workspace { grid-template-columns: 1fr; }
    .recipe-maker { position: static; }
    .canvas-wrap { padding: 20px; }
}

@media (max-width: 620px) {
    .builder-intro { padding-top: 18px; }
    .builder-intro h1 { font-size: 29px; }
    .builder-intro__steps { padding: 10px 8px; gap: 6px; overflow-x: auto; justify-content: flex-start; }
    .builder-intro__steps span { font-size: 8px; }
    .photo-import-card, .deck-import-card { padding: 16px; }
    .photo-import-form { grid-template-columns: 1fr; }
    .photo-import-form > button { min-height: 44px; }
    .photo-dropzone { min-height: 88px; }
    .deck-import-card { gap: 10px; }
    .deck-import-form__control { height: auto; display: grid; border: 0; overflow: visible; background: transparent; }
    .deck-import-form__control input { height: 45px; border: 1px solid #bdcedb; border-radius: 8px; background: white; font-size: 13px; }
    .deck-import-form__control button { min-height: 43px; margin-top: 8px; border-radius: 8px; }
    .sample-load-button { width: 100%; }
    .builder-workspace { width: calc(100% - 14px); }
    .deck-editor__header, .recipe-maker__header { padding: 16px; }
    .deck-title-field { padding: 15px 16px 11px; grid-template-columns: 1fr; gap: 5px; }
    .deck-title-field > span { display: none; }
    .deck-progress { margin-inline: 16px; }
    .deck-sections { padding-inline: 12px; }
    .deck-card-row__rename { padding-inline: 5px; font-size: 0; }
    .deck-card-row__rename::before { content: "修正"; font-size: 8px; }
    .deck-card-row { grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; padding-left: 9px; }
    .deck-card-row__name { font-size: 10px; }
    .deck-card-row__candidates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card-add-panel { margin-inline: 12px; }
    .card-search-controls { grid-template-columns: 1fr; }
    .card-search-controls button { grid-column: auto; }
    .deck-editor__actions { padding-inline: 12px; flex-wrap: wrap; }
    .deck-editor__actions a { margin-left: 0; }
    .canvas-wrap { padding: 10px; }
    .theme-picker { flex-wrap: wrap; }
    .theme-picker label { flex-basis: 30%; }
}
