*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --border: #e2e5ea;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

html {
    font-size: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Main layout */
.main {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    align-items: start;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}

.control-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.control-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.control-section h2 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
    margin-top: 0.75rem;
}

.label-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.8rem;
}

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(67, 97, 238, 0.04);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.upload-content svg {
    opacity: 0.5;
}

.upload-content p {
    font-size: 0.9rem;
    font-weight: 500;
}

.upload-hint {
    font-size: 0.75rem;
    opacity: 0.6;
}

.upload-zone.has-image {
    border-style: solid;
    border-color: var(--accent);
    background: rgba(67, 97, 238, 0.04);
    padding: 0.75rem;
}

.upload-zone.has-image .upload-content {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

.upload-info {
    flex: 1;
    min-width: 0;
}

/* Inline delete button in upload zone */
.upload-remove-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.12);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.upload-remove-btn:hover {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.upload-zone.has-image .upload-content svg {
    display: none;
}

.upload-zone.has-image .upload-hint {
    display: none;
}

.upload-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
}

.upload-filename {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-all;
    text-align: left;
}

.upload-filesize {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Ratio buttons */
.ratio-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.ratio-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.25rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.ratio-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.ratio-btn.active {
    border-color: var(--accent);
    background: rgba(67, 97, 238, 0.06);
    color: var(--accent);
}

.ratio-icon {
    display: block;
    width: 100%;
    max-width: 28px;
    max-height: 28px;
    border: 2px solid currentColor;
    border-radius: 2px;
}

.ratio-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    opacity: 0.7;
    line-height: 1.2;
}

/* Input with suffix */
.input-with-suffix {
    display: flex;
    align-items: center;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s;
}

.input-with-suffix:focus-within {
    border-color: var(--accent);
}

.input-with-suffix input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    min-width: 0;
    background: transparent;
}

.input-with-suffix .suffix {
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border-left: 2px solid var(--border);
}

.input-small {
    max-width: 100px;
    flex-shrink: 0;
}

.input-small input {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
}

.input-small .suffix {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}

/* Frame ratio control */
.frame-ratio-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.frame-ratio-control input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.frame-ratio-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(67, 97, 238, 0.3);
    transition: transform 0.15s;
}

.frame-ratio-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.frame-ratio-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(67, 97, 238, 0.3);
}

/* Color presets */
.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    padding: 2px;
    background: var(--surface);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-swatch span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.color-swatch:hover {
    border-color: var(--accent);
    transform: scale(1.1);
}

.color-swatch.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.25);
}

.color-picker-wrap {
    position: relative;
    width: 32px;
    height: 32px;
}

.color-picker-wrap input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.color-picker-wrap svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: var(--text-secondary);
}

/* Info section */
.info-section {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem !important;
    border: none !important;
    margin-top: 0.5rem;
}

.info-section h2 {
    margin-top: 0 !important;
}

.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.85rem;
}

.info-label {
    color: var(--text-secondary);
}

.info-value {
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.warning {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fff3cd;
    color: #856404;
    border-radius: var(--radius);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* EXIF section inside info */
.exif-divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 0;
}

.exif-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.exif-section .info-value {
    word-break: break-word;
}

/* Download button */
.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem;
    margin-top: 1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.download-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.download-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.download-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Preview area */
.preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.preview-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#d0d0d0 0% 25%, #f0f0f0 0% 50%) 50% / 20px 20px;
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.preview-container.has-image {
    cursor: default;
}

.preview-container.drag-over {
    box-shadow: 0 0 0 3px var(--accent);
}

#preview-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

.preview-container:not(.has-image) #preview-canvas {
    pointer-events: none;
}

/* Preview upload prompt overlay */
.preview-upload-prompt {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 1;
}

.preview-upload-prompt svg {
    opacity: 0.4;
}

.preview-upload-prompt p {
    font-size: 0.95rem;
    font-weight: 500;
}

.preview-upload-prompt .prompt-mobile {
    display: none;
}

.preview-upload-prompt span {
    font-size: 0.75rem;
    opacity: 0.6;
}

.preview-container.has-image .preview-upload-prompt {
    display: none;
}

/* Preview toolbar (hint + delete button) */
.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
}

.preview-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.preview-remove-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.preview-remove-btn:hover {
    background: #fef2f2;
    color: #dc3545;
    border-color: #dc3545;
}

/* Preview mode toggle */
.preview-mode-toggle {
    display: flex;
    background: var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
    width: fit-content;
}

