/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Page Transition (presentation-style vertical slide) ----------------- */
/* Opt in to cross-document view transitions on same-origin navigation.     */
@view-transition { navigation: auto; }

/* Tag the regions so each can be animated (or not) independently.          */
.sidebar-wrapper      { view-transition-name: app-sidebar; }
.separator-line       { view-transition-name: app-separator; }
.main-content         {
    view-transition-name: app-main;
    /* Pre-promote to a GPU composited layer so the snapshot capture is fast  */
    will-change: transform;
    /* Isolate layout/paint to this subtree                                   */
    contain: layout style;
}

/* The sidebar and separator must stay fully visible during the transition. */
::view-transition-group(app-sidebar),
::view-transition-group(app-separator) {
    animation-duration: 0s;
}
::view-transition-old(app-sidebar),
::view-transition-new(app-sidebar),
::view-transition-old(app-separator),
::view-transition-new(app-separator) {
    animation: none !important;
    mix-blend-mode: normal;
}

/* The root snapshot must not fade — it would reveal a white flash.         */
::view-transition-old(root),
::view-transition-new(root) {
    animation: none !important;
    mix-blend-mode: normal;
}

/* Both snapshots stay fully opaque; only transform is animated.            */
::view-transition-old(app-main),
::view-transition-new(app-main) {
    mix-blend-mode: normal;
    /* Force GPU compositing on the pseudo-element itself                     */
    will-change: transform;
    backface-visibility: hidden;
    /* Prevent sub-pixel rounding artifacts                                   */
    transform-style: flat;
}

/* Clip slides to the group's bounding box — prevents overflow artifacts.   */
::view-transition-group(app-main) {
    overflow: hidden;
}

/* ─── Keyframes ─────────────────────────────────────────────────────────── */
/* Use translate() (single-axis shorthand) instead of translateY() so the   */
/* browser can skip the full matrix decomposition on every frame.           */
@keyframes mt-slide-out-up   { to { translate: 0 -100%; } }
@keyframes mt-slide-out-down { to { translate: 0  100%; } }
@keyframes mt-slide-in-up    { from { translate: 0  100%; } }
@keyframes mt-slide-in-down  { from { translate: 0 -100%; } }

/* ─── Easing ─────────────────────────────────────────────────────────────  */
/* Smooth ease-out curve — fast at start, gentle deceleration at end.       */
/* 360 ms: quick enough to feel instant, long enough to register.           */
:root {
    --slide-duration: 360ms;
    --slide-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html.nav-forward::view-transition-old(app-main) {
    animation: mt-slide-out-up var(--slide-duration) var(--slide-ease) both;
}
html.nav-forward::view-transition-new(app-main) {
    animation: mt-slide-in-up var(--slide-duration) var(--slide-ease) both;
}

html.nav-backward::view-transition-old(app-main) {
    animation: mt-slide-out-down var(--slide-duration) var(--slide-ease) both;
}
html.nav-backward::view-transition-new(app-main) {
    animation: mt-slide-in-down var(--slide-duration) var(--slide-ease) both;
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --slide-duration: 1ms;
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #333;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Layout Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Sidebar --- */
.sidebar-wrapper {
    display: flex;
    align-items: center;
    padding-left: 20px;
    height: 100%;
    z-index: 10;
}

.sidebar {
    width: 64px;
    background-color: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 999px;
    display: flex;
    flex-direction: column;
    gap: 120px;
    padding: 32px 0;
    box-shadow: none;
}

.separator-line {
    width: 1px;
    height: 100vh;
    background-color: #f4f4f4;
    margin: 0 16px;
}

.nav-top,
.nav-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #999;
    gap: 8px;
    transition: all 0.2s ease;
}

.nav-item-button {
    appearance: none;
    background: transparent;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.nav-item:hover {
    color: #333;
}

.logo-container {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-logo {
    width: 62px;
    height: 62px;
    object-fit: contain;
}

.icon-box {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 22px;
    color: #a0a0a0;
    transition: all 0.2s ease;
}

.nav-item.active .icon-box {
    background-color: #f4f4f4;
    color: #333;
}

.nav-item.active span,
.nav-item.is-open span {
    color: #333;
}

.nav-item.is-open .icon-box {
    background-color: #f4f4f4;
    color: #333;
}

.nav-item span {
    font-size: 8px;
    font-weight: 400;
    letter-spacing: 0.3px;
    color: #a0a0a0;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    height: 100%;
    padding: 16px 16px 16px 0;
    /* removed left padding */
    gap: 24px;
}

/* --- Control Panel (Middle) --- */
.control-panel {
    width: 420px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    padding-top: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 0;
    isolation: isolate;
}

/* Upload Area */
.upload-area {
    background: #ffffff;
    border-radius: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    min-height: 480px;
    cursor: pointer;
    transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.4s ease;
    position: relative;
    overflow: hidden;
    z-index: 0;
    isolation: isolate;
}

.upload-area.has-preview {
    cursor: default;
    background: #ffffff;
    padding: 16px 16px 12px;
    min-height: unset;
    justify-content: flex-start;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.11) 1px, transparent 1px);
    background-size: 8px 8px;
    -webkit-mask-image: radial-gradient(circle 140px at var(--mouse-x, 50%) var(--mouse-y, 50%), black 0%, transparent 100%);
    mask-image: radial-gradient(circle 140px at var(--mouse-x, 50%) var(--mouse-y, 50%), black 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.upload-area::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.15' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 180px 180px;
    opacity: 0.035;
    mix-blend-mode: multiply;
    z-index: 0;
}

.upload-area:not(.has-preview):hover::before {
    opacity: 1;
}

.upload-area.drag-over {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.2);
}

/* ── default upload state ── */
.upload-default {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
}

/* ── preview state ── */
.upload-preview {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 12px;
    cursor: default;
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    z-index: 2;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dynamic Grid for Multiple Images */
.preview-images-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex: 1;
    align-content: center;
}

/* Image Wrapper — compact uniform thumbnails */
.preview-image-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    background: #f4f4f4;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.preview-image-wrapper::after {
    display: none;
}

.preview-image-wrapper:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.preview-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    padding: 0;
    filter: none;
}

.preview-images-grid.count-1 .preview-image-wrapper img {
    object-fit: cover;
    padding: 0;
}

/* Individual Image Delete Overlay */
.single-remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    background: #ffffff;
    border: none;
    border-radius: 50%;
    color: #111;
    font-size: 11px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transform: scale(0.9);
}

