/* SnapScence - Light Sky Glass UI */
:root {
    --ui-bg: #eaf6ff;
    --ui-bg-2: #dff0ff;
    --ui-panel: rgba(255, 255, 255, 0.66);
    --ui-panel-strong: rgba(255, 255, 255, 0.82);
    --ui-border: rgba(147, 197, 253, 0.45);
    --ui-text: #0f172a;
    --ui-text-soft: #475569;
    --ui-primary-start: #6edbff;
    --ui-primary-end: #3b82f6;
    --ui-shadow-soft: 0 10px 28px rgba(59, 130, 246, 0.12);
    --ui-shadow-card: 0 16px 40px rgba(56, 116, 186, 0.14);
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --control-h: 40px;
    --radius-md: 12px;
    --card-gap-outer: 16px;
    --card-gap-section: 14px;
    --card-gap-field: 10px;
    --card-gap-inline: 8px;
    --card-gap-remaster-to-form: 14px;
    --card-gap-control-to-custom: 12px;
    --card-gap-note: 14px;
}

body {
    font-family: "Plus Jakarta Sans", "Noto Sans TC", sans-serif;
}

body.bg-\[\#eaf6ff\] {
    background:
        radial-gradient(1200px 700px at 0% -10%, rgba(125, 211, 252, 0.32), transparent 58%),
        radial-gradient(900px 500px at 100% 10%, rgba(224, 242, 254, 0.7), transparent 62%),
        linear-gradient(180deg, var(--ui-bg), var(--ui-bg-2));
}

.glass-nav {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--ui-border);
    box-shadow: 0 4px 16px rgba(148, 184, 230, 0.18);
}

.glass-bar {
    background: var(--ui-panel-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-soft);
}

.glass-card,
.command-bar {
    background: linear-gradient(145deg, var(--ui-panel-strong), var(--ui-panel));
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-card);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.btn-primary,
.btn-secondary {
    min-height: var(--control-h);
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--ui-primary-start), var(--ui-primary-end));
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.24);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(59, 130, 246, 0.26);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.45;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.7);
    color: var(--ui-text);
    border: 1px solid rgba(148, 184, 230, 0.5);
    box-shadow: 0 6px 14px rgba(120, 168, 224, 0.16);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(59, 130, 246, 0.4);
}

.pill-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

#base-type-options button.is-active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0369a1;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.35), 0 8px 18px rgba(2, 132, 199, 0.25);
    font-weight: 600;
}

.pill-switch input {
    display: none;
}

.pill-switch .pill-track {
    width: 52px;
    height: 28px;
    background: rgba(148, 184, 230, 0.3);
    border: 1px solid rgba(148, 184, 230, 0.5);
    border-radius: 999px;
    position: relative;
    transition: all 0.25s ease;
}

.pill-switch .pill-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.25);
    transition: all 0.25s ease;
}

.pill-switch input:checked + .pill-track {
    background: linear-gradient(135deg, var(--ui-primary-start), var(--ui-primary-end));
    border-color: rgba(56, 189, 248, 0.6);
}

.pill-switch input:checked + .pill-track::after {
    transform: translateX(24px);
}

.pill-switch .pill-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ui-text-soft);
}

.pill-switch.small .pill-track {
    width: 44px;
    height: 24px;
}

.pill-switch.small .pill-track::after {
    width: 18px;
    height: 18px;
    top: 2px;
    left: 2px;
}

.pill-switch.small input:checked + .pill-track::after {
    transform: translateX(20px);
}

.pill-switch.small .pill-label {
    font-size: 11px;
}

.upload-zone {
    border-color: rgba(125, 211, 252, 0.7);
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.7), rgba(224, 242, 254, 0.56));
    box-shadow: 0 8px 26px rgba(125, 180, 230, 0.12);
    transition: all 0.22s ease;
    padding: clamp(24px, 3vw, 36px);
}

.upload-zone.drag-over {
    border-color: #38bdf8;
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.84), rgba(186, 230, 253, 0.56));
}