.preview-mode-btn {
    padding: 5px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.preview-mode-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Instagram Feed Mockup */
.feed-mockup {
    width: 100%;
    max-width: 470px;
    align-self: center;
}

.feed-post {
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    overflow: hidden;
}

.feed-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
}

.feed-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    flex-shrink: 0;
    position: relative;
}

.feed-avatar::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: #fff;
}

.feed-username {
    font-size: 14px;
    font-weight: 600;
    color: #262626;
    flex: 1;
}

.feed-more {
    color: #262626;
    cursor: default;
}

.feed-image-wrap {
    width: 100%;
    background: #fafafa;
    line-height: 0;
}

.feed-image {
    width: 100%;
    display: block;
}

.feed-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 6px;
}

.feed-actions svg {
    color: #262626;
    cursor: default;
}

.feed-actions-left {
    display: flex;
    gap: 14px;
}

.feed-info {
    padding: 0 14px 14px;
    font-size: 14px;
    color: #262626;
    line-height: 1.5;
}

.feed-likes {
    margin-bottom: 4px;
}

.feed-caption strong {
    font-weight: 600;
}

/* Instagram Profile Grid Mockup */
.profile-mockup {
    width: 100%;
    max-width: 470px;
    align-self: center;
}

.profile-card {
    background: #fff;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    overflow: hidden;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    flex-shrink: 0;
    position: relative;
}

.profile-avatar::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: #fff;
}

.profile-stats {
    display: flex;
    gap: 16px;
    flex: 1;
    justify-content: center;
}

.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 13px;
    color: #262626;
    line-height: 1.3;
}

.profile-stat strong {
    font-size: 15px;
    font-weight: 700;
}

.profile-stat span {
    color: #262626;
    font-weight: 400;
}

.profile-bio {
    padding: 0 20px 12px;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    color: #262626;
}

.profile-tab-bar {
    display: flex;
    border-top: 1px solid #dbdbdb;
}

.profile-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    color: #8e8e8e;
    border-top: 1px solid transparent;
    margin-top: -1px;
}

.profile-tab.active {
    color: #262626;
    border-top-color: #262626;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

.profile-grid-item {
    aspect-ratio: 1;
    overflow: hidden;
}

.profile-grid-item.placeholder {
    background: #efefef;
}

.profile-grid-item.target {
    position: relative;
}

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

/* Bottom sheet handle (hidden on desktop) */
.sheet-handle {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 12px 0 8px;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
}

.sheet-handle-bar {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
}

/* Save overlay (mobile long-press to save) */
.save-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.25s;
}

.save-overlay.active {
    opacity: 1;
}

.save-overlay-header {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
    flex-shrink: 0;
}

.save-overlay-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.save-overlay-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    min-height: 0;
}

.save-overlay-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    -webkit-touch-callout: default;
}

.save-overlay-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}

/* Sheet backdrop */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.sheet-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Footer */
.footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: #9ca3af;
    border-top: 1px solid #f0f0f0;
}

.footer a {
    color: #9ca3af;
    text-decoration: none;
}

.footer a:hover {
    color: #6b7280;
    text-decoration: underline;
}

/* Thumbnail strip */
.thumbnail-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 0;
}

.thumbnail-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding: 2px;
}

.thumbnail-list::-webkit-scrollbar {
    height: 4px;
}

.thumbnail-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.thumbnail-item {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.thumbnail-item.active {
    border-color: var(--accent);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumbnail-item .thumbnail-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    border: none;
    padding: 0;
}

.thumbnail-item:hover .thumbnail-remove {
    opacity: 1;
}

.thumbnail-add-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px dashed #d1d5db;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.thumbnail-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.thumbnail-counter {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* Download progress */
.download-progress {
    margin-top: 0.5rem;
    width: 100%;
}

.progress-bar-track {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.2s;
    width: 0%;
}

.progress-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1f2937;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 10000;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Number input spinner hide */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Canvas navigation arrows */
.canvas-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.35);
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0.7;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.canvas-nav-arrow:hover {
    background: rgba(0, 0, 0, 0.55);
    opacity: 1;
}

.canvas-nav-arrow:active {
    transform: translateY(-50%) scale(0.92);
}

.canvas-nav-arrow.visible {
    display: flex;
}

.canvas-nav-prev {
    left: 8px;
}

.canvas-nav-next {
    right: 8px;
}