.preview-image-wrapper:hover .single-remove-btn {
    opacity: 1;
    transform: scale(1);
}

.single-remove-btn:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

/* Hidden — actions moved to pill */
.preview-actions {
    display: none;
}

/* Compact pill card below thumbnail */
.preview-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 999px;
    padding: 4px 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: fit-content;
    margin: 0 auto;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}


.preview-meta-name {
    display: none;
}

.preview-meta-size {
    display: none;
}

/* Pill action buttons */
.preview-meta-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.preview-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #777;
    font-size: 13px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
    padding: 0;
    font-family: inherit;
}

.preview-action-btn:hover {
    color: #111;
    background: rgba(0, 0, 0, 0.06);
    transform: scale(1.1);
}

.upload-icon {
    margin-bottom: 12px;
}

.upload-area p {
    font-size: 16px;
    font-weight: 300;
    color: #111;
    margin-bottom: 16px;
}

.tags {
    display: flex;
    gap: 8px;
}

.tag {
    font-size: 11px;
    padding: 4px 10px;
    background-color: #ffffff;
    border: 1px solid #d1d1d1;
    border-radius: 6px;
    color: #333;
    cursor: pointer;
}

/* Material Input */
.input-group {
    background-color: #ffffff;
    border: 1px solid #efefef;
    border-radius: 10px;
    padding: 12px 14px;
}

.dropdown-container {
    position: relative;
    cursor: pointer;
}

.material-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #efefef;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    gap: 12px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.10);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    pointer-events: none;
}

.material-dropdown.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.material-option {
    width: 60px;
    aspect-ratio: 9/16;
    background-color: #f4f4f4;
    border-radius: 8px;
    border: 1px solid #ebebeb;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.material-option:hover {
    border-color: #d1d1d1;
}

.material-option.is-selected {
    border-color: #9aa8c0;
    box-shadow: 0 0 0 2px rgba(154, 168, 192, 0.25);
}

.material-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.material-icon-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.material-icon-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.material-input input {
    border: none;
    outline: none;
    font-size: 13px;
    color: #999;
    width: 100%;
    font-family: inherit;
}

/* Prompt Area */
.prompt-area {
    background-color: #ffffff;
    border: 1px solid #efefef;
    border-radius: 10px;
    padding: 14px;
    min-height: 165px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: visible;
}

.prompt-area::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 65%;
    height: 80%;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.13) 1px, transparent 1px);
    background-size: 7px 7px;
    -webkit-mask-image: radial-gradient(ellipse at 100% 100%, black 0%, transparent 68%);
    mask-image: radial-gradient(ellipse at 100% 100%, black 0%, transparent 68%);
    z-index: 0;
    border-radius: 0 0 10px 0;
}

.prompt-area textarea {
    border: none;
    outline: none;
    resize: none;
    width: 100%;
    flex: 1;
    font-family: inherit;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    position: relative;
    z-index: 1;
    background: transparent;
}

.prompt-area textarea::placeholder {
    color: #c4c4c4;
}

.prompt-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 10px;
    position: relative;
    z-index: 1;
}

.text-prompt-btn,
.language-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: transparent;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    background-color: #ffffff;
}

.language-trigger {
    min-width: 88px;
    justify-content: center;
    padding: 4px 12px;
}

.text-prompt-btn i {
    font-size: 12px;
}

.language-dropdown {
    position: relative;
    display: flex;
    align-items: flex-end;
}

.language-trigger:hover {
    border-color: #d4d4d4;
}

.language-trigger-flag {
    font-size: 12px;
    line-height: 1;
}

.language-trigger-label {
    font-size: 11px;
    font-weight: 500;
    color: #666;
}

.language-menu {
    position: fixed;
    min-width: 192px;
    padding: 8px;
    border: 1px solid #e3e6eb;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 18px 40px rgba(17, 17, 17, 0.1);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
    z-index: 9999;
}

.language-dropdown.is-open .language-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.language-option {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
    font-size: 12px;
    color: #3d3d3d;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.language-option:hover,
.language-option.is-selected {
    background-color: #f5f6f8;
    color: #111111;
}

.language-option-flag {
    font-size: 16px;
    line-height: 1;
}

.language-option-name {
    white-space: nowrap;
}

/* Generate Button */
.generate-btn {
    align-self: flex-end;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    background: #ffffff;
    border: 0.5px solid rgba(154, 168, 192, 0.35);
    border-radius: 8px;
    padding: 3px 14px;
    color: #334155;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    margin-top: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.generate-btn:disabled {
    cursor: progress;
    opacity: 0.72;
    box-shadow: none;
}

.generate-btn:hover {
    background: #ffffff;
    border-color: rgba(129, 146, 176, 0.45);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.09), 0 1px 3px rgba(0, 0, 0, 0.05);
}

.generate-btn-icon {
    width: 27px;
    height: 27px;
    object-fit: contain;
    display: block;
}

.generate-wordmark {
    width: 68px;
    height: auto;
    display: block;
}

/* --- Canvas Area (Right) --- */
.canvas-area {
    flex: 1;
    background-color: transparent;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    height: calc(100vh - 32px);
    z-index: 1;
}

.canvas-area::before {
    content: '';
    position: absolute;
    bottom: -350px;
    right: -350px;
    width: 700px;
    height: 700px;
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
    /* 3色の光: うすい青、うすい綺麗な黄緑、白 (薄めの色味へ調整) */
    background:
        radial-gradient(circle at 30% 70%, rgba(210, 222, 245, 0.8) 0%, transparent 55%),
        radial-gradient(circle at 70% 30%, rgba(195, 245, 190, 0.8) 0%, transparent 55%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.9) 0%, transparent 55%);
    filter: blur(60px);
    animation: floatingLights 12s infinite alternate ease-in-out;
}

@keyframes floatingLights {
    0% {
        transform: rotate(0deg) scale(1) translate(0, 0);
    }

    50% {
        transform: rotate(90deg) scale(1.1) translate(-30px, -50px);
    }

    100% {
        transform: rotate(180deg) scale(1) translate(20px, -20px);
    }
}

.canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.token-display {
    position: absolute;
    top: 22px;
    right: 22px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: #ffffff;
    border: 0.8px solid #8d8d8d;
    border-radius: 10px;
    color: #111111;
    box-shadow: 0 4px 14px rgba(17, 17, 17, 0.06);
    appearance: none;
    font: inherit;
}

