/* Custom card creator (/custom). Builds on garam_checklist.css, like Combine. */
.garam-custom-page .custom-hero { display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 0; }
.garam-custom-page .custom-hero .checklist-title { display: block; text-align: center; }
.garam-custom-page .custom-hero em { color: var(--check-accent); font-style: italic; }
.custom-signin { padding: 50px 24px; max-width: 600px; margin: 0 auto; text-align: center; background: var(--check-soft);
    border: 1px solid var(--check-border); border-radius: 24px; }

/* Limit / balance bar */
.custom-access { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
    margin: 0 0 14px; padding: 12px 18px; border-radius: 16px; background: rgba(255,255,255,.88);
    border: 1px solid var(--check-border); color: var(--check-ink); font-size: 14px; font-weight: 700; }
.custom-access[data-tone="warning"] { background: #fff6e2; border-color: #f0d58e; color: #7a5300; }
.custom-access[data-tone="error"] { background: #fdecef; border-color: #f3b9c4; color: #9b1f35; }
.custom-access a { color: var(--check-accent); font-weight: 800; }
.custom-access-balance { display: inline-flex; align-items: center; gap: 5px; }
.custom-coin { width: 16px; height: 16px; object-fit: contain; vertical-align: -3px; margin-left: 4px; }

/* Two columns: the form, and a sticky preview */
.custom-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 18px; align-items: start; }
.garam-custom-page .custom-form { display: grid; gap: 6px; }
.custom-step { margin: 0; padding: 4px 0 14px; border: 0; border-bottom: 1px solid var(--check-border); min-width: 0; }
.custom-step:last-of-type { border-bottom: 0; }
.custom-step legend { display: flex; align-items: center; gap: 9px; padding: 0; margin-bottom: 12px;
    color: var(--check-ink); font-size: 17px; font-weight: 850; }
.custom-step-number { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
    background: var(--check-accent); color: #fff; font-size: 13px; font-weight: 850; }
.custom-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.custom-label { color: var(--check-muted); font-size: 13px; font-weight: 700; }
.custom-hint { margin: 9px 0 0; color: var(--check-muted); font-size: 12px; }
.garam-custom-page .checklist-filter-field input[type="text"], .custom-select {
    display: block; width: 100%; min-width: 0; height: 45px; padding: 10px 12px; margin: 0;
    border: 1px solid var(--garam-c-b7d8ed,#b7d8ed); border-radius: 13px; font: inherit; font-size: 14px;
    background: var(--check-soft); color: var(--check-ink); }
.garam-custom-page .checklist-filter-field input[type="text"]:focus-visible, .custom-select:focus-visible {
    outline: 2px solid var(--check-accent); outline-offset: 1px; }

/* Segmented choices (card type, rarity) */
.custom-segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--check-soft);
    border: 1px solid var(--check-border); margin-bottom: 12px; }
.custom-segmented label { position: relative; cursor: pointer; }
.custom-segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.custom-segmented span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 36px;
    padding: 6px 14px; border-radius: 10px; color: var(--check-muted); font-size: 14px; font-weight: 800; transition: background .15s, color .15s; }
