:root {
    --color-primary: #0d9488;
    --color-primary-light: #ccfbf1;
    --color-primary-hover: #0f766e;
    --color-bg: #f5f5f5;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --header-brand-height: 38px;
    --header-main-height: 88px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    --color-brand-bar-bg: #eef7f6;
    --color-brand-accent: #0d9488;
}

[data-theme="dark"] {
    --color-bg: #111827;
    --color-surface: #1f2937;
    --color-border: #374151;
    --color-text: #f9fafb;
    --color-text-secondary: #9ca3af;
    --color-brand-bar-bg: #0f172a;
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select {
    font-family: inherit;
}

.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.header-brand {
    height: var(--header-brand-height);
    background: var(--color-brand-bar-bg);
    border-bottom: 1px solid var(--color-border);
}

.header-brand-inner,
.header-main-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
}

.header-brand-inner {
    justify-content: space-between;
    gap: 12px;
}

.header-brand-start {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.header-main-inner {
    justify-content: center;
}

.brand-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-brand-accent);
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.brand-home:hover {
    opacity: 0.85;
}

.brand-mark {
    display: flex;
}

.brand-tagline {
    font-size: 12px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.brand-tools {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
}

.brand-tool {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    border: 1px solid transparent;
}

.brand-tool:hover {
    color: var(--color-brand-accent);
}

.brand-tool.is-current {
    color: var(--color-brand-accent);
    background: var(--color-surface);
    border-color: rgba(13, 148, 136, 0.35);
    font-weight: 600;
}

.header-main {
    height: var(--header-main-height);
    background: var(--color-surface);
}

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

.tool-logo-icon {
    color: var(--color-primary);
    display: flex;
    flex-shrink: 0;
}

.tool-logo-icon svg {
    width: 48px;
    height: 48px;
}

.tool-logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.tool-logo-name {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.tool-logo-desc {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

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

.site-main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.editor-section {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.preview-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 100%;
}

.preview-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
}

.preview-card-title {
    font-size: 14px;
    font-weight: 600;
}

.preview-card-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

.preview-card-hint {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.alert {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.6;
}

.alert--warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert--warning a {
    color: #b45309;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.alert--warning a:hover {
    color: #78350f;
}

[data-theme="dark"] .alert--warning {
    background: rgba(251, 191, 36, 0.12);
    color: #fcd34d;
    border-color: rgba(251, 191, 36, 0.35);
}

[data-theme="dark"] .alert--warning a {
    color: #fde68a;
}

[data-theme="dark"] .alert--warning a:hover {
    color: #fff;
}

.crop-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

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

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

.size-info-card {
    padding: 10px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.7;
}

.size-info-card strong {
    color: var(--color-text);
}

.size-info-mm {
    color: var(--color-primary);
}

.check-block {
    margin-top: 4px;
}

.settings-field--full {
    grid-column: 1 / -1;
}

.color-picker--block {
    width: 100%;
    height: 40px;
}

#bgStatus.is-error {
    color: #dc2626;
}

[data-theme="dark"] #bgStatus.is-error {
    color: #f87171;
}

.crop-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 320px;
    background: #0f172a;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.crop-stage canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: grab;
    touch-action: none;
}

.crop-stage canvas.is-dragging {
    cursor: grabbing;
}

.paper-stage {
    position: relative;
    width: 100%;
    background: #cbd5e1;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    /* 高度由 JS 按相纸比例设置，铺满内容区宽度 */
}

.paper-stage canvas {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: default;
    background: #fff;
}

.crop-empty,
.paper-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    font-size: 13px;
    pointer-events: none;
    z-index: 1;
}

.paper-empty {
    background: var(--color-bg);
}

.crop-empty.is-hidden,
.paper-empty.is-hidden {
    display: none;
}

.controls-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.panel-heading {
    font-size: 14px;
    font-weight: 600;
}

.field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    display: block;
    margin-bottom: 6px;
}

.field-hint {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.field-row-label {
    font-size: 12px;
    color: var(--color-text-secondary);
    min-width: 36px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.range-input {
    flex: 1;
    accent-color: var(--color-primary);
}

.range-value {
    font-size: 13px;
    color: var(--color-text-secondary);
    min-width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

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

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

.settings-field--pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.select-input,
.text-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 13px;
    outline: none;
}

.select-input:focus,
.text-input:focus {
    border-color: var(--color-primary);
}

.full-width {
    width: 100%;
}

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

.color-picker {
    width: 42px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}

.check-inline input {
    accent-color: var(--color-primary);
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.upload-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.upload-btn--block {
    width: 100%;
}

.action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 18px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.action-bar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn {
    padding: 10px 28px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-secondary:hover {
    background: var(--color-bg);
}

.site-footer {
    --footer-bg: #1e293b;
    --footer-text: #f1f5f9;
    --footer-text-muted: #94a3b8;
    --footer-border: #334155;
    --footer-card-bg: #273449;
    background: var(--footer-bg);
    color: var(--footer-text);
    margin-top: auto;
}

.footer-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 24px;
}

.footer-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 40px;
}

.footer-about {
    flex: 1;
    min-width: 0;
}

.footer-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--footer-text);
}

.footer-desc {
    font-size: 14px;
    color: var(--footer-text-muted);
    line-height: 1.8;
    max-width: 560px;
}

.footer-qrcodes {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    flex-shrink: 0;
}

.footer-qrcode-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.footer-qrcode-box {
    width: 108px;
    height: 108px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--footer-card-bg);
    border: 1px solid var(--footer-border);
}

.footer-qrcode-box img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.footer-qrcode-box.is-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    border-style: dashed;
    background: rgba(255, 255, 255, 0.03);
}

.footer-qrcode-placeholder {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--footer-text-muted);
    opacity: 0.7;
}

.footer-qrcode-label {
    font-size: 12px;
    color: var(--footer-text-muted);
    text-align: center;
    white-space: nowrap;
}

.footer-bottom {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--footer-border);
    text-align: center;
}

.footer-copyright {
    font-size: 12px;
    color: var(--footer-text-muted);
}

@media (max-width: 900px) {
    .settings-grid,
    .settings-grid--3 {
        grid-template-columns: 1fr;
    }

    .brand-tagline {
        display: none;
    }

    .action-bar {
        justify-content: stretch;
    }

    .action-bar-buttons {
        width: 100%;
    }

    .action-bar-buttons .btn {
        flex: 1;
    }

    .footer-main {
        flex-direction: column;
        gap: 28px;
    }

    .footer-qrcodes {
        align-self: flex-start;
    }
}