.token-display-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.token-display-label i {
    font-size: 13px;
    line-height: 1;
}

.token-display-value {
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: #5f5f5f;
}

.token-display.is-hidden-by-settings {
    display: none;
}

.credits-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50000;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.credits-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.credits-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 430px;
    z-index: 50001;
    background: #ffffff;
    border: 1px solid #ececec;
    border-radius: 22px;
    padding: 16px;
    box-shadow: 0 22px 48px rgba(17, 17, 17, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, calc(-50% - 10px));
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
}

.credits-popup.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.credits-popup-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 20px;
    margin-bottom: 18px;
    border-bottom: 1px solid #efefef;
    position: relative;
}

.credits-popup-header-copy {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 112px;
}

.credits-popup-mark {
    position: absolute;
    top: 6px;
    right: -2px;
    width: 94px;
    height: auto;
    display: block;
    object-fit: contain;
    pointer-events: none;
}

.credits-popup-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: #111111;
    line-height: 1.1;
}

.credits-popup-description {
    max-width: 250px;
    font-size: 12px;
    line-height: 1.4;
    color: #707070;
}

.credits-popup-secondary-action {
    width: fit-content;
    padding: 8px 11px;
    border: 1px solid #e7e7e7;
    border-radius: 10px;
    background: #ffffff;
    color: #222222;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.credits-popup-secondary-action:hover {
    background: #f8f8f8;
    border-color: #dcdcdc;
}

.credits-popup-balance-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #fcfcfc 100%);
    border: 1px solid #ededed;
    border-radius: 16px;
    box-shadow: 0 12px 24px rgba(17, 17, 17, 0.05);
}

.credits-popup-balance-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.credits-popup-balance-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #666666;
}

.credits-popup-balance-status {
    font-size: 11px;
    font-weight: 500;
    color: #6b6b6b;
    padding: 4px 8px;
    background: #ffffff;
    border: 1px solid #ededed;
    border-radius: 8px;
}

.credits-popup-balance-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.credits-popup-balance {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #111111;
    line-height: 1;
}

.credits-popup-balance-unit {
    font-size: 12px;
    font-weight: 500;
    color: #5c5c5c;
    text-transform: lowercase;
}

.credits-popup-balance-bar {
    position: relative;
    width: 100%;
    height: 10px;
    overflow: hidden;
    background: #efefef;
    border-radius: 999px;
}

.credits-popup-balance-fill {
    display: block;
    width: 62%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #111111 0%, #7a7a7a 100%);
}

.credits-pricing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.credits-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid #ebebeb;
    border-radius: 16px;
}

.credits-card-featured {
    background: #fbfbfb;
    border-color: #e7e7e7;
}

.credits-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.credits-card-name {
    font-size: 14px;
    font-weight: 500;
    color: #111111;
    letter-spacing: -0.02em;
}

.credits-card-price {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: #111111;
    line-height: 1;
}

.credits-card-price-period {
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0;
    color: #666666;
}

.credits-card-amount {
    font-size: 13px;
    font-weight: 500;
    color: #313131;
}

.credits-card-benefits {
    list-style: none;
    min-height: 56px;
    margin: 0;
    padding-left: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #666666;
}

.credits-card-benefits li {
    position: relative;
    padding-left: 18px;
}

.credits-card-benefits li::before {
    content: "\2713";
    position: absolute;
    top: 0;
    left: 0;
    font-size: 11px;
    font-weight: 600;
    color: #111111;
}

.credits-card-benefits li + li {
    margin-top: 4px;
}

.credits-card-action {
    margin-top: auto;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    background: #ffffff;
    color: #111111;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.credits-card-action:hover {
    background: #f7f7f7;
    border-color: #d6d6d6;
}

.settings-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60000;
    background: rgba(76, 76, 76, 0.26);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.settings-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.settings-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 60001;
    width: min(780px, calc(100vw - 56px), calc((100vh - 40px) * 1.5));
    aspect-ratio: 3 / 2;
    display: flex;
    background: #ffffff;
    border: none;
    border-radius: 26px;
    box-shadow: 0 24px 64px rgba(17, 17, 17, 0.1);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, calc(-50% - 10px));
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
}

.settings-popup.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.settings-sidebar-panel {
    width: 196px;
    padding: 0 12px 18px;
    border-right: 1px solid rgba(17, 17, 17, 0.06);
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.settings-brand {
    display: flex;
    align-items: flex-start;
    padding: 0 2px 0;
    min-height: 0;
    margin-top: -12px;
}

.settings-brand-mark {
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.settings-brand-mark img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    display: block;
    transform: translateX(4px) translateY(-10px) scale(1.08);
    transform-origin: center top;
}


.settings-nav-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: -20px;
}

.settings-nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: #666666;
    font: inherit;
    font-size: 15px;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.settings-nav-item i {
    font-size: 20px;
    line-height: 1;
}

.settings-nav-item.is-active {
    background: #f4f4f4;
    color: #111111;
}

.settings-sidebar-note {
    margin-top: auto;
    padding: 16px 8px 2px;
    border-top: none;
}

.settings-sidebar-note-label {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #999999;
}

.settings-sidebar-note p {
    font-size: 12px;
    line-height: 1.5;
    color: #696969;
}

.settings-main-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.settings-popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 22px 14px;
    border-bottom: none;
}

.settings-popup-header-copy h2 {
    font-size: 18px;
    font-weight: 500;
    letter-spacing: -0.04em;
    color: #111111;
    line-height: 1.1;
}

.settings-popup-header-copy p {
    margin-top: 8px;
    max-width: 460px;
    font-size: 13px;
    line-height: 1.55;
    color: #737373;
}

.settings-popup-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    background: #f4f4f4;
    color: #666666;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.settings-popup-close:hover {
    background: #ededed;
    color: #111111;
}

.settings-popup-close i {
    font-size: 18px;
}

.settings-popup-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 22px 20px;
}

.settings-panel {
    display: none;
}

.settings-panel.is-active {
    display: block;
}

.settings-group {
    padding: 18px 0 6px;
}

.settings-group-label {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #8e8e8e;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0;
    border-top: none;
}

.settings-copy {
    max-width: 500px;
}

.settings-copy strong {
    display: block;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: -0.02em;
    color: #111111;
}

.settings-copy p {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.55;
    color: #7a7a7a;
}

.settings-select-wrapper {
    position: relative;
    min-width: 190px;
    flex-shrink: 0;
}

