/* ============================================
   WeLayout — 公众号图片排版工具
   Design: Refined Editorial / Modern Minimal
   ============================================ */

:root {
    /* Palette */
    --bg-page: #f5f3f0;
    --bg-card: #ffffff;
    --bg-hover: #faf9f7;
    --bg-input: #f9f8f6;
    --bg-tag: #f0ede8;

    --text-primary: #1e1b1b;
    --text-secondary: #78716c;
    --text-muted: #a8a29e;
    --text-placeholder: #b8b2ab;

    --border: #e7e5e4;
    --border-hover: #d6d3d1;
    --border-focus: #07c160;

    --primary: #07c160;
    --primary-dark: #06ad56;
    --primary-light: #e8f8ef;
    --primary-glow: rgba(7, 193, 96, 0.15);

    --accent: #d97706;
    --accent-dark: #b45309;
    --accent-light: #fff7ed;
    --accent-border: #fed7aa;

    --success: #059669;
    --success-light: #ecfdf5;
    --danger: #dc2626;
    --danger-light: #fef2f2;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
    --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Sizing */
    --sidebar-width: 260px;
    --content-max: 960px;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ============================================
   Layout
   ============================================ */
.container {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ============================================
   Header
   ============================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

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

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    font-size: 18px;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px var(--primary-glow);
}

.logo h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.version-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-tag);
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ============================================
   Step Box
   ============================================ */
.step-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s ease;
    animation: stepIn 0.4s ease;
}

.step-box:hover {
    box-shadow: var(--shadow-md);
}

@keyframes stepIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.step-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.step-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    letter-spacing: -0.01em;
}

.step-actions {
    display: flex;
    gap: 8px;
}

.step-action {
    margin-top: 18px;
    display: flex;
    justify-content: center;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 3px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-mp {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

.btn-mp:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

.btn-wechat {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.btn-wechat:hover {
    background: var(--primary-dark);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 10px 28px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

/* ============================================
   Textarea
   ============================================ */
textarea.input-urls,
textarea.output-code {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: "SF Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
    box-sizing: border-box;
    transition: all 0.15s ease;
    background: var(--bg-input);
    color: var(--text-primary);
    resize: vertical;
}

textarea.input-urls {
    height: 140px;
}

textarea.output-code {
    height: 140px;
    background: #f8f8f5;
    color: var(--text-secondary);
    margin-top: 16px;
    font-size: 12px;
}

textarea.input-urls:hover,
textarea.output-code:hover {
    border-color: var(--border-hover);
}

textarea.input-urls:focus,
textarea.output-code:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--bg-card);
}

textarea::placeholder {
    color: var(--text-placeholder);
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

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

.toolbar-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.toolbar-label.mp-label {
    color: var(--accent);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    border-radius: 1px;
}

/* ============================================
   Inputs
   ============================================ */
input[type="text"],
input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.15s ease;
    outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="number"] {
    width: 64px;
    text-align: center;
    appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    height: 28px;
}

input:disabled {
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border);
    opacity: 0.6;
}

.input-sm {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.input-full {
    flex: 1;
    font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
    font-size: 12px;
}

.mp-input {
    border-color: var(--accent-border);
    background: var(--accent-light);
}

.mp-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1);
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 6px;
}

.unit {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================
   Toggle Switch
   ============================================ */
.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    display: block;
    width: 36px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--border-hover);
    transition: background 0.2s ease;
    position: relative;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.toggle input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============================================
   Color Picker
   ============================================ */
.color-group {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-card);
    transition: all 0.15s ease;
}

.color-group:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.color-group input[type="color"] {
    border: none;
    width: 34px;
    height: 34px;
    padding: 4px;
    background: none;
    cursor: pointer;
    border-radius: 0;
}

.color-group input[type="text"] {
    border: none;
    width: 72px;
    padding: 6px 8px;
    font-size: 13px;
    background: transparent;
    border-radius: 0;
    border-left: 1px solid var(--border);
}

.color-group input[type="text"]:focus {
    box-shadow: none;
}

/* ============================================
   Image List
   ============================================ */
.img-list {
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    padding: 6px;
}

.img-list::-webkit-scrollbar {
    width: 6px;
}