.custom-segmented input:checked + span { background: var(--check-accent); color: #fff; box-shadow: 0 2px 6px rgb(0 0 0 / 12%); }
.custom-segmented input:focus-visible + span { outline: 2px solid var(--check-accent); outline-offset: 2px; }
.custom-rarity { margin-bottom: 0; }

/* What the card shows: one switch per part */
.custom-show { display: grid; gap: 7px; margin-top: 14px; }
.custom-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.custom-toggle { position: relative; display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 8px 14px 8px 10px;
    border-radius: 13px; border: 1px solid var(--garam-c-b7d8ed,#b7d8ed); background: var(--check-soft); color: var(--check-ink);
    font-size: 14px; font-weight: 800; cursor: pointer; user-select: none; transition: border-color .15s, background .15s; }
.custom-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.custom-toggle-track { position: relative; width: 34px; height: 20px; flex-shrink: 0; border-radius: 999px;
    background: var(--garam-c-b7d8ed,#b7d8ed); transition: background .15s; }
.custom-toggle-knob { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .15s; }
.custom-toggle:has(input:checked) { border-color: var(--check-accent); }
.custom-toggle input:checked + .custom-toggle-track { background: var(--check-accent); }
.custom-toggle input:checked + .custom-toggle-track .custom-toggle-knob { transform: translateX(14px); }
.custom-toggle:has(input:focus-visible) { outline: 2px solid var(--check-accent); outline-offset: 2px; }

/* Picture drop zone */
.custom-drop { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 16px; cursor: pointer;
    border: 2px dashed var(--garam-c-a9cfea,#a9cfea); background: var(--check-soft); color: var(--check-ink); transition: border-color .15s, background .15s; }
.custom-drop:hover, .custom-drop.is-over, .custom-drop:focus-within { border-color: var(--check-accent); background: var(--garam-c-e5f5ff,#e5f5ff); }
.custom-drop.has-file { border-style: solid; }
.custom-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.custom-drop-icon { display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px;
    background: var(--check-accent); color: #fff; font-size: 20px; font-weight: 900; }
.custom-drop-text { display: grid; gap: 2px; min-width: 0; }
.custom-drop-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-drop-text small { color: var(--check-muted); font-size: 12px; }
.custom-emoji-image { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.custom-file-button { position: relative; cursor: pointer; }
.custom-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.custom-file-button:focus-within { outline: 2px solid var(--check-accent); outline-offset: 2px; }

/* Holder */
.custom-holder-choice { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.custom-holder-selected { display: flex; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; border-radius: 14px;
    background: var(--check-soft); border: 1px solid var(--check-border); min-width: 0; }
.custom-holder-selected > img { width: 54px; height: 80px; object-fit: contain; }
.custom-holder-selected div { display: grid; gap: 3px; min-width: 0; }
.custom-holder-selected strong { color: var(--check-ink); }
.custom-holder-selected span { color: var(--check-muted); font-size: 13px; font-weight: 700; }

/* Submit */
.custom-submit { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 8px; }
.garam-custom-page .custom-create { min-height: 48px; padding: 10px 22px; font-size: 15px; }
.custom-create .custom-coin { filter: drop-shadow(0 0 1px #fff); }
.custom-status { flex: 1; min-width: 200px; margin: 0; padding: 9px 12px; border-radius: 11px; font-size: 13px; font-weight: 700;
    background: var(--check-soft); color: var(--check-ink); }
.custom-status[data-tone="error"] { background: #fdecef; color: #9b1f35; }

/* Preview */
.custom-preview-panel { position: sticky; top: 110px; padding: 16px; border-radius: 24px; background: #fff;
    border: 1px solid var(--check-border); box-shadow: 0 14px 30px rgba(21,99,153,.12); }
.custom-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.custom-preview-head h2 { margin: 0; color: var(--check-ink); font-size: 18px; }
.custom-preview-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--check-muted); font-size: 13px; font-weight: 700; cursor: pointer; }
/* Same look as the card details stage (garam_card_modal.css); the 3D viewer fills it. */
.custom-preview-stage { position: relative; overflow: hidden; border-radius: 18px;
    background: radial-gradient(circle at center, var(--garam-c-f6fcff,#f6fcff), var(--garam-c-b9e2fc,#b9e2fc)); }
.garam-custom-page #three_dimensional_target { display: block; width: 100%; height: min(560px, 64vh); min-height: 340px; margin: 0 auto;
    cursor: grab; touch-action: none; }
.garam-custom-page #three_dimensional_target:active { cursor: grabbing; }
.garam-custom-page #three_dimensional_target canvas { display: block; }
.custom-preview-empty { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); margin: 0; padding: 6px 12px;
    border-radius: 999px; background: rgba(4,37,67,.72); color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; }
.custom-preview-note { margin: 10px 2px 0; color: var(--check-muted); font-size: 12px; }

/* Dialogs: moved to <body> by custom_script.js and stacked above the shared header
   (z-index 10050) and footer, like the Inventory modals (garam_layout.css). */
html body.garam-shell-body .custom-modal { position: fixed; inset: 0; z-index: 200002; display: flex; align-items: center; justify-content: center;
    padding: 18px; background: rgba(6,39,67,.7); }
.custom-modal[hidden] { display: none !important; }
.custom-modal * { box-sizing: border-box; }
.custom-modal-panel { width: min(100%, 520px); max-height: calc(100dvh - 36px); overflow: auto; padding: 20px; border-radius: 22px;
    background: #fff; border: 1px solid var(--garam-c-b1d8f2,#b1d8f2); color: var(--garam-c-123c5c,#123c5c);
    box-shadow: 0 24px 70px rgba(4,37,67,.35); }
.custom-holder-panel { width: min(100%, 860px); display: flex; flex-direction: column; }
.custom-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.custom-modal-head h2 { margin: 0; font-size: 21px; font-weight: 850; }
.custom-modal-close { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--garam-c-a9cfea,#a9cfea);
    background: #fff; color: var(--garam-c-155a8d,#155a8d); font-size: 22px; line-height: 1; cursor: pointer; }
.custom-modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.custom-modal .checklist-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
    padding: 9px 16px; border-radius: 13px; font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; text-decoration: none; }
.custom-modal .checklist-button-outline { border: 1px solid var(--garam-c-a9cfea,#a9cfea); background: #fff; color: var(--garam-c-155a8d,#155a8d); }
.custom-modal .checklist-button-primary { border: 1px solid var(--garam-theme-ui-accent,#087cce);
    background: var(--garam-theme-ui-accent,#087cce); color: #fff; }
.custom-modal .checklist-button:disabled { opacity: .5; cursor: wait; }
.custom-holder-filters { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 10px; }
.custom-holder-tag { position: relative; min-width: 0; }
@media (max-width: 560px) { .custom-holder-filters { grid-template-columns: minmax(0, 1fr); } }
.custom-holder-search { width: 100%; height: 44px; padding: 9px 13px; border-radius: 13px; border: 1px solid var(--garam-c-a9cfea,#a9cfea);
    background: var(--garam-c-f0f9ff,#f0f9ff); color: inherit; font: inherit; font-size: 14px; }
.custom-holder-status { margin: 10px 2px; color: var(--garam-c-527f99,#527f99); font-size: 13px; font-weight: 700; }
.custom-holder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; overflow: auto; min-height: 120px; }
.custom-holder-option { display: grid; justify-items: center; gap: 4px; padding: 8px; border-radius: 14px; cursor: pointer;
    border: 1px solid var(--garam-c-b9def3,#b9def3); background: var(--garam-c-f0f9ff,#f0f9ff); color: inherit; font: inherit; text-align: center; }
.custom-holder-option:hover, .custom-holder-option:focus-visible { border-color: var(--garam-theme-ui-accent,#087cce); }
.custom-holder-option.is-selected { border-color: var(--garam-theme-ui-accent,#087cce); box-shadow: 0 0 0 2px var(--garam-theme-ui-accent,#087cce); }
.custom-holder-option img { width: 100%; aspect-ratio: 642 / 1032; object-fit: contain; }
.custom-holder-option-name { font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.custom-holder-option small { color: var(--garam-c-527f99,#527f99); font-size: 11px; }
.custom-holder-option-price { display: inline-flex; align-items: center; font-size: 13px; font-weight: 800; color: var(--garam-c-155a8d,#155a8d); }
.custom-holder-pages { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; font-weight: 800; }
.custom-confirm-body { display: grid; gap: 8px; }
.custom-confirm-body > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 11px; background: var(--garam-c-f0f9ff,#f0f9ff); font-size: 14px; }
.custom-confirm-body > div span { color: var(--garam-c-527f99,#527f99); font-weight: 700; }
.custom-confirm-body > div strong { display: inline-flex; align-items: center; text-align: right; overflow-wrap: anywhere; }
.custom-confirm-note { margin: 4px 2px 0; color: var(--garam-c-527f99,#527f99); font-size: 12px; }
.custom-modal .custom-status { margin-top: 12px; }
.custom-result-art { display: grid; place-items: center; padding: 10px; border-radius: 18px; background: var(--garam-c-f0f9ff,#f0f9ff); }
.custom-result-art canvas { max-width: 100%; max-height: 52vh; width: auto; height: auto; }
.custom-result-text p { margin: 8px 0 0; font-weight: 700; }
.custom-result-text code { padding: 2px 8px; border-radius: 8px; background: var(--garam-c-e5f5ff,#e5f5ff); font-size: 15px; }
.custom-result-pending { padding: 9px 12px; border-radius: 11px; background: #fff6e2; color: #7a5300; font-size: 13px; }

/* Dark mode (same tokens as garam_dark.css) */
html[data-garam-mode="dark"] body.garam-shell-body .custom-access,
html[data-garam-mode="dark"] body.garam-shell-body .custom-preview-panel,
html[data-garam-mode="dark"] body.garam-shell-body .custom-modal-panel {
    background: var(--garam-dark-panel); color: var(--garam-dark-text); border-color: var(--garam-dark-border); }
html[data-garam-mode="dark"] body.garam-shell-body .custom-toggle,
html[data-garam-mode="dark"] body.garam-shell-body .custom-drop,
html[data-garam-mode="dark"] body.garam-shell-body .custom-segmented,
html[data-garam-mode="dark"] body.garam-shell-body .custom-holder-selected,
html[data-garam-mode="dark"] body.garam-shell-body .custom-holder-option,
html[data-garam-mode="dark"] body.garam-shell-body .custom-holder-search,
html[data-garam-mode="dark"] body.garam-shell-body .custom-confirm-body > div,
html[data-garam-mode="dark"] body.garam-shell-body .custom-result-art,
html[data-garam-mode="dark"] body.garam-shell-body .garam-custom-page .checklist-filter-field input[type="text"],
html[data-garam-mode="dark"] body.garam-shell-body .custom-select,
html[data-garam-mode="dark"] body.garam-shell-body .custom-modal .checklist-button-outline,
html[data-garam-mode="dark"] body.garam-shell-body .custom-modal-close {
    background: var(--garam-dark-raised); color: var(--garam-dark-text); border-color: var(--garam-dark-border); }
html[data-garam-mode="dark"] body.garam-shell-body .custom-preview-stage { background: var(--garam-dark-hover); }
html[data-garam-mode="dark"] body.garam-shell-body .custom-step legend,
html[data-garam-mode="dark"] body.garam-shell-body .custom-preview-head h2,
html[data-garam-mode="dark"] body.garam-shell-body .custom-holder-selected strong { color: var(--garam-dark-text); }
html[data-garam-mode="dark"] body.garam-shell-body .custom-hint,
html[data-garam-mode="dark"] body.garam-shell-body .custom-label,
html[data-garam-mode="dark"] body.garam-shell-body .custom-preview-note,
html[data-garam-mode="dark"] body.garam-shell-body .custom-drop-text small { color: var(--garam-dark-muted); }

@media (max-width: 1000px) {
    .custom-layout { grid-template-columns: minmax(0, 1fr); }
    .custom-preview-panel { position: static; order: -1; }
    .garam-custom-page #three_dimensional_target { height: min(470px, 56vh); }
}
@media (max-width: 640px) {
    .custom-fields { grid-template-columns: minmax(0, 1fr); }
    .custom-access { flex-direction: column; align-items: flex-start; }
    .custom-submit { justify-content: stretch; }
    .garam-custom-page .custom-create { width: 100%; }
    .custom-holder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