.settings-select {
    width: 100%;
    height: 50px;
    padding: 0 46px 0 16px;
    border: none;
    border-radius: 14px;
    background: #f4f4f4;
    color: #111111;
    font-family: inherit;
    font-size: 15px;
    font-weight: 400;
    appearance: none;
    cursor: pointer;
}

.settings-select:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.04);
}

.settings-select-wrapper i {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    font-size: 16px;
    color: #666666;
    pointer-events: none;
}

.settings-switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 26px;
    padding: 3px;
    border: none;
    border-radius: 999px;
    background: #d8d8d5;
    cursor: pointer;
    transition: background-color 0.18s ease;
}

.settings-switch.is-on {
    background: #545454;
}

.settings-switch-thumb {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(17, 17, 17, 0.14);
    transition: transform 0.18s ease;
}

.settings-switch.is-on .settings-switch-thumb {
    transform: translateX(18px);
}

.settings-account-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border: none;
    border-radius: 20px;
    background:
        radial-gradient(circle at top right, rgba(17, 17, 17, 0.03) 0%, rgba(17, 17, 17, 0) 26%),
        linear-gradient(180deg, #ffffff 0%, #fbfbfa 100%);
    box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.05);
}

.settings-account-card-top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.settings-account-avatar {
    width: 52px;
    height: 52px;
    border-radius: 999px;
    background: linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 100%);
    color: #111111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    overflow: hidden;
}

.settings-account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 999px;
    display: block;
}

.settings-account-copy {
    min-width: 0;
    flex: 1;
}

.settings-account-eyebrow {
    display: inline-block;
    margin-bottom: 5px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9a9a9a;
}

.settings-account-copy strong {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: #111111;
    letter-spacing: -0.02em;
}

.settings-account-copy p {
    margin-top: 4px;
    font-size: 13px;
    color: #707070;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-account-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 11px;
    border: none;
    border-radius: 999px;
    background: #f4f4f4;
    color: #3b3f46;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
}

.settings-account-badge i {
    font-size: 14px;
}

.settings-account-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.settings-account-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    background: #f4f4f4;
    color: #595959;
    font-size: 12px;
    font-weight: 400;
}

.settings-account-meta-item i {
    font-size: 13px;
    color: #7a7a7a;
}

.settings-account-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.settings-account-summary-card {
    padding: 16px;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.08);
}

.settings-account-summary-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #969696;
}

.settings-account-summary-card strong {
    display: block;
    margin-top: 10px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
    color: #111111;
    letter-spacing: -0.02em;
}

.settings-account-summary-card p {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.45;
    color: #767676;
}

/* --- Toast Notification System --- */
#toast-container {
    position: fixed;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
    pointer-events: none;
    max-width: 90%;
}

.custom-toast {
    display: flex;
    align-items: center;
    gap: 8px;
    /* アイコン用の隙間 */
    background: #ffffff;
    padding: 12px 20px;
    border: 1px solid #eef0f3;
    border-radius: 12px;
    /* 少し丸くして柔らかい印象に */
    font-size: 14px;
    font-weight: 500;
    color: #111111;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

.custom-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.custom-toast i {
    font-size: 18px;
    color: #555555;
    /* アイコンは少し控えめな黒で細さを強調 */
}

/* --- Publish Component --- */
.publish-component-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    top: -35px;
    padding: 20px;
    box-sizing: border-box;
    font-family: inherit;
    transform: scale(0.93);
    transform-origin: center;
}

.status-pill {
    background: #f1f2f3;
    color: #555;
    padding: 10px 24px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 30px;
}

.publish-main-layout {
    display: flex;
    align-items: center;
    gap: 30px;
}

.pagination-dots {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pagination-dots .dot {
    width: 8px;
    height: 8px;
    background: #dbdbdb;
    border-radius: 50%;
    transition: all 0.2s;
}

.pagination-dots .dot.active {
    background: #111;
}

.carousel-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f7f7f7;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: #111;
    transition: all 0.2s;
}

.control-btn:hover {
    background: #e5e5e5;
}

.animated-card-stack-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding-top: 8px;
}

.card-stack-nav {
    position: absolute;
    right: 30px;
    bottom: 142px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 20;
}

.card-stack-nav-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: #111;
    transition: background 0.15s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.card-stack-nav-btn:hover {
    background: #f0f0f0;
}

.card-stack-nav-btn:active {
    transform: scale(0.93);
}

.animated-card-stack {
    position: relative;
    height: 425px;
    width: 100%;
    max-width: 644px;
    overflow: visible;
}

.card-stack-dots {
    position: absolute;
    left: 40px;
    top: 261px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
}

.card-stack-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c0c0c0;
    transition: background 0.15s ease-in-out;
}

.card-stack-dot.active {
    background: #111;
}

.animated-card-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.anim-card {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 512px;
    height: 352px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    will-change: transform;
    transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.anim-card-image-wrap {
    position: relative;
    width: 100%;
    height: 270px;
    border-radius: 12px;
    overflow: hidden;
    outline: 1px solid rgba(0, 0, 0, 0.1);
    outline-offset: -1px;
}

.anim-card-image-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.08;
    mix-blend-mode: overlay;
}

.anim-card-image-wrap img,
.anim-card-image-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    user-select: none;
}

.anim-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 12px 56px;
}

