/* ===== 4分割メーカー style.css ===== */
/* ===== Custom Fonts (shared with iconsamunemaker) ===== */
@font-face {
    font-family: 'LightNovelPOPv2';
    src: url('/assets/fonts/LightNovelPOPv2.otf') format('opentype');
    font-display: swap;
}

@font-face {
    font-family: 'AkazukiPOP';
    src: url('/assets/fonts/AkazukiPOP.otf') format('opentype');
    font-display: swap;
}

:root {
    --primary: #ff5e91;
    --primary-dark: #e8457c;
    --x-blue: #1DA1F2;
    --background: #f7f9fa;
    --surface: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #eeeeee;
    --shadow: rgba(255, 94, 145, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 10px;
}

/* Header */
header {
    text-align: center;
    padding: 15px 0 10px;
}

header h1 {
    font-size: 1.6rem;
    background: linear-gradient(135deg, var(--primary), var(--x-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Step Indicator */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 15px;
    padding: 12px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s;
    opacity: 0.5;
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 0.8;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.step.active .step-number {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 10px var(--shadow);
}

.step.completed .step-number {
    background: #4CAF50;
    color: #fff;
}

.step-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
}

.step.active .step-label {
    color: var(--primary);
}

.step-arrow {
    color: #ccc;
    font-weight: bold;
    font-size: 1rem;
}

/* Step Sections */
.step-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.step-section.active {
    display: block;
}

/* Section Card */
.section-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
}

.section-card h2 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.description {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 15px;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #ddd;
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
    position: relative;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: #fff0f5;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px var(--shadow);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.upload-area p {
    font-weight: 700;
    font-size: 1rem;
}

.upload-sub {
    color: #aaa;
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    margin-top: 5px;
}

.upload-size-hint {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #888;
    background: rgba(255, 94, 145, 0.06);
    border-radius: 8px;
    padding: 6px 12px;
    display: inline-block;
}

.hint-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 2px;
}

.hint-badge--blue {
    background: var(--x-blue);
}

/* Vertical mode buttons */
.vertical-mode-btn {
    background: linear-gradient(135deg, #4facfe, #00f2fe) !important;
    color: #fff !important;
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.vertical-mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(79, 172, 254, 0.5);
}

/* Panel selector (Step 4) */
.v-panel-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    align-items: center;
}

.v-panel-tab {
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: #f5f5f5;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.v-panel-tab:hover {
    border-color: #4facfe;
    background: #e8f4ff;
}

.v-panel-tab.active {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: #fff;
    border-color: #4facfe;
    box-shadow: 0 3px 10px rgba(79, 172, 254, 0.4);
}

.v-save-all-btn {
    margin-left: auto;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary), var(--x-blue));
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 3px 10px var(--shadow);
    transition: all 0.2s;
    white-space: nowrap;
}

.v-save-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--shadow);
}

/* Vertical canvas wrapper */
.vertical-canvas-wrapper {
    position: relative;
}

#verticalCanvas {
    max-height: 45vh;
    width: auto;
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
    border: 1px solid var(--border);
}

/* Zone labels overlay */
.vertical-zone-labels {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 100%;
    width: 100%;
    max-width: 320px;
    /* matches canvas display width roughly */
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.65rem;
    font-weight: 700;
}

.zone-label {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    text-align: center;
    backdrop-filter: blur(2px);
    white-space: nowrap;
}

.zone-top {
    align-self: center;
    margin-top: 4px;
}

.zone-mid {
    align-self: center;
}

.zone-bottom {
    align-self: center;
    margin-bottom: 4px;
}

/* Vertical mode layout */
.vertical-mode-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 768px) {
    .vertical-mode-layout {
        grid-template-columns: 1fr;
    }

    #verticalCanvas {
        max-height: 40vh;
    }
}

.file-input {
    display: none;
}

/* Margin Options */
.margin-options {
    margin-top: 15px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 10px;
}

.margin-options label {
    font-weight: 700;
    font-size: 0.85rem;
    display: block;
    margin-bottom: 8px;
}