.upload-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(148, 184, 230, 0.5);
    color: var(--ui-text);
    box-shadow: 0 4px 12px rgba(148, 184, 230, 0.18);
    min-height: var(--control-h);
}

.upload-btn:hover {
    background: rgba(255, 255, 255, 0.95);
}

.new-batch-layout {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.new-batch-sidebar {
    min-width: 0;
}

.new-batch-detail {
    min-width: 0;
}

.new-batch-control-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
}

.new-batch-mini-button {
    min-height: 30px;
    padding: 5px 10px;
}

.new-batch-download-control {
    display: grid;
    gap: 4px;
    min-width: 220px;
    max-width: min(320px, 100%);
}

.new-batch-download-control .glass-dark {
    width: 100%;
    min-width: 0;
}

.new-batch-regenerate-panel {
    border: 1px solid rgba(148, 184, 230, 0.45);
    background: rgba(255, 255, 255, 0.58);
    border-radius: 14px;
    padding: 10px;
}

.new-batch-regenerate-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.new-batch-help-button {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(148, 184, 230, 0.6);
    background: rgba(255, 255, 255, 0.85);
    color: #2563eb;
    font-size: 12px;
    font-weight: 700;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.new-batch-help-button:hover,
.new-batch-help-button.is-active {
    border-color: rgba(37, 99, 235, 0.45);
    background: rgba(239, 246, 255, 0.95);
    box-shadow: 0 6px 14px rgba(59, 130, 246, 0.12);
}

.new-batch-help-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.new-batch-help-popover {
    position: absolute;
    top: 50%;
    right: 30px;
    transform: translateY(-50%);
    z-index: 20;
    width: min(260px, 70vw);
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(148, 184, 230, 0.5);
    background: rgba(255, 255, 255, 0.96);
    color: #475569;
    box-shadow: 0 14px 32px rgba(65, 112, 172, 0.18);
    font-size: 12px;
    line-height: 1.55;
    text-align: left;
}

.new-batch-help-popover::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -6px;
    width: 10px;
    height: 10px;
    transform: translateY(-50%) rotate(45deg);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(148, 184, 230, 0.5);
    border-right: 1px solid rgba(148, 184, 230, 0.5);
}

.new-batch-template-panel {
    min-width: 0;
    overflow: hidden;
}

.new-batch-template-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.new-batch-template-row + .new-batch-template-row {
    margin-top: 8px;
}

.new-batch-template-row.is-save {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.new-batch-template-row .glass-dark {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.new-batch-template-row button {
    white-space: nowrap;
}

.template-select-control {
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-error {
    border-color: rgba(239, 68, 68, 0.85) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
}

.new-batch-job-row {
    border: 1px solid rgba(148, 184, 230, 0.45);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    padding: 14px;
    cursor: pointer;
    transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.16s ease;
}

.new-batch-job-row:hover,
.new-batch-job-row.is-active {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(255, 255, 255, 0.9);
}

.new-batch-job-row:hover {
    transform: translateY(-1px);
}

.new-batch-item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.new-batch-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.new-batch-image-box {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 14px;
    background: #0f172a;
    border: 1px solid rgba(148, 184, 230, 0.35);
}

.new-batch-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.new-batch-placeholder {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    text-align: center;
    color: #64748b;
    background: rgba(248, 250, 252, 0.88);
    font-size: 12px;
}

.new-batch-arrow {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.76);
    color: #2563eb;
    border: 1px solid rgba(148, 184, 230, 0.5);
    font-weight: 700;
}

@media (max-width: 1024px) {
    .new-batch-layout {
        grid-template-columns: 1fr;
    }
}

.glass-dark {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(148, 184, 230, 0.45);
    color: var(--ui-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.glass-dark::placeholder {
    color: rgba(71, 85, 105, 0.65);
}

/* Bgswap-specific spacing and rhythm */
#main-screen .glass-card {
    border-radius: 24px;
}

#batch-control-panel {
    padding: var(--space-6);
    gap: var(--space-5);
}

#batch-control-panel > .flex:first-child {
    padding-bottom: var(--space-2);
    border-bottom: 1px solid rgba(148, 184, 230, 0.35);
}

#batch-control-panel .grid {
    gap: var(--space-5);
}