.anim-card-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.anim-card-title {
    font-size: 14px;
    font-weight: 400;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anim-card-desc {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

.anim-card-read-btn {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 40px;
    padding: 0 12px 0 16px;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.anim-card-read-btn svg {
    width: 16px;
    height: 16px;
}


.publish-mockup-area {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    height: 420px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

/* Background gradient inspired by the provided image */
.mockup-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 50% 120%, #70D59D 0%, transparent 60%),
        radial-gradient(circle at top right, #32B669 0%, transparent 40%),
        radial-gradient(circle at top left, #AEE4CD 0%, #E9F6F0 100%),
        linear-gradient(135deg, #AEE4CD 0%, #eefbf5 100%);
    z-index: 0;
}

.mockup-bg.is-hidden {
    display: none;
}

.browser-floating-mockup {
    position: relative;
    z-index: 1;
    width: 95%;
    height: 92%;
    margin-bottom: 0px;
    background: #fff;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.browser-floating-mockup.is-hidden {
    display: none;
}

.browser-header {
    background: #fdfdfd;
    border-bottom: 1px solid #ededed;
    display: flex;
    align-items: flex-end;
    padding: 0 12px;
    height: 38px;
}

.mac-dots {
    display: flex;
    gap: 6px;
    padding-bottom: 12px;
    margin-right: 16px;
}

.mac-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-red {
    background: #ff5f56;
}

.dot-yellow {
    background: #ffbd2e;
}

.dot-green {
    background: #27c93f;
}

.browser-tabs {
    display: flex;
    gap: 4px;
}

.browser-tabs .tab {
    padding: 6px 12px;
    border-radius: 8px 8px 0 0;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
    background: transparent;
    max-width: 160px;
}

.browser-tabs .tab.active {
    background: #fff;
    border-top: 1px solid #ededed;
    border-left: 1px solid #ededed;
    border-right: 1px solid #ededed;
    color: #111;
    box-shadow: 0 1px 0 #fff;
    position: relative;
    margin-bottom: -1px;
    padding-bottom: 7px;
}

.mocha-favicon {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #e07a5f;
}

.browser-toolbar {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid #ededed;
    gap: 16px;
    background: #fff;
}

.nav-arrows {
    display: flex;
    gap: 12px;
    color: #666;
    font-size: 14px;
}

.url-bar {
    flex: 1;
    background: #f1f1f1;
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 12px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ext-icons {
    display: flex;
    gap: 12px;
    color: #555;
    align-items: center;
    font-size: 14px;
}

.profile-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ebdec2;
    color: #a46d3e;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.browser-body {
    display: flex;
    flex: 1;
    background: #fafafa;
    position: relative;
    overflow: hidden;
}

.mock-sidebar {
    width: 140px;
    border-right: 1px solid #ededed;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-item {
    padding: 6px 8px;
    font-size: 11px;
    color: #555;
    border-radius: 6px;
    cursor: default;
}

.sidebar-item.active {
    background: #f0f4ff;
    color: #3b82f6;
    font-weight: 500;
}

.mock-content {
    flex: 1;
    padding: 0 20px;
    background: #fff;
    display: flex;
    flex-direction: column;
    position: relative;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid #eaeaea;
    padding-top: 16px;
}

.header-nav {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #666;
}

.header-nav span {
    padding-bottom: 10px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.header-nav span.active {
    color: #111;
    font-weight: 500;
    border-bottom-color: #111;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    font-size: 12px;
    color: #555;
}

.primary-btn {
    background: #f0f4ff;
    color: #3b82f6;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.primary-btn i {
    font-size: 14px;
}

.primary-btn.dark {
    background: #111;
    color: #fff;
}

.primary-btn.dark i {
    color: #fff;
}

.secondary-btn {
    background: #f5f5f5;
    color: #333;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.content-body {
    padding: 24px 0;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.main-settings {
    flex: 1;
}

.main-settings h2 {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 24px 0;
    color: #111;
}

.setting-row {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-row label {
    font-size: 11px;
    color: #555;
    width: 80px;
}

.input-group-mock {
    display: flex;
    align-items: center;
    border: 1px solid #dfdfdf;
    border-radius: 6px;
    overflow: hidden;
    padding: 0;
    height: 30px;
    background: #fff;
}

.input-group-mock input {
    border: none;
    padding: 0 10px;
    font-size: 11px;
    color: #333;
    outline: none;
    width: 110px;
}

.domain-suffix {
    background: #f9f9f9;
    padding: 0 10px;
    font-size: 11px;
    color: #666;
    border-left: 1px solid #dfdfdf;
    height: 100%;
    display: flex;
    align-items: center;
}

.setting-row.details {
    align-items: flex-start;
}

.setting-row.details p {
    font-size: 11px;
    color: #888;
    margin: 0;
    line-height: 1.5;
}

.setting-row.details a {
    color: #555;
    text-decoration: underline;
}

.floating-panel {
    width: 220px;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    background: #fff;
    font-size: 11px;
}

.floating-panel h3 {
    margin: 0 0 16px 0;
    font-size: 13px;
    font-weight: 500;
    color: #111;
}

.panel-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: #666;
}

.url-value {
    color: #111;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-badge {
    background: #f6fdf6;
    color: #1a7b3b;
    padding: 3px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    border: 1px solid #e2f4e2;
}

.status-badge .dot-green {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    display: block;
}

.visibility-sel {
    color: #111;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 6px;
}

.panel-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.toast-notification {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.toast-notification button {
    background: #fff;
    color: #111;
    border: none;
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}


/* --- History Page --- */
body.history-page {
    background:
        radial-gradient(circle at top right, rgba(246, 246, 241, 0.9) 0%, transparent 28%),
        linear-gradient(180deg, #ffffff 0%, #fbfbf8 100%);
}

.history-page-main {
    gap: 0;
    min-width: 0;
    min-height: 0;
}

.history-page-shell {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #ecebe6;
    border-radius: 32px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 250, 246, 0.96) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.history-page-shell::before {
    content: '';
    position: absolute;
    top: -140px;
    right: -80px;
    width: 380px;
    height: 380px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(248, 248, 244, 0.95) 0%, rgba(248, 248, 244, 0) 72%);
    pointer-events: none;
}

.history-page-shell::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(17, 17, 17, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(17, 17, 17, 0.018) 1px, transparent 1px);
    background-size: 96px 96px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0) 32%);
    pointer-events: none;
}

.history-surface {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    min-height: 0;
    padding: 84px 16px 16px;
}

.history-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 0 4px;
}

.history-sort-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.history-sort-chip {
    appearance: none;
    border: none;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.history-sort-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 11px;
    border: 1px solid rgba(17, 17, 17, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.94);
    color: rgba(17, 17, 17, 0.78);
    box-shadow: 0 3px 10px rgba(17, 17, 17, 0.025);
    transition: background-color 0.18s ease, color 0.18s ease;
}

.history-sort-chip:hover {
    border-color: rgba(17, 17, 17, 0.2);
}

.history-sort-chip i {
    font-size: 12px;
    line-height: 1;
}

.history-sort-chip span {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.history-sort-chip.is-active {
    background: rgba(17, 17, 17, 0.86);
    color: #ffffff;
    border-color: rgba(17, 17, 17, 0.2);
}

.history-grid {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 4px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: 106px;
    grid-auto-flow: dense;
    gap: 12px;
    scrollbar-width: none;
}

.history-grid::-webkit-scrollbar {
    display: none;
}

.history-empty-layout {
    position: relative;
    flex: 1;
    min-height: 0;
}

.history-empty-layout .history-grid {
    height: 100%;
    opacity: 0.82;
    filter: grayscale(1);
}

.history-empty-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
}

.history-empty-message {
    margin: 0;
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(17, 17, 17, 0.58);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.02em;
    text-align: center;
    box-shadow: 0 10px 28px rgba(17, 17, 17, 0.035);
}

.history-card {
    --history-wash: rgba(239, 239, 239, 0.92);
    position: relative;
    grid-row: span 2;
    overflow: hidden;
    border: 1px solid rgba(17, 17, 17, 0.11);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(247, 247, 247, 0.97) 100%);
    box-shadow: 0 10px 24px rgba(17, 17, 17, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.96);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.history-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 22% 18%, var(--history-wash) 0%, rgba(255, 255, 255, 0) 62%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 100%);
}

.history-card::after {
    display: none;
}

.history-card:hover {
    transform: translateY(-2px);
    border-color: rgba(17, 17, 17, 0.16);
    box-shadow: 0 14px 30px rgba(17, 17, 17, 0.045), inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.history-card-tall {
    grid-row: span 4;
}

.history-card-medium {
    grid-row: span 2;
}

.tone-cloud {
    --history-wash: rgba(236, 236, 236, 0.95);
}

.tone-paper {
    --history-wash: rgba(243, 243, 243, 0.95);
}

.tone-mist {
    --history-wash: rgba(232, 232, 232, 0.95);
}

.tone-pearl {
    --history-wash: rgba(240, 240, 240, 0.95);
}

.history-card-skeleton {
    position: absolute;
    inset: 14px;
    border-radius: 12px;
    background: linear-gradient(110deg, rgba(233, 233, 233, 0.92) 12%, rgba(249, 249, 249, 0.98) 50%, rgba(231, 231, 231, 0.92) 88%);
    background-size: 220% 100%;
    background-position: 200% 0;
    animation: historySkeletonShimmer 3.8s ease-in-out infinite;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.history-card-skeleton::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: rgba(252, 252, 252, 0.72);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.history-skeleton-portrait::before {
    width: 56%;
    height: 78%;
    max-width: 170px;
}

.history-skeleton-portrait-soft::before {
    width: 60%;
    height: 74%;
    max-width: 180px;
    border-radius: 16px;
}

.history-skeleton-landscape::before {
    width: 78%;
    height: 56%;
    max-height: 120px;
}

.history-skeleton-landscape-soft::before {
    width: 72%;
    height: 52%;
    max-height: 110px;
    border-radius: 14px;
}

.history-skeleton-square::before {
    width: 54%;
    aspect-ratio: 1;
}

.history-skeleton-square-soft::before {
    width: 50%;
    aspect-ratio: 1;
    border-radius: 18px;
}

.history-skeleton-panorama::before {
    width: 84%;
    height: 42%;
    max-height: 92px;
}

@keyframes historySkeletonShimmer {
    0%,
    100% {
        background-position: 200% 0, 0 0;
    }

    50% {
        background-position: -20% 0, 0 0;
    }
}

@media (max-width: 1200px) {
    .history-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 920px) {
    .history-toolbar {
        justify-content: flex-start;
    }

    .history-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

}

@media (max-width: 720px) {
    .history-page .sidebar-wrapper {
        padding-left: 12px;
    }

    .history-page .separator-line {
        margin: 0 12px;
    }

    .history-page .sidebar {
        width: 58px;
        gap: 88px;
        padding: 24px 0;
    }

    .history-page-main {
        padding: 12px 12px 12px 0;
    }

    .history-surface {
        padding: 76px 12px 12px;
    }

    .history-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: 120px;
        gap: 10px;
    }

    .history-page-shell .token-display {
        top: 16px;
        right: 16px;
    }

}

@media (max-width: 560px) {
    .history-page .nav-item span {
        display: none;
    }

    .history-page .sidebar {
        width: 52px;
    }

    .history-page .icon-box {
        width: 34px;
        height: 34px;
        font-size: 20px;
    }

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

    .history-sort-chip {
        padding: 8px 10px;
    }

    .history-sort-chip span {
        font-size: 12px;
    }

    .history-page-shell .token-display-value {
        display: none;
    }

}

/* ============================================================
   Login Popup
   ============================================================ */

.login-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70000;
    background: rgba(200, 200, 200, 0.30);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease;
}

.login-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.login-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 70001;
    width: min(400px, calc(100vw - 40px));
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 24px;
    padding: 36px 32px 28px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 18px;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, calc(-50% - 12px));
    pointer-events: none;
    transition: opacity 0.24s ease, visibility 0.24s ease, transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-popup.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.login-popup-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 50%;
    background: #ffffff;
    color: #999;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.login-popup-close:hover {
    background: #f5f5f5;
    color: #333;
    border-color: rgba(0, 0, 0, 0.16);
}

.login-popup-close i { line-height: 1; }

.login-popup-logo {
    display: flex;
    justify-content: center;
}

.login-popup-logo-mark {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-popup-logo-mark img {
    width: 76px;
    height: 76px;
    object-fit: contain;
    display: block;
}

.login-popup-heading {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-popup-heading h2 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: #111;
    line-height: 1.15;
}

.login-popup-heading p {
    font-size: 13px;
    color: #888;
    line-height: 1.5;
}

.login-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 9px;
    color: #333;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-google-btn:hover {
    background: #fafafa;
    border-color: rgba(0, 0, 0, 0.20);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e8e8e8;
}

.login-divider span {
    color: #bbb;
    font-size: 12px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.login-field label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.login-field input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.13);
    border-radius: 9px;
    background: #ffffff;
    font-family: inherit;
    font-size: 13px;
    color: #111;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-field input::placeholder { color: #c0c0c0; }

.login-field input:focus {
    border-color: rgba(0, 0, 0, 0.28);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.login-password-wrapper { position: relative; }
.login-password-wrapper input { padding-right: 42px; }

.login-password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0;
    transition: color 0.15s ease;
}

.login-password-toggle:hover { color: #555; }

.login-continue-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 9px;
    color: #111;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-continue-btn:hover {
    background: #f7f7f7;
    border-color: rgba(0, 0, 0, 0.20);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.login-continue-btn i { font-size: 14px; }

.login-footer {
    text-align: center;
    font-size: 13px;
    color: #888;
    margin-top: -4px;
}

.login-footer a {
    color: #111;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.login-footer a:hover { opacity: 0.7; }

/* ── Welcome Popup ── */
.welcome-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.welcome-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.welcome-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    z-index: 9999;
    width: 380px;
    max-width: 90vw;
    background: #ffffff;
    border-radius: 28px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.45s ease;
}

.welcome-popup.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.welcome-popup-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    position: relative;
    clip-path: ellipse(120% 100% at 50% 0%);
}

/* arc shape is handled by clip-path on .welcome-popup-image */

.welcome-popup-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.welcome-popup-body {
    padding: 24px 32px 36px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.welcome-popup-title {
    font-size: 28px;
    font-weight: 800;
    color: #111;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.welcome-popup-description {
    font-size: 14px !important;
    font-weight: 400 !important;
    color: #888 !important;
    line-height: 1.6 !important;
    margin-bottom: 0 !important;
    max-width: 300px;
}

.welcome-popup-cta {
    width: 100%;
    max-width: 280px;
    padding: 14px 24px;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    margin-top: 20px;
}

.welcome-popup-cta:hover {
    background: #333;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.welcome-popup-cta:active {
    transform: translateY(0);
}

.welcome-popup-footer {
    font-size: 13px !important;
    color: #999 !important;
    margin-bottom: 0 !important;
}

.welcome-popup-footer a {
    color: #111;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.welcome-popup-footer a:hover {
    opacity: 0.7;
}

/* ── Generation Result Panel ── */
@keyframes cardStackExit {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes resultEnter {
    0%   { opacity: 0; transform: translateY(24px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spinnerRotate {
    to { transform: rotate(360deg); }
}

@keyframes imageReveal {
    0%   { opacity: 0; transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
}

.publish-component-wrapper.is-exiting {
    animation: cardStackExit 0.3s ease forwards;
    pointer-events: none;
}

.publish-component-wrapper.is-hidden {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    width: 0 !important;
    height: 0 !important;
}

/* ── Canvas Board ── */
.canvas-board {
    display: none;
    position: absolute;
    inset: 0;
    overflow: scroll;
    cursor: grab;
    z-index: 2;
    background-color: transparent;
    background-image:
        radial-gradient(circle, rgba(0,0,0,0.15) 1px, transparent 1px);
    background-size: 24px 24px;
    background-attachment: local;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.canvas-board::-webkit-scrollbar {
    display: none;
}

.canvas-board.is-visible {
    display: block;
    animation: resultEnter 0.5s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.canvas-board.is-panning {
    cursor: grabbing;
}

.canvas-board-inner {
    position: relative;
    width: 3000px;
    height: 3000px;
}

/* ── Canvas Minimap ── */
.canvas-minimap {
    display: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 10;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.canvas-minimap.is-visible {
    display: flex;
}

.canvas-minimap-map {
    position: relative;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.canvas-minimap-viewport {
    position: absolute;
    background: rgba(200, 200, 200, 0.18);
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 2px;
    transition: left 0.05s, top 0.05s, width 0.05s, height 0.05s;
}

/* ── Canvas Image Card ── */
.canvas-image-card {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    animation: imageReveal 0.45s cubic-bezier(0.2, 0, 0, 1) forwards;
    will-change: transform;
}

.canvas-image-card:active,
.canvas-image-card.is-dragging {
    cursor: grabbing;
    z-index: 100;
}

.canvas-image-card.is-selected {
    z-index: 50;
}

.canvas-image-card img {
    display: block;
    width: auto;
    max-width: 380px;
    max-height: 560px;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s ease;
    pointer-events: none;
}

.canvas-image-card.is-selected img {
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08), 0 0 0 2px rgba(0,0,0,0.18);
}

.canvas-image-card.is-dragging img {
    box-shadow: 0 20px 60px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.12);
}

/* ── Card Footer (actions + reprompt) ── */
.canvas-image-card-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 315px;
}

.canvas-image-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}

.canvas-image-card:hover:not(.is-selected) .canvas-image-card-actions {
    opacity: 1;
    pointer-events: auto;
}

/* ── Per-card Reprompt Form ── */
.canvas-card-reprompt {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
    background: rgba(255,255,255,0.97);
    border: 1px solid rgba(0,0,0,0.10);
    border-radius: 12px;
    padding: 5px 5px 5px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, border-radius 0.15s ease;
}

.canvas-image-card.is-selected .canvas-card-reprompt {
    opacity: 1;
    pointer-events: auto;
}

.canvas-card-reprompt.is-multiline {
    align-items: flex-end;
    border-radius: 12px;
}

.canvas-card-reprompt-input {
    flex: 1;
    resize: none;
    border: none;
    border-radius: 0;
    padding: 7px 0;
    font-size: 12px;
    font-family: inherit;
    line-height: 1.5;
    min-height: 28px;
    height: 28px;
    max-height: 200px;
    overflow: hidden;
    color: #111;
    background: transparent;
    outline: none;
    cursor: text;
}

.canvas-card-reprompt-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.22);
    background: transparent;
    color: #111;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.1s ease;
    pointer-events: auto;
}

.canvas-card-reprompt-btn:hover {
    border-color: rgba(0,0,0,0.5);
    transform: scale(1.06);
}

.canvas-card-reprompt-btn:active {
    transform: scale(0.95);
}

/* ── Card Loading State ── */
.canvas-card-loading {
    position: absolute;
    width: 315px;
    height: 560px;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
}

.canvas-card-skeleton-shimmer {
    width: 100%;
    height: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #f0f0f0;
    position: relative;
}

.canvas-card-skeleton-strip {
    display: flex;
    width: 400%;
    height: 100%;
    animation: skeletonSlide 12s cubic-bezier(0.45, 0, 0.55, 1) infinite;
    will-change: transform;
}

.canvas-card-skeleton-slide {
    width: 25%;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
}

.canvas-card-skeleton-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
    animation: skeletonPulse 2.2s ease-in-out infinite;
}

@keyframes skeletonPulse {
    0%,  100% { opacity: 1;    }
    50%        { opacity: 0.62; }
}

.canvas-card-generating-chip {
    position: absolute;
    bottom: 14px;
    right: 14px;
    background: rgba(255, 255, 255, 0.92);
    font-size: 11px;
    letter-spacing: 0.03em;
    padding: 5px 11px;
    border-radius: 999px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    pointer-events: none;
    user-select: none;
    z-index: 10;
}

.generating-label {
    font-weight: 400;
    color: transparent;
    background: linear-gradient(
        90deg,
        #333 0%,
        #333 38%,
        #fff  50%,
        #333 62%,
        #333 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: generatingShimmer 2s linear infinite;
}

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

@keyframes skeletonSlide {
    0%,  20% { transform: translateX(0%);    }
    25%, 45% { transform: translateX(-25%);  }
    50%, 70% { transform: translateX(-50%);  }
    75%, 95% { transform: translateX(-75%);  }
    100%     { transform: translateX(0%);    }
}

.generation-spinner {
    width: 36px;
    height: 36px;
    border: 2.5px solid #e5e5e5;
    border-top-color: #111;
    border-radius: 50%;
    animation: spinnerRotate 0.75s linear infinite;
}

.generation-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: rgba(243,243,243,0.9);
    border: none;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    backdrop-filter: blur(4px);
}

.generation-reset-btn:hover {
    background: #eaeaea;
    transform: translateY(-1px);
}

.generation-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: #111;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.generation-download-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.generate-btn.is-loading {
    opacity: 0.65;
    pointer-events: none;
}

.generate-btn.is-loading .generate-wordmark {
    opacity: 0.5;
}

/* ── User nav dropdown ── */
.user-nav-wrapper {
    position: relative;
}

.user-avatar-btn {
    background: none;
    border: none;
    cursor: pointer;
}

.user-avatar-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
}

.user-dropdown {
    position: absolute;
    left: calc(100% + 12px);
    bottom: 0;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    min-width: 200px;
    padding: 12px 0 8px;
    z-index: 1000;
}

.user-dropdown-info {
    padding: 4px 16px 10px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 6px;
}

.user-dropdown-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #111;
    line-height: 1.3;
    margin-bottom: 2px;
}

.user-dropdown-email {
    display: block;
    font-size: 12px;
    color: #888;
    line-height: 1.3;
    word-break: break-all;
}

.user-dropdown-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #555;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.user-dropdown-logout:hover {
    background: #fef2f2;
    color: #e53e3e;
}