.badge {
    background: var(--primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.margin-color-row {
    display: flex;
    gap: 10px;
}

.margin-color-chip {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.margin-color-chip.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--shadow);
}

/* Split Layout */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.split-panels h3,
.x-preview-area h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.split-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.split-panel {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 8px;
    text-align: center;
    position: relative;
}

.panel-label {
    font-weight: 900;
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 5px;
}

.split-panel canvas {
    width: 100%;
    border-radius: 8px;
    background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}

.panel-dl-btn,
.panel-edit-btn {
    display: inline-block;
    margin-top: 5px;
    padding: 5px 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.panel-dl-btn {
    background: var(--primary);
    color: #fff;
}

.panel-edit-btn {
    background: var(--x-blue);
    color: #fff;
    margin-left: 4px;
}

.panel-dl-btn:hover,
.panel-edit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* Actions */
.split-actions,
.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    min-width: 120px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--x-blue));
    color: #fff;
    box-shadow: 0 4px 15px var(--shadow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}

.secondary-btn {
    background: #f0f0f0;
    color: var(--text);
}

.secondary-btn:hover {
    background: #e5e5e5;
    transform: translateY(-1px);
}

/* X Tweet Preview */
.x-tweet-preview {
    background: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 16px;
    padding: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans JP', sans-serif;
}

.x-tweet-preview.large {
    max-width: 500px;
    margin: 15px auto 0;
}

.x-tweet-preview.dark {
    background: #15202b;
    border-color: #38444d;
}

.x-tweet-preview.dark .x-name {
    color: #fff;
}

.x-tweet-preview.dark .x-handle {
    color: #8899a6;
}

.x-tweet-preview.dark .x-tweet-text {
    color: #fff;
}

.x-tweet-preview.dark .x-tweet-actions {
    color: #8899a6;
}

.x-tweet-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.x-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    flex-shrink: 0;
}

.x-user-info {
    display: flex;
    flex-direction: column;
}

.x-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.x-handle {
    color: #657786;
    font-size: 0.8rem;
}

.x-tweet-text {
    margin-bottom: 10px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.x-image-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 2/1;
}

.x-grid-cell {
    background: #e1e8ed;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: opacity 0.15s;
}

.x-grid-cell:hover {
    opacity: 0.85;
}

/* X Image Detail Viewer */
.x-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: xViewerFadeIn 0.18s ease-out;
}

@keyframes xViewerFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.x-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.x-viewer-close {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 28px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.x-viewer-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.x-viewer-prev,
.x-viewer-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 32px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.x-viewer-prev {
    left: 16px;
}

.x-viewer-next {
    right: 16px;
}

.x-viewer-prev:hover,
.x-viewer-next:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.x-viewer-img-wrap {
    position: relative;
    z-index: 1;
    max-width: 92vw;
    max-height: 92vh;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
}

.x-viewer-img-wrap.grabbing {
    cursor: grabbing;
}

.x-viewer-img-wrap img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
    animation: xImgPopIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: center center;
    will-change: transform;
    touch-action: none;
    pointer-events: none;
}

@keyframes xImgPopIn {
    from {
        transform: scale(0.88);
        opacity: 0.5;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.x-viewer-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* ズームインジケーター */
.x-viewer-zoom-info {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.x-viewer-zoom-info.visible {
    opacity: 1;
}

/* グリッドセルをタップしやすく */
.x-grid-cell {
    cursor: pointer;
    transition: filter 0.15s;
}

.x-grid-cell:hover {
    filter: brightness(0.85);
}

.x-grid-cell:active {
    filter: brightness(0.7);
}

.x-tweet-actions {
    display: flex;
    justify-content: space-around;
    padding-top: 10px;
    color: #657786;
    font-size: 0.8rem;
}

/* Preview Mode Toggle */
.preview-mode-toggle {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 10px 0;
}

.mode-btn {
    padding: 8px 18px;
    border: 2px solid var(--border);
    border-radius: 20px;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.85rem;
}

.mode-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ===== EDITOR (Step 2) ===== */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    gap: 10px;
}

.editor-header h2 {
    font-size: 1rem;
    flex: 1;
    text-align: center;
}

.back-btn,
.done-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.back-btn {
    background: #f0f0f0;
    color: var(--text);
}

.done-btn {
    background: var(--primary);
    color: #fff;
}

.back-btn:hover {
    background: #e0e0e0;
}

.done-btn:hover {
    background: var(--primary-dark);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    align-items: start;
}

.canvas-section {
    background: var(--surface);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
}

.canvas-wrapper {
    width: 100%;
    text-align: center;
    overflow: hidden;
}

#mainCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: default;
    border: 1px solid var(--border);
}

.canvas-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.control-btn,
.download-btn {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    font-size: 0.85rem;
}

.control-btn:hover {
    transform: translateY(-2px);
    background: #f5f5f5;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.download-btn {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    flex: 2;
    font-size: 1rem;
}

.download-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--shadow);
}