#batch-control-panel .space-y-4 > * + * {
    margin-top: var(--space-3);
}

#batch-control-panel .space-y-6 > * + * {
    margin-top: var(--space-4);
}

#batch-control-panel input,
#batch-control-panel select,
#swap-grid input,
#swap-grid select,
#swap-grid textarea {
    min-height: var(--control-h);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    line-height: 1.35;
}

#swap-grid textarea {
    min-height: 72px;
}

#swap-grid > div {
    animation: card-enter 0.22s ease both;
}

#swap-grid .group {
    box-shadow: 0 10px 24px rgba(56, 116, 186, 0.12);
}

#swap-grid .group:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(56, 116, 186, 0.18);
}

#swap-grid .btn-primary,
#swap-grid .btn-secondary,
#batch-control-panel .btn-primary,
#batch-control-panel .btn-secondary {
    min-height: 38px;
    padding: 8px 14px;
}

#batch-control-panel #generate-all {
    min-height: 42px;
    padding: 10px 18px;
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.28);
}

#batch-control-panel #generate-all:hover {
    box-shadow: 0 14px 28px rgba(59, 130, 246, 0.32);
}

#batch-control-panel #apply-global,
#batch-control-panel #save-all,
#batch-control-panel #clear-all {
    background: rgba(255, 255, 255, 0.8);
}

#swap-grid .text-slate-800.text-\[15px\] {
    letter-spacing: 0.005em;
}

#swap-grid .card-title,
#swap-grid .card-meta,
#swap-grid .card-model {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

#swap-grid .card-meta,
#swap-grid .card-model {
    word-spacing: 0.03em;
}

#swap-grid .single-card-controls {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

#swap-grid .single-card-controls .glass-dark {
    background: rgba(255, 255, 255, 0.88);
}

#swap-grid .single-controls-body {
    display: flex;
    flex-direction: column;
    margin-top: var(--card-gap-section);
    gap: var(--card-gap-section);
}

#swap-grid .single-control-group {
    display: flex;
    flex-direction: column;
    gap: var(--card-gap-field);
}

#swap-grid .single-custom-input {
    margin-top: calc(var(--card-gap-control-to-custom) - var(--card-gap-field));
}

#swap-grid .card-stack {
    display: flex;
    flex-direction: column;
    gap: var(--card-gap-outer);
}

#swap-grid .card-config-block {
    padding-bottom: var(--card-gap-inline);
    border-bottom: 1px solid rgba(148, 184, 230, 0.22);
}

#swap-grid .card-remaster-row {
    margin-top: var(--card-gap-section);
    padding-bottom: var(--card-gap-remaster-to-form);
}

#swap-grid .card-form-body {
    display: flex;
    flex-direction: column;
    gap: var(--card-gap-section);
}

#swap-grid .card-batch-hint {
    margin-top: var(--card-gap-field);
}

#swap-grid .card-config-block + .card-form-body {
    margin-top: var(--card-gap-remaster-to-form);
}

#swap-grid .card-field-control {
    min-height: var(--control-h);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    line-height: 1.35;
}

#swap-grid .card-note-wrapper {
    margin-top: var(--card-gap-note);
    margin-bottom: var(--card-gap-note);
}

#swap-grid .card-note-wrapper textarea {
    padding: 12px 14px;
    line-height: 1.45;
}

#swap-grid .card-note-wrapper .note-counter {
    bottom: 10px;
    right: 12px;
}

#swap-grid .card-error {
    margin-top: 2px;
}

#swap-grid .card-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--card-gap-inline);
    padding-top: 4px;
}

#loading-overlay {
    background: rgba(148, 163, 184, 0.35);
}