.login-error-msg {
    font-size: 13px;
    color: #e53e3e;
    text-align: center;
    margin: 0 0 4px;
}

/* ── Settings avatar Google badge ── */
.settings-account-avatar {
    position: relative;
}

.settings-avatar-google-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.settings-avatar-google-badge svg {
    width: 11px;
    height: 11px;
    display: block;
}

/* ── History: Loading State ── */
.history-loading-state {
    flex: 1;
    min-height: 0;
}

.history-loading-state .history-grid {
    height: 100%;
    opacity: 0.55;
    filter: grayscale(1);
    animation: historyPulse 2s ease-in-out infinite;
}

@keyframes historyPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 0.38; }
}

/* ── History: Real Images Grid ── */
.history-real-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: min-content;
    gap: 12px;
    scrollbar-width: none;
    align-content: start;
}

.history-real-grid::-webkit-scrollbar {
    display: none;
}

.history-real-card {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid rgba(17, 17, 17, 0.1);
    background: #f2f2f2;
    aspect-ratio: 9 / 16;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    cursor: pointer;
}

.history-real-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 36px rgba(17, 17, 17, 0.12);
}

.history-real-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.history-real-card-img.is-loaded {
    opacity: 1;
}

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

.history-real-card.is-loading-img {
    background: linear-gradient(
        90deg,
        #e8e8e8 25%,
        #f2f2f2 50%,
        #e8e8e8 75%
    );
    background-size: 200% 100%;
    animation: history-shimmer 1.4s ease-in-out infinite;
}