/* Tools Panel */
.tools-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
    max-height: 80vh;
    overflow-y: auto;
}

.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.tab-btn {
    padding: 8px 10px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    font-weight: 700;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    min-width: 60px;
    text-align: center;
    line-height: 1.2;
}

.tab-btn:hover {
    transform: translateY(-2px);
    background: #f5f5f5;
    border-color: var(--primary);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 10px var(--shadow);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.tab-content h3 {
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

/* Banner Tab */
.banner-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.banner-upload-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: #f0f0f0;
    color: var(--text);
    text-align: center;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px dashed #ddd;
    font-size: 0.9rem;
}

.banner-upload-btn:hover {
    background: #e5e5e5;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.banner-presets h4 {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.banner-preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.banner-preset-btn {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fdfdfd;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.banner-preset-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    background: #fff0f5;
}

/* Form Controls (same as IconsamuneMaker) */
label {
    display: block;
    margin-top: 12px;
    margin-bottom: 4px;
    font-weight: 700;
    color: #555;
    font-size: 0.85rem;
}

.text-input,
.select-input,
.number-input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.text-input:focus,
.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--shadow);
}

.slider {
    width: calc(100% - 60px);
    margin-right: 10px;
}

.color-input {
    width: 50px;
    height: 36px;
    border: 2px solid #eee;
    border-radius: 8px;
    cursor: pointer;
}

/* Background Grid */
.background-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.bg-item {
    aspect-ratio: 2/1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
}

.bg-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    box-shadow: 0 3px 10px var(--shadow);
}

/* Category Buttons */
.category-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cat-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 5px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
    font-family: inherit;
    font-weight: 700;
}

.cat-btn:hover {
    background: #e0e0e0;
}