.img-list::-webkit-scrollbar-track {
    background: transparent;
}

.img-list::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: var(--radius-full);
}

.img-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.img-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    transition: all 0.15s ease;
}

.img-item:last-child {
    margin-bottom: 0;
}

.img-item:hover {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--primary-light);
    border: 1px dashed var(--primary);
    box-shadow: none;
}

/* --- Drag Handle --- */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 18px;
    padding: 0 4px;
    user-select: none;
    line-height: 1;
    transition: color 0.15s;
}

.drag-handle:hover {
    color: var(--primary);
}

.drag-handle:active {
    cursor: grabbing;
}

/* --- Index --- */
.img-index {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* --- Preview --- */
.img-preview {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    flex-shrink: 0;
}

/* --- Info Column --- */
.img-info-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.img-url {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: "SF Mono", Menlo, Consolas, monospace;
}

.input-row {
    display: flex;
    gap: 6px;
    width: 100%;
    align-items: center;
}

.common-input {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    transition: all 0.15s;
    min-width: 0;
    background: var(--bg-input);
}

.common-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--primary-light);
    background: var(--bg-card);
}

.img-alt-input { flex: 1.2; }
.mp-input-item { flex: 1; border-color: var(--accent-border); background: var(--accent-light); color: var(--accent-dark); }
.mp-input-item:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.1); }
.mp-input-item::placeholder { color: rgba(180, 83, 9, 0.4); }

/* --- Action Buttons --- */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    line-height: 1;
}

.btn-icon:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.btn-remove {
    color: var(--text-muted);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: all 0.15s;
}

.btn-remove:hover {
    color: var(--danger);
    background: var(--danger-light);
}

/* ============================================
   Controls / Panels
   ============================================ */
.layout-controls {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.panel {
    background: var(--bg-input);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.panel-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 18px;
    display: block;
}

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

.form-row:last-child {
    margin-bottom: 0;
}

.form-row label,
.toggle-label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    min-width: 56px;
    white-space: nowrap;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-row .toggle-label {
    min-width: 56px;
}

.toggle-row .input-full {
    flex: 1;
}

.form-divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0;
}

.panel-action {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* ============================================
   Phone Frame — iPhone 17 Concept
   ============================================ */
.phone-frame {
    width: 380px;
    margin: 0 auto 20px;
    background: linear-gradient(160deg, #2c2c30 0%, #1c1c20 30%, #141418 50%, #1c1c20 70%, #2c2c30 100%);
    border-radius: 52px;
    padding: 10px 6px 10px;
    box-shadow:
        inset 0 0 1px rgba(255, 255, 255, 0.06),
        0 0 0 1px #222226,
        0 0 0 2px #3a3a40,
        0 0 0 3px #18181c,
        0 20px 56px rgba(0, 0, 0, 0.45),
        0 6px 16px rgba(0, 0, 0, 0.25);
    position: relative;
}

/* Side button — single flush action button */
.phone-frame::before {
    content: '';
    position: absolute;
    right: -2px;
    top: 200px;
    width: 2px;
    height: 88px;
    background: linear-gradient(180deg, #3a3a40, #2a2a30, #3a3a40);
    border-radius: 0 2px 2px 0;
}

/* Dynamic Island — smaller, pill shaped */
.phone-notch {
    width: 100px;
    height: 26px;
    background: radial-gradient(ellipse at 50% 40%, #1a1a1e 0%, #08080a 100%);
    border-radius: 15px;
    margin: 0 auto 10px;
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}

.phone-screen {
    background: #ffffff;
    border-radius: 42px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 700px;
    padding: 18px 4px;
    min-height: 140px;
    box-shadow: inset 0 0 1px rgba(0,0,0,0.04);
    scrollbar-width: none;
}

.phone-screen::-webkit-scrollbar {
    display: none;
}

.phone-screen img {
    max-width: 100%;
    height: auto;
    display: block;
}

.phone-bar {
    width: 100px;
    height: 4px;
    background: #4a4a50;
    border-radius: 2px;
    margin: 10px auto 0;
    opacity: 0.5;
}

/* ============================================
   Toast
   ============================================ */
#toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.toast {
    background: var(--text-primary);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.35s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}