.history-real-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0) 55%);
    opacity: 0;
    transition: opacity 0.22s ease;
    display: flex;
    align-items: flex-end;
}

.history-real-card:hover .history-real-card-overlay {
    opacity: 1;
}

.history-real-card-meta {
    padding: 14px 12px 12px;
    width: 100%;
}

.history-real-card-prompt {
    margin: 0 0 6px;
    font-size: 11.5px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.88);
    line-height: 1.4;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-real-card-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-real-card-tag {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 2px 6px;
}

.history-real-card-date {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.55);
    margin-left: auto;
    white-space: nowrap;
}

.history-real-card-download {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(17, 17, 17, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(17, 17, 17, 0.75);
    font-size: 14px;
    text-decoration: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease;
}

.history-real-card:hover .history-real-card-download {
    opacity: 1;
    transform: translateY(0);
}

.history-real-card-download:hover {
    background: rgba(255, 255, 255, 1);
    color: rgba(17, 17, 17, 0.95);
}

@media (max-width: 1200px) {
    .history-real-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 920px) {
    .history-real-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .history-real-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
}

/* ── History Lightbox ── */
.history-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.history-lightbox.is-open {
    pointer-events: all;
    opacity: 1;
}

.history-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.history-lightbox-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: min(520px, 90vw);
    max-height: 92vh;
    width: 100%;
    transform: scale(0.94) translateY(10px);
    transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.history-lightbox.is-open .history-lightbox-shell {
    transform: scale(1) translateY(0);
}

.history-lightbox-img-wrap {
    width: 100%;
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
    max-height: calc(92vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-lightbox-img {
    width: 100%;
    height: auto;
    max-height: calc(92vh - 120px);
    object-fit: contain;
    display: block;
    border-radius: 18px;
    transition: opacity 0.2s ease;
}

.history-lightbox-img.is-loading {
    opacity: 0.3;
}

.history-lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.85);
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    z-index: 2;
}

.history-lightbox-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.history-lightbox-prev,
.history-lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.16);
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    z-index: 2;
}

.history-lightbox-prev { left: 20px; }
.history-lightbox-next { right: 20px; }

.history-lightbox-prev:hover,
.history-lightbox-next:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.history-lightbox-footer {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 14px 4px 0;
    width: 100%;
}

.history-lightbox-meta {
    flex: 1;
    min-width: 0;
}

.history-lightbox-prompt {
    margin: 0 0 6px;
    font-size: 12.5px;
    color: rgba(255,255,255,0.72);
    line-height: 1.45;
    letter-spacing: -0.01em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.history-lightbox-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-lightbox-tag {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 2px 7px;
}

.history-lightbox-date {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
}

.history-lightbox-download {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.82);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.history-lightbox-download:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

@media (max-width: 640px) {
    .history-lightbox-prev { left: 10px; }
    .history-lightbox-next { right: 10px; }
    .history-lightbox-shell { max-width: 95vw; }
}