@keyframes card-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Enhanced Text Overlay Editor
   ============================================ */

.text-overlay {
    position: absolute;
    cursor: grab;
    user-select: none;
    transition: all 0.15s ease-out;
    outline: 2px dashed transparent;
    padding: 8px 12px;
    border-radius: 6px;
    z-index: 10;
}

.text-overlay:hover,
.text-overlay.active {
    outline-color: rgba(99, 102, 241, 0.6);
    background: rgba(0, 0, 0, 0.1);
    z-index: 40;
}

.text-overlay.dragging {
    cursor: grabbing;
    outline-color: #6366f1;
    outline-width: 3px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: none;
    z-index: 50;
}

.text-overlay.editing {
    outline-color: #22c55e;
    outline-width: 3px;
    cursor: text;
    background: rgba(0, 0, 0, 0.2);
    z-index: 50;
}

/* Enhanced Floating Toolbar - Two Row Layout */
.overlay-toolbar-enhanced {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    --toolbar-offset-x: 0px;
    transform: translateX(calc(-50% + var(--toolbar-offset-x)));
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 14px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    transform: translateX(calc(-50% + var(--toolbar-offset-x))) translateY(8px);
}

/* 工具列在下方的樣式（當上方空間不足時） */
.overlay-toolbar-enhanced.toolbar-bottom {
    bottom: auto;
    top: calc(100% + 12px);
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.text-overlay:hover .overlay-toolbar-enhanced,
.text-overlay.active .overlay-toolbar-enhanced,
.text-overlay.editing .overlay-toolbar-enhanced {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(calc(-50% + var(--toolbar-offset-x))) translateY(0);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

.toolbar-select {
    padding: 6px 10px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 14px;
    padding-right: 26px;
}

.toolbar-select:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.toolbar-select:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.25);
}

.toolbar-select option {
    background: #1e293b;
    color: white;
}

.toolbar-btn {
    padding: 6px 10px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.toolbar-btn:active {
    transform: scale(0.95);
}

.toolbar-btn.active {
    background: rgba(99, 102, 241, 0.8);
}

.toolbar-btn.toolbar-delete {
    color: #f87171;
}

.toolbar-btn.toolbar-delete:hover {
    background: rgba(248, 113, 113, 0.3);
}

.toolbar-toggle.active {
    background: rgba(99, 102, 241, 0.8);
}

.toolbar-size-group .toolbar-btn {
    min-width: 32px;
}

.toolbar-align-group .toolbar-btn {
    min-width: 28px;
    font-size: 14px;
}

.toolbar-align-btn {
    font-family: monospace;
}

/* Color Picker */
.color-picker-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: border-color 0.15s;
}