/* Mobile tab bar + panels (hidden on desktop) */
.mobile-tab-bar,
.mobile-tab-panels {
    display: none;
}

/* Responsive - Mobile tab bar layout */
@media (max-width: 900px) {
    body {
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }

    .app {
        height: 100vh;
        height: 100dvh;
        max-width: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0.5rem 0.75rem 0;
    }

    .footer {
        display: none;
    }

    .header {
        flex-shrink: 0;
        margin-bottom: 0.35rem;
    }

    .header h1 {
        font-size: 1.35rem;
    }

    .subtitle {
        font-size: 0.8rem;
    }

    .main {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        gap: 0;
        position: relative;
    }

    .preview-area {
        flex: 1;
        overflow: hidden;
        padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
        gap: 0.25rem;
        justify-content: flex-start;
    }

    .preview-mode-toggle {
        align-self: center;
    }

    .feed-mockup,
    .profile-mockup {
        overflow-y: auto;
        max-height: 100%;
    }

    .preview-container {
        min-height: 0;
        padding: 0.5rem;
        align-self: center;
        margin: 0 auto;
    }

    .preview-upload-prompt .prompt-desktop {
        display: none;
    }

    .preview-upload-prompt .prompt-mobile {
        display: block;
    }

    .preview-toolbar {
        flex-shrink: 0;
    }

    /* Hide desktop sidebar on mobile */
    .sidebar {
        display: none;
    }

    /* --- Mobile tab bar --- */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 201;
        background: var(--surface);
        border-top: 1px solid var(--border);
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        height: auto;
    }

    .tab-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 0 6px;
        border: none;
        background: none;
        color: var(--text-secondary);
        font-size: 0.65rem;
        font-family: inherit;
        font-weight: 500;
        cursor: pointer;
        transition: color 0.15s;
        -webkit-tap-highlight-color: transparent;
    }

    .tab-btn svg {
        width: 20px;
        height: 20px;
    }

    .tab-btn.active {
        color: var(--accent);
    }

    .tab-btn-download:not(:disabled) {
        color: var(--accent);
    }

    .tab-btn-download:disabled {
        opacity: 0.35;
    }

    /* --- Tab panels --- */
    .mobile-tab-panels {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        pointer-events: none;
    }

    .tab-panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-panel.active {
        transform: translateY(0);
        pointer-events: auto;
    }

    .tab-panel-content {
        padding: 1.25rem 1.25rem;
        /* account for tab bar height */
        padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px) + 1rem);
    }

    .tab-panel-header {
        font-size: 0.85rem;
        font-weight: 600;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-bottom: 0.75rem;
    }

    .tab-panel-sub {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-top: 1rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
    }

    .tab-panel-sub-label {
        font-size: 0.8rem;
        font-weight: 500;
        color: var(--text-secondary);
        white-space: nowrap;
    }

    .mobile-ratio-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Hide redundant sections on mobile */
    .upload-section {
        display: none;
    }

    /* Mobile photo tab */
    .mobile-photo-thumb-row {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .mobile-photo-thumb {
        width: 48px;
        height: 48px;
        border-radius: 8px;
        object-fit: cover;
        border: 1px solid var(--border);
    }

    .mobile-photo-meta {
        flex: 1;
        min-width: 0;
    }

    .mobile-photo-name {
        font-size: 0.85rem;
        font-weight: 500;
        color: var(--text);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-photo-size {
        font-size: 0.75rem;
        color: var(--text-secondary);
        margin-top: 2px;
    }

    .mobile-photo-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-photo-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.7rem;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        background: var(--surface);
        color: var(--text);
        font-size: 0.85rem;
        font-family: inherit;
        font-weight: 500;
        cursor: pointer;
    }

    .mobile-photo-btn-danger {
        color: #dc3545;
        border-color: #f5c6cb;
        background: #fff5f5;
    }

    /* Mobile canvas nav arrows */
    .canvas-nav-arrow {
        width: 32px;
        height: 32px;
        opacity: 0.6;
    }

    .canvas-nav-prev {
        left: 4px;
    }

    .canvas-nav-next {
        right: 4px;
    }

    /* Mobile thumbnail strip */
    .thumbnail-strip {
        padding: 2px 0;
    }

    .thumbnail-item .thumbnail-remove {
        opacity: 1;
    }

    .thumbnail-item {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 0.5rem 0.5rem 0;
    }

    .header h1 {
        font-size: 1.15rem;
    }

    .preview-container {
        padding: 0.5rem;
    }
}