.cat-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Stamps Grid */
.stamps-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.stamp-item {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.stamp-item:hover {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

/* Template Buttons */
.template-btns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.template-btn {
    padding: 10px;
    border: 2px solid #eee;
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    font-size: 0.9rem;
}

.template-btn:hover {
    background: linear-gradient(135deg, #ffecd2, #fcb69f);
    border-color: #fcb69f;
}

/* Style Template Buttons */
.style-template-btns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 10px 0;
}

.style-template-btn {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fdfdfd;
    color: var(--text);
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

.style-template-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Gradient/Stroke/Shadow/Effect Controls */
.gradient-controls,
.stroke-controls,
.shadow-controls,
.effect-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.effect-controls label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin: 0;
}

/* Radio Groups */
.radio-group {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    background: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #ddd;
    transition: all 0.2s;
    margin: 0;
}

.radio-group label:hover {
    background: #f0f0f0;
}

.radio-group input[type="radio"] {
    accent-color: var(--primary);
}

/* Bubble/Brush/Shape Buttons */
.bubble-type-btns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 10px 0;
}

.bubble-type-btn {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fdfdfd;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.bubble-type-btn:hover {
    border-color: var(--primary);
}

.bubble-type-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.brush-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.8rem;
}

.brush-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.shape-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.shape-btn {
    width: 48px;
    height: 48px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.shape-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Layers */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* FAB - テキスト追加ボタン（全デバイス共通）*/
#addTextBtn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: auto;
    min-width: 90px;
    padding: 13px 26px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(255, 94, 145, 0.45);
    z-index: 1001;
    display: none;
    background: linear-gradient(135deg, #ff5e91, #4facfe);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

#addTextBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 94, 145, 0.55);
}

/* テキストタブがアクティブの時だけ表示 (JS制御: editor.js setupEventListeners) */


/* FAB - 上下モード テキスト追加ボタン */
#vAddTextBtn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: auto;
    min-width: 90px;
    padding: 13px 26px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.45);
    z-index: 1001;
    display: none;
    background: linear-gradient(135deg, #4facfe, #a855f7);
    border: none;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

#vAddTextBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79, 172, 254, 0.6);
}

/* 上下モード テキストタブがアクティブの時だけ表示 */
#step4 .tab-content#v-text-tab.active~* #vAddTextBtn,
body:has(#step4.active) #v-text-tab.active~#vAddTextBtn {
    display: flex;
}

/* Layer thumbnail */
.layer-thumb {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #f5f5f5;
    flex-shrink: 0;
    margin-right: 6px;
}

.layer-thumb-emoji {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    margin-right: 6px;
}

.layer-item {
    background: linear-gradient(135deg, #ffecd2, #fcb69f);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    cursor: move;
    font-size: 0.85rem;
}

.layer-item.selected {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    border: 2px solid #4facfe;
    box-shadow: 0 3px 10px rgba(79, 172, 254, 0.4);
}

.layer-info {
    flex: 1;
    font-weight: 700;
}

.layer-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.layer-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 5px;
    background: #fa709a;
    color: #fff;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s;
}

.layer-btn:hover {
    background: #f5576c;
}

.upload-font-btn {
    margin-top: 5px;
    display: inline-block;
    background: var(--primary);
    color: #fff !important;
    border-radius: 8px;
    cursor: pointer;
}

/* Save Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border-radius: 16px;
    width: 85%;
    max-width: 500px;
    text-align: center;
    position: relative;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 5px;
}

.close-modal:hover {
    color: #000;
}

#saveImagePreview {
    max-width: 100%;
    height: auto;
    margin-top: 10px;
    border-radius: 8px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar */
.tools-panel::-webkit-scrollbar {
    width: 6px;
}

.tools-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.tools-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary), var(--x-blue));
    border-radius: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .tools-panel {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 5px;
    }

    header h1 {
        font-size: 1.3rem;
    }

    header p {
        font-size: 0.75rem;
    }

    header {
        padding: 10px 0 5px;
    }

    .step-indicator {
        padding: 8px;
        gap: 5px;
        margin: 5px 0 10px;
    }

    .step-number {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .step-label {
        font-size: 0.65rem;
    }

    .section-card {
        padding: 12px;
        border-radius: 12px;
    }

    .section-card h2 {
        font-size: 1rem;
    }

    .split-layout {
        grid-template-columns: 1fr;
    }

    .split-grid {
        gap: 6px;
    }

    .upload-area {
        padding: 30px 15px;
    }

    .upload-icon {
        font-size: 2.5rem;
    }

    /* Editor Mobile */
    .main-content {
        grid-template-columns: 1fr;
    }

    .canvas-section {
        padding: 8px;
        position: sticky;
        top: 0;
        z-index: 1000;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        border-radius: 0 0 12px 12px;
        margin: -5px -5px 5px -5px;
        width: calc(100% + 10px);
        margin-left: -5px;
    }

    #mainCanvas {
        max-width: 100%;
        height: auto !important;
        max-height: 35vh;
        width: auto;
    }

    .canvas-controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .control-btn,
    .download-btn {
        min-width: 55px;
        padding: 7px 6px;
        font-size: 0.7rem;
    }

    .control-btn {
        flex: 1;
    }

    .download-btn {
        flex: 2;
        font-size: 0.8rem;
    }

    .tools-panel {
        margin-top: 5px;
        padding: 10px;
    }

    .tabs {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 8px 0;
        gap: 4px;
    }

    .tab-btn {
        flex: 0 0 23%;
        width: 23%;
        padding: 5px 2px;
        font-size: 0.6rem;
        min-width: unset;
        height: 40px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .background-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .stamps-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .stamp-item {
        padding: 6px;
    }

    .style-template-btns {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .style-template-btn {
        font-size: 0.7rem;
        padding: 8px;
    }


    .editor-header {
        padding: 5px 0;
    }

    .editor-header h2 {
        font-size: 0.85rem;
    }

    .back-btn,
    .done-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .banner-preset-grid {
        grid-template-columns: 1fr;
    }

    .bubble-type-btns {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Custom Fonts (from IconsamuneMaker) */
@font-face {
    font-family: 'LightNovelPOPv2';
    src: url('https://icon-samune.com/app/assets/fonts/LightNovelPOPv2.otf');
}

@font-face {
    font-family: 'AkazukiPOP';
    src: url('https://icon-samune.com/app/assets/fonts/AkazukiPOP.otf');
}