.color-picker-wrapper:hover {
    border-color: rgba(255, 255, 255, 0.4);
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    top: -8px;
    left: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    border: none;
    cursor: pointer;
    background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Quick Color Preset Buttons */
.toolbar-color-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-preset-row {
    display: flex;
    gap: 3px;
}

.color-preset-btn {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.color-preset-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-preset-btn.active {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}

.color-picker-small {
    width: 24px;
    height: 24px;
}

/* Overlay Hint */
.overlay-hint {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.text-overlay:hover .overlay-hint,
.text-overlay.active .overlay-hint {
    opacity: 1;
}

.text-overlay.editing .overlay-hint,
.text-overlay.dragging .overlay-hint {
    opacity: 0;
}

/* ============================================
   Shimmer / Loading
   ============================================ */

.shimmer-circle {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe, #a5b4fc, #c7d2fe, #e0e7ff);
    background-size: 300% 300%;
    animation: shimmer 2s ease-in-out infinite;
}

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

.loading-bar {
    animation: loading-progress 2s ease-in-out infinite;
}

@keyframes loading-progress {
    0% { width: 5%; }
    50% { width: 70%; }
    100% { width: 95%; }
}

/* Toast notifications */
.toast {
    padding: 12px 20px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toast-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: 360px;
}

.toast.toast-error {
    border-left: 4px solid #ef4444;
}

.toast.toast-success {
    border-left: 4px solid #22c55e;
}

.toast.toast-info {
    border-left: 4px solid #6366f1;
}

.toast.removing {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* Spring transition utility */
.spring-enter {
    animation: spring-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes spring-in {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Skeleton shimmer for cards */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 24px;
}

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

/* Responsive */
@media (max-width: 640px) {
    #swap-grid {
        --card-gap-outer: 12px;
        --card-gap-section: 10px;
        --card-gap-field: 10px;
        --card-gap-inline: 8px;
        --card-gap-remaster-to-form: 10px;
        --card-gap-control-to-custom: 10px;
        --card-gap-note: 10px;
    }

    #action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #action-bar button {
        width: 100%;
        justify-content: center;
    }

    #action-bar #selected-count {
        text-align: center;
    }

    .glass-bar {
        left: 16px;
        right: 16px;
        transform: none;
    }

    .overlay-toolbar-enhanced {
        padding: 6px 8px;
        gap: 2px;
        border-radius: 10px;
    }

    .toolbar-select {
        padding: 4px 6px;
        padding-right: 20px;
        font-size: 11px;
    }

    .toolbar-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .toolbar-divider {
        margin: 0 2px;
    }

    .color-preset-btn {
        width: 18px;
        height: 18px;
    }

    .color-picker-small {
        width: 20px;
        height: 20px;
    }

    #main-screen {
        gap: 12px;
    }

    #batch-control-panel {
        padding: 16px;
    }

    #batch-control-panel .flex.flex-wrap {
        gap: 8px;
    }

    #swap-grid {
        gap: 14px;
    }

    #swap-grid .group .p-5 {
        padding: 14px;
    }
}

@media (max-width: 360px) {
    #swap-grid {
        --card-gap-outer: 10px;
        --card-gap-section: 10px;
        --card-gap-note: 10px;
    }

    #batch-control-panel .flex.flex-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    #batch-control-panel .btn-primary,
    #batch-control-panel .btn-secondary {
        width: 100%;
    }

    #swap-grid .card-action-grid {
        grid-template-columns: 1fr;
    }

    #swap-grid .card-action-grid .btn-primary,
    #swap-grid .card-action-grid .btn-secondary {
        width: 100%;
    }
}

/* Container Query Support for Text */
@supports (container-type: size) {
    .card-image {
        container-type: size;
    }
}

/* ============================================
   Glass Morphism for Modals
   ============================================ */

/* 亮色玻璃擬態（輸入框與彈窗） */
.glass-dark {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 184, 230, 0.45);
    color: var(--ui-text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

/* 儲存對話框 */
.save-dialog-content {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 184, 230, 0.45);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.45),
        0 20px 60px rgba(71, 118, 175, 0.24);
    color: var(--ui-text);
}

.save-option-btn {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(148, 184, 230, 0.35);
    color: var(--ui-text);
    transition: all 0.2s;
}

.save-option-btn:hover {
    background: rgba(219, 234, 254, 0.85);
    border-color: rgba(59, 130, 246, 0.35);
}

.save-option-icon {
    background: rgba(59, 130, 246, 0.14);
    padding: 10px;
    border-radius: 12px;
    color: #2563eb;
}

/* Payment Modal Styles */
.payment-modal-content {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 20px 60px rgba(0, 0, 0, 0.5);
    color: #f0f0f5;
}

.payment-modal-content .border-slate-200 {
    border-color: rgba(255, 255, 255, 0.1);
}

.payment-modal-content .border-brand-500 {
    border-color: rgba(99, 102, 241, 0.6);
}

.payment-modal-content .text-brand-600 {
    color: #a5b4fc;
}

.payment-modal-content span.absolute {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
}
.command-bar {
    position: sticky;
    top: 76px;
    z-index: 20;
}

@media (max-width: 768px) {
    .command-bar {
        top: 64px;
    }
}
