/* ═════════════════════════════════════════════════════════════════════
   Design Tokens
   ═════════════════════════════════════════════════════════════════════ */
:root {
    --color-bg:            #080c14;
    --color-bg-elevated:   #0e1320;
    --color-surface:       #111827;
    --color-surface-hover: #1a2332;
    --color-border:        #1e293b;
    --color-border-light:  #263348;
    --color-border-glow:   rgba(245, 158, 11, 0.18);

    --color-gold:          #f59e0b;
    --color-gold-dim:      #d97706;
    --color-gold-soft:     rgba(245, 158, 11, 0.08);
    --color-gold-medium:   rgba(245, 158, 11, 0.14);

    --color-green:         #34d399;
    --color-green-soft:    rgba(52, 211, 153, 0.10);
    --color-red:           #f87171;
    --color-red-soft:      rgba(248, 113, 113, 0.10);

    --color-text:          #e2e8f0;
    --color-text-secondary:#94a3b8;
    --color-text-muted:    #64748b;

    --color-input-bg:      #0a0f1a;
    --color-input-border:  #263348;
    --color-ad-bg:         #0b0f1a;
    --color-ad-border:     #1a2236;

    --radius:              16px;
    --radius-sm:           10px;
    --radius-xs:           6px;
    --shadow:              0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.2);
    --shadow-lg:           0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-gold:         0 0 0 1px rgba(245, 158, 11, 0.10), 0 4px 24px rgba(245, 158, 11, 0.06);
    --max-width:           1100px;
    --sidebar-width:       280px;
}

/* ═════════════════════════════════════════════════════════════════════
   Reset & Base
   ═════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 70% 50% at 50% -10%, rgba(245, 158, 11, 0.03) 0%, transparent 60%),
        radial-gradient(ellipse 30% 40% at 85% 90%, rgba(37, 99, 235, 0.02) 0%, transparent 60%);
}

.app { display: flex; flex-direction: column; min-height: 100vh; position: relative; z-index: 1; }

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

/* ═════════════════════════════════════════════════════════════════════
   Ad Slots (hidden by default, shown via JS when ad loads)
   ═════════════════════════════════════════════════════════════════════ */
.ad-banner {
    display: none; flex-direction: column; align-items: center; justify-content: center;
    min-height: 60px; background: var(--color-ad-bg);
    border-top: 1px solid var(--color-ad-border);
    border-bottom: 1px solid var(--color-ad-border); position: relative;
    overflow: hidden;
}
.ad-banner.has-ad { display: flex; }
.ad-banner--top { min-height: 50px; max-height: 120px; }
.ad-banner--header {
    min-height: 90px; max-height: 150px; max-width: var(--max-width); margin: 0 auto;
    border: 1px solid var(--color-ad-border); border-radius: var(--radius-sm);
    margin-block: 16px;
}
.ad-banner--content { min-height: 90px; max-height: 150px; border: 1px solid var(--color-ad-border); border-radius: var(--radius-sm); margin-top: 32px; }
.ad-banner--footer { min-height: 90px; max-height: 150px; }
.ad-label {
    position: absolute; top: 2px; right: 8px; font-size: 0.6rem;
    color: var(--color-text-muted); opacity: 0.5; letter-spacing: 0.05em; z-index: 1;
}
.ad-slot {
    display: flex; align-items: center; justify-content: center;
    min-height: 60px; color: var(--color-text-muted); font-size: 0.75rem; opacity: 0.3; width: 100%;
    overflow: hidden;
}
.ad-banner--top .ad-slot { min-height: 50px; }
.ad-banner--header .ad-slot, .ad-banner--content .ad-slot { min-height: 90px; }
.ad-banner--footer .ad-slot { min-height: 90px; }

.sidebar-ad {
    display: none; position: relative; background: var(--color-ad-bg);
    border: 1px solid var(--color-ad-border); border-radius: var(--radius-sm);
    overflow: hidden; margin-bottom: 24px; min-height: 250px;
}
.sidebar-ad.has-ad { display: block; }

/* ═════════════════════════════════════════════════════════════════════
   Header (left-aligned: logo + nav + CTA)
   ═════════════════════════════════════════════════════════════════════ */
.header {
    border-bottom: 1px solid var(--color-border);
    background: rgba(8, 12, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 100;
}
.header-inner {
    max-width: var(--max-width); margin: 0 auto;
    display: flex; align-items: center; gap: 32px;
    padding: 0 24px; height: 60px;
}
.header-brand {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.header-logo { width: 36px; height: 36px; border-radius: 8px; }
.header-title {
    font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em;
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 40%, #fcd34d 70%, #f59e0b 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.header-nav { display: flex; gap: 8px; }
.nav-link {
    padding: 6px 16px; border-radius: var(--radius-xs);
    font-size: 0.9rem; color: var(--color-text-secondary); font-weight: 500;
    transition: all 0.2s;
}
.nav-link:hover { color: var(--color-text); background: var(--color-surface); }
.nav-link.active { color: var(--color-gold); background: var(--color-gold-soft); }

/* ── 导航拖拽排序 ──────────────────────────────────────────────────── */
.nav-link[draggable="true"] {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

.nav-link[draggable="true"]::before {
    content: '⋮⋮';
    display: inline-block;
    margin-right: 2px;
    font-size: 0.6rem;
    letter-spacing: -2px;
    opacity: 0;
    transition: opacity 0.2s;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.header-nav:hover .nav-link[draggable="true"]::before {
    opacity: 0.35;
}

.nav-link[draggable="true"]:hover::before {
    opacity: 0.6;
}

.nav-link[draggable="true"]:active {
    cursor: grabbing;
}

.nav-link.nav-dragging {
    opacity: 0.35;
}

.nav-link.nav-drag-over {
    box-shadow: 2px 0 0 0 var(--color-gold);
    background: var(--color-gold-soft);
}

/* 重置顺序按钮 */
.nav-reset-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    padding: 0; margin-left: 4px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    align-self: center;
    line-height: 1;
}

.nav-reset-order:hover {
    color: var(--color-text-secondary);
    background: var(--color-surface);
    border-color: var(--color-border-light);
}

.nav-reset-done {
    color: var(--color-green) !important;
}

.header-cta {
    margin-left: auto; padding: 8px 20px; border-radius: var(--radius-xs);
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #0a0e17; font-size: 0.88rem; font-weight: 600;
    transition: all 0.2s; flex-shrink: 0;
}
.header-cta:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3); }

/* ═════════════════════════════════════════════════════════════════════
   Hero Section
   ═════════════════════════════════════════════════════════════════════ */
.hero {
    padding: 64px 24px 48px;
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, rgba(245, 158, 11, 0.06) 0%, transparent 60%),
        var(--color-bg);
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}
.hero-inner { max-width: 680px; margin: 0 auto; }
.hero-badge {
    display: inline-block; padding: 6px 16px; border-radius: 99px;
    background: var(--color-gold-soft); border: 1px solid rgba(245, 158, 11, 0.15);
    color: var(--color-gold); font-size: 0.82rem; font-weight: 500;
    margin-bottom: 20px;
}
.hero-title {
    font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em;
    line-height: 1.25; margin-bottom: 12px;
}
.hero-accent {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 50%, #fcd34d 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-subtitle {
    color: var(--color-text-muted); font-size: 0.95rem; font-weight: 400;
    text-align: right; max-width: 680px; margin: 4px auto 36px;
}
.hero-stats {
    display: flex; justify-content: center; gap: 48px;
    padding: 24px 0;
}
.stat-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat-number {
    font-size: 1.4rem; font-weight: 800;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stat-label { font-size: 0.82rem; color: var(--color-text-muted); }

/* ═════════════════════════════════════════════════════════════════════
   Main Layout: content + sidebar
   ═════════════════════════════════════════════════════════════════════ */
.main--home {
    display: flex; gap: 32px;
    max-width: var(--max-width); margin: 40px auto 48px;
    padding: 0 24px;
}

/* Centered tool grid (no sidebar, no ads) */
.main--tools {
    max-width: 960px; margin: 40px auto 48px;
    padding: 0 24px;
}
.main--tools .tool-grid {
    grid-template-columns: repeat(4, 1fr);
}
.main--tools .section-header {
    justify-content: center; margin-bottom: 28px;
}
.main--tools .section-title {
    font-size: 1.2rem;
}
.main--tools .section-divider {
    max-width: 200px;
}

@media (max-width: 800px) {
    .main--tools .tool-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .main--tools .tool-grid { grid-template-columns: 1fr; }
    .main--tools { padding: 0 16px; }
}
.main-content { flex: 1; min-width: 0; }

/* ═════════════════════════════════════════════════════════════════════
   Section Header
   ═════════════════════════════════════════════════════════════════════ */
.section-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.section-title {
    font-size: 1.1rem; font-weight: 700; color: var(--color-text);
    white-space: nowrap;
}
.section-divider { flex: 1; height: 1px; background: var(--color-border); }

/* ═════════════════════════════════════════════════════════════════════
   Tool Card Grid
   ═════════════════════════════════════════════════════════════════════ */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.tool-card {
    display: flex; flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.25s;
    position: relative;
}
.tool-card:hover {
    border-color: var(--color-border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-gold);
}
.tool-card-accent {
    height: 3px; background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.accent--blue   { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.accent--green  { background: linear-gradient(90deg, #22c55e, #4ade80); }
.accent--purple { background: linear-gradient(90deg, #a855f7, #c084fc); }
.accent--orange { background: linear-gradient(90deg, #f97316, #fb923c); }
.accent--teal   { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }
.accent--rose   { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.accent--cyan   { background: linear-gradient(90deg, #06b6d4, #22d3ee); }
.tool-card-body {
    padding: 20px; display: flex; flex-direction: column; gap: 10px; flex: 1;
}
.tool-icon-wrap {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    background: var(--color-gold-soft);
    display: flex; align-items: center; justify-content: center;
}
.tool-icon { font-size: 1.3rem; }
.tool-title {
    font-size: 1rem; font-weight: 700; color: var(--color-text);
}
.tool-desc {
    font-size: 0.82rem; color: var(--color-text-muted); line-height: 1.5;
    flex: 1;
}
.tool-arrow {
    font-size: 0.82rem; color: var(--color-gold); font-weight: 600;
    transition: gap 0.2s;
}
.tool-card:hover .tool-arrow { text-shadow: 0 0 8px rgba(245, 158, 11, 0.3); }
.tool-badge {
    font-size: 0.72rem; padding: 3px 10px; border-radius: 99px;
    background: var(--color-border); color: var(--color-text-muted);
    align-self: flex-start; font-weight: 500;
}
.tool-card--coming { opacity: 0.75; cursor: default; }
.tool-card--coming:hover { transform: none; border-color: var(--color-border); box-shadow: none; }

/* ═════════════════════════════════════════════════════════════════════
   Sidebar
   ═════════════════════════════════════════════════════════════════════ */
.sidebar { width: var(--sidebar-width); flex-shrink: 0; }
.sidebar-section {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 24px;
}
.sidebar-title {
    font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; color: var(--color-text);
}
.sidebar-links { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sidebar-links a {
    display: block; padding: 8px 12px; border-radius: var(--radius-xs);
    font-size: 0.88rem; color: var(--color-text-secondary);
    transition: all 0.2s;
}
.sidebar-links a:hover { background: var(--color-surface-hover); color: var(--color-text); }
.link-disabled { opacity: 0.45; cursor: default !important; }

/* ═════════════════════════════════════════════════════════════════════
   Footer
   ═════════════════════════════════════════════════════════════════════ */
.footer {
    background: var(--color-bg-elevated); border-top: 1px solid var(--color-border);
    padding: 48px 24px 24px; margin-top: auto;
}
.footer-inner {
    max-width: var(--max-width); margin: 0 auto;
    display: flex; gap: 48px; margin-bottom: 32px;
}
.footer-col { flex: 1; min-width: 0; }
.footer-col h4 {
    font-size: 0.95rem; font-weight: 700; margin-bottom: 12px; color: var(--color-text);
}
.footer-col p {
    font-size: 0.85rem; color: var(--color-text-muted); line-height: 1.6;
}
.footer-col a {
    display: block; font-size: 0.85rem; color: var(--color-text-muted);
    padding: 4px 0; transition: color 0.2s;
}
.footer-col a:hover { color: var(--color-gold); }
.footer-bottom {
    max-width: var(--max-width); margin: 0 auto; padding-top: 20px;
    border-top: 1px solid var(--color-border);
    text-align: center; font-size: 0.8rem; color: var(--color-text-muted);
}

/* ═════════════════════════════════════════════════════════════════════
   Responsive
   ═════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .main--home { flex-direction: column; }
    .sidebar { width: 100%; }
    .tool-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-title { font-size: 2rem; }
    .hero-stats { gap: 28px; }
    .footer-inner { flex-direction: column; gap: 28px; }
}
@media (max-width: 640px) {
    .header-inner { padding: 0 16px; gap: 16px; }
    .header-title { display: none; }
    .header-cta { padding: 6px 14px; font-size: 0.8rem; }
    .hero { padding: 40px 16px 36px; }
    .hero-title { font-size: 1.5rem; }
    .hero-stats { gap: 20px; }
    .stat-number { font-size: 1.15rem; }
    .tool-grid { grid-template-columns: 1fr; }
}

.main--with-sidebar .main-content { flex: 1; min-width: 0; }
.main--with-sidebar .sidebar { width: var(--sidebar-width); flex-shrink: 0; padding-top: 8px; }

/* ── Footer (scoped to PDF tools page) ──────────────────────────── */
.main--with-sidebar ~ .footer {
    text-align: center; padding: 16px;
    color: var(--color-text-muted); font-size: 0.75rem;
    border-top: 1px solid var(--color-border);
}

/* ── Tool Grid (scoped to PDF tools page) ─────────────────────── */
.main--with-sidebar .tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

.main--with-sidebar .tool-card {
    display: flex; flex-direction: column; background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius);
    padding: 28px 24px 22px; text-decoration: none; color: var(--color-text);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer; position: relative; overflow: hidden;
}
.main--with-sidebar .tool-card::before {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    background: radial-gradient(ellipse at top left, var(--color-gold-soft), transparent 70%);
    opacity: 0; transition: opacity 0.3s;
}
.main--with-sidebar .tool-card:hover { border-color: var(--color-border-glow); box-shadow: var(--shadow-gold); transform: translateY(-2px); }
.main--with-sidebar .tool-card:hover::before { opacity: 1; }
.main--with-sidebar .tool-card--coming { opacity: 0.4; cursor: default; pointer-events: none; }
.main--with-sidebar .tool-card--coming::before { display: none; }

.main--with-sidebar .tool-icon { font-size: 2.2rem; margin-bottom: 10px; position: relative; z-index: 1; }
.main--with-sidebar .tool-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; position: relative; z-index: 1; }
.main--with-sidebar .tool-desc { color: var(--color-text-secondary); font-size: 0.82rem; flex: 1; margin-bottom: 12px; position: relative; z-index: 1; line-height: 1.5; }
.main--with-sidebar .tool-arrow { color: var(--color-gold); font-size: 0.82rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; position: relative; z-index: 1; transition: gap 0.2s; }
.main--with-sidebar .tool-card:hover .tool-arrow { gap: 8px; }
.main--with-sidebar .tool-badge { display: inline-block; background: var(--color-gold-soft); color: var(--color-gold); font-size: 0.72rem; padding: 2px 10px; border-radius: 99px; font-weight: 500; position: relative; z-index: 1; }

/* ── Tabs ──────────────────────────────────────────────────────── */
.tabs {
    display: flex; gap: 2px; background: var(--color-surface);
    border-radius: var(--radius); padding: 4px; margin-bottom: 24px;
    border: 1px solid var(--color-border);
}
.tab-btn {
    flex: 1; padding: 12px 14px; border: none; background: transparent;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 0.88rem;
    color: var(--color-text-secondary); transition: all 0.2s; font-family: inherit;
    white-space: nowrap; font-weight: 500;
}
.tab-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.tab-btn.active { background: var(--color-gold-soft); color: var(--color-gold); font-weight: 700; }

/* ── Tab 拖拽排序 ──────────────────────────────────────────────────── */
.tab-btn[draggable="true"] {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.tab-btn[draggable="true"]:active {
    cursor: grabbing;
}

.tab-btn.tab-dragging {
    opacity: 0.35;
}

.tab-btn.tab-drag-over {
    box-shadow: inset 0 0 0 2px var(--color-gold);
}

/* tab 重置按钮（在 .tabs 容器内） */
.tab-reset-order {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1;
}

.tab-reset-order:hover {
    color: var(--color-text-secondary);
    background: var(--color-surface-hover);
    border-color: var(--color-border-light);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Card ──────────────────────────────────────────────────────── */
.card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 28px 28px 24px;
}
.card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; color: var(--color-text); }
.card-desc { color: var(--color-text-secondary); font-size: 0.85rem; margin-bottom: 22px; line-height: 1.5; }

/* ── Form ──────────────────────────────────────────────────────── */
.tool-form { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--color-text); letter-spacing: 0.01em; }
.form-hint { font-size: 0.75rem; color: var(--color-text-muted); }

/* ── Download Format Radio Group ──────────────────────────────────── */
.download-format-group {
    display: flex;
    gap: 16px;
}
.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text);
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    background: var(--color-surface);
    transition: all 0.15s;
    user-select: none;
}
.radio-label:hover {
    border-color: var(--color-gold);
    background: var(--color-surface-hover);
}
.radio-label input[type="radio"] {
    accent-color: var(--color-gold);
    margin: 0;
}
.radio-label:has(input:checked) {
    border-color: var(--color-gold);
    background: rgba(245, 158, 11, 0.08);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.12);
}

/* ── File Upload ───────────────────────────────────────────────── */
.file-upload {
    position: relative; border: 2px dashed var(--color-border-light);
    border-radius: var(--radius-sm); padding: 24px 16px; text-align: center;
    cursor: pointer; transition: all 0.2s; background: var(--color-bg-elevated);
}
.file-upload:hover, .file-upload.drag-over { border-color: var(--color-gold); background: var(--color-gold-soft); }
.file-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--color-text-secondary); font-size: 0.85rem; }
.file-icon { font-size: 1.5rem; margin-bottom: 2px; }
.file-hint { font-size: 0.72rem; color: var(--color-text-muted); }
.file-selected { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--color-green); font-size: 0.85rem; }

/* ── Merge File List ───────────────────────────────────────────── */
.merge-file-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 0;
    transition: opacity 0.2s;
}
.merge-file-item.dragging { opacity: 0.4; }
.merge-file-handle {
    cursor: grab; color: var(--color-text-muted); font-size: 1.1rem;
    user-select: none; padding: 0 2px; letter-spacing: -2px;
}
.merge-file-handle:active { cursor: grabbing; }
.merge-file-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--color-primary); color: #fff; font-size: 0.75rem;
    font-weight: 600; flex-shrink: 0;
}
.merge-file-upload {
    flex: 1; min-width: 0; padding: 10px 12px;
}
.merge-file-upload .file-placeholder { font-size: 0.8rem; }
.merge-file-upload .file-selected { font-size: 0.8rem; justify-content: flex-start; }
.merge-file-remove {
    background: none; border: 1px solid transparent; color: var(--color-text-muted);
    font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
    transition: all 0.15s; flex-shrink: 0; line-height: 1;
}
.merge-file-remove:hover { color: var(--color-red); border-color: var(--color-red); background: rgba(239, 68, 68, 0.06); }

/* ── Input ─────────────────────────────────────────────────────── */
input[type="text"] {
    padding: 11px 16px; background: var(--color-input-bg);
    border: 1px solid var(--color-input-border); border-radius: var(--radius-sm);
    color: var(--color-text); font-size: 0.88rem; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
input[type="text"]:focus { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.10); }
input[type="text"]::placeholder { color: var(--color-text-muted); }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px; border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; font-family: inherit; cursor: pointer;
    transition: all 0.2s; letter-spacing: 0.01em;
}
.btn-primary {
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dim));
    color: #0a0e17; box-shadow: 0 2px 12px rgba(245, 158, 11, 0.15);
}
.btn-primary:hover { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3); filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

/* ── Result Box ────────────────────────────────────────────────── */
.result-box { margin-top: 18px; padding: 14px 18px; border-radius: var(--radius-sm); font-size: 0.87rem; font-weight: 500; }
.result-success { background: var(--color-green-soft); border: 1px solid rgba(52, 211, 153, 0.18); color: var(--color-green); }
.result-error { background: var(--color-red-soft); border: 1px solid rgba(248, 113, 113, 0.18); color: var(--color-red); }
.btn-download {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
    padding: 8px 18px; background: rgba(52, 211, 153, 0.12); color: var(--color-green);
    border-radius: var(--radius-xs); text-decoration: none; font-weight: 600;
    font-size: 0.84rem; transition: background 0.2s;
}
.btn-download:hover { background: rgba(52, 211, 153, 0.22); }

/* ── Diagram ──────────────────────────────────────────────────── */
.diagram { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 12px 0 18px; }
.diagram-sheet { width: 100%; max-width: 380px; aspect-ratio: 1.414/1; border: 2px solid var(--color-border-light); border-radius: var(--radius-xs); display: flex; overflow: hidden; }
.diagram-half { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 600; text-align: center; padding: 8px; }
.diagram-left { background: rgba(245, 158, 11, 0.06); border-right: 1px dashed var(--color-border-light); color: var(--color-gold); }
.diagram-right { background: rgba(37, 99, 235, 0.06); color: #60a5fa; }
.diagram-top { background: rgba(245, 158, 11, 0.06); border-bottom: 1px dashed var(--color-border-light); color: var(--color-gold); }
.diagram-bottom { background: rgba(37, 99, 235, 0.06); color: #60a5fa; }

/* ── File List (Multi-Invoice) ────────────────────────────────── */
.file-list {
    margin-top: 14px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    font-size: 0.82rem;
}
.file-list-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px;
    background: var(--color-bg-subtle, #f8f9fa);
    border-bottom: 1px solid var(--color-border-light);
    font-weight: 600;
}
.file-list-count {
    color: var(--color-text-secondary);
    font-weight: 400; font-size: 0.78rem;
}
.file-list-items {
    max-height: 360px;
    overflow-y: auto;
}
.file-list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--color-border-light);
    transition: background 0.15s;
    cursor: grab; user-select: none;
}
.file-list-item:last-child { border-bottom: none; }
.file-list-item:hover { background: var(--color-bg-elevated); }
.file-list-item.dragging { opacity: 0.4; background: var(--color-gold-soft); }
.file-list-item.drag-over { border-top: 2px solid var(--color-gold); }
.file-list-item .file-list-index {
    min-width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--color-bg-subtle, #f3f4f6);
    font-size: 0.72rem; font-weight: 700;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}
.file-list-item .file-list-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--color-text);
}
.file-list-item .file-list-size {
    flex-shrink: 0;
    color: var(--color-text-muted); font-size: 0.75rem;
}
.file-list-item .file-list-remove {
    flex-shrink: 0;
    background: none; border: none; cursor: pointer;
    color: var(--color-text-muted); font-size: 1.1rem;
    padding: 2px 6px; border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}
.file-list-item .file-list-remove:hover {
    color: var(--color-red);
    background: var(--color-red-soft, #fef2f2);
}
.file-list-actions {
    padding: 8px 14px;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-subtle, #f8f9fa);
    text-align: right;
}
.file-list-actions .btn-sm { font-size: 0.75rem; }
.file-list-pairing {
    border-top: 1px solid var(--color-border-light);
    background: var(--color-gold-soft, #fffdf0);
}
.file-list-pairing-header {
    padding: 8px 14px 4px;
    font-size: 0.75rem; font-weight: 600;
    color: var(--color-gold-dim, #b45309);
}
.file-list-pair-group {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 14px 8px;
}
.file-list-pair-group .pair-label {
    font-weight: 600;
    color: var(--color-gold-dim, #b45309);
    font-size: 0.73rem; white-space: nowrap;
    min-width: 38px;
}
.file-list-pair-group .pair-arrow {
    color: var(--color-text-muted); font-size: 0.8rem;
    flex-shrink: 0;
}
.file-list-pair-group .pair-file-tag {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.73rem;
    background: var(--color-bg-elevated, #fff);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border-light);
}
.file-list-pair-group .pair-warn {
    color: var(--color-red); font-size: 0.73rem;
}

/* ── Info Note ────────────────────────────────────────────────── */
.info-note {
    background: var(--color-gold-soft); border: 1px solid rgba(245, 158, 11, 0.10);
    border-radius: var(--radius-sm); padding: 12px 16px; font-size: 0.82rem;
    color: var(--color-text-secondary); line-height: 1.6;
}
.info-note strong { color: var(--color-gold); }

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(245, 158, 11, 0.15); border-top-color: var(--color-gold); border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Split Preview ────────────────────────────────────────────── */
.split-preview { margin-top: 24px; display: flex; flex-direction: column; align-items: center; }
.split-toolbar { width: 100%; max-width: 660px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.split-mode-selector { display: flex; gap: 2px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 2px; }
.split-mode-btn { padding: 6px 14px; border: none; background: transparent; border-radius: var(--radius-xs); cursor: pointer; font-size: 0.82rem; font-family: inherit; color: var(--color-text-secondary); transition: all 0.15s; white-space: nowrap; }
.split-mode-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.split-mode-btn.active { background: var(--color-gold-soft); color: var(--color-gold); font-weight: 600; }

#split-pages-container { width: 100%; max-width: 660px; max-height: 600px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg-elevated); padding: 8px; }
.page-wrapper { position: relative; width: 100%; box-shadow: var(--shadow); border-radius: 4px; overflow: hidden; background: #fff; }
.page-wrapper canvas { display: block; width: 100%; height: auto; }
.page-label { text-align: center; font-size: 0.78rem; color: var(--color-text-secondary); padding: 7px 0; background: var(--color-surface); border-bottom: 1px solid var(--color-border); font-weight: 600; }

.split-divider { position: relative; width: 100%; height: 28px; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; transition: background 0.15s; border-radius: 4px; }
.split-divider:hover { background: rgba(245, 158, 11, 0.04); }
.split-divider::before { content: ''; width: 80%; height: 2px; background: var(--color-border-light); border-radius: 1px; transition: background 0.2s; }
.split-divider:hover::before { background: var(--color-gold); height: 3px; }
.split-divider::after { content: '+'; position: absolute; font-size: 1.1rem; font-weight: 300; color: var(--color-text-muted); transition: color 0.2s; }
.split-divider:hover::after { color: var(--color-gold); }
.split-divider.has-split::before { background: var(--color-gold); height: 3px; }
.split-divider.has-split::after { content: '✂'; font-size: 0.85rem; }
.split-divider + .split-divider { display: none; }
.split-divider.drag-over { height: 36px; margin: 2px 0; }
.split-divider.drag-over::before { height: 4px; background: var(--color-gold); animation: dash-pulse 0.8s ease-in-out infinite alternate; }
@keyframes dash-pulse { from { opacity: 1; } to { opacity: 0.4; } }

.split-summary { width: 100%; max-width: 660px; text-align: center; padding: 12px 16px; background: var(--color-gold-soft); border: 1px solid rgba(245, 158, 11, 0.12); border-radius: var(--radius-sm); font-size: 0.85rem; margin-top: 12px; color: var(--color-text); }
.split-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 32px; color: var(--color-text-secondary); font-size: 0.9rem; }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; border: 1px solid var(--color-border-light); border-radius: var(--radius-xs); background: var(--color-surface); cursor: pointer; font-family: inherit; color: var(--color-text-secondary); transition: all 0.15s; font-weight: 500; }
.btn-sm:hover { background: var(--color-surface-hover); color: var(--color-text); border-color: var(--color-border); }

/* ── Select Input ─────────────────────────────────────────────── */
select {
    padding: 11px 16px; background: var(--color-input-bg);
    border: 1px solid var(--color-input-border); border-radius: var(--radius-sm);
    color: var(--color-text); font-size: 0.88rem; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s; outline: none;
    cursor: pointer; appearance: auto;
}
select:focus { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.10); }
select option { background: var(--color-surface); color: var(--color-text); }

/* ── Range Input ──────────────────────────────────────────────── */
input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 6px;
    background: var(--color-border); border-radius: 3px;
    outline: none; cursor: pointer; margin: 6px 0;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dim));
    border: 2px solid var(--color-bg); cursor: pointer;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}
input[type="range"]::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-gold), var(--color-gold-dim));
    border: 2px solid var(--color-bg); cursor: pointer;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* ── Editor (Content Text Edit) ────────────────────────────────── */
.editor-toolbar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: var(--color-bg-elevated);
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    margin-bottom: 16px; flex-wrap: wrap; position: sticky; top: 0; z-index: 30;
}
.editor-toolbar-info {
    font-size: 0.85rem; color: var(--color-text-secondary);
    font-weight: 600; margin-right: auto;
}
#editor-pages-container {
    display: flex; flex-direction: column; gap: 24px;
}
.editor-page-wrap {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); overflow: hidden;
}
.editor-page-header {
    padding: 8px 14px; font-size: 0.82rem; font-weight: 600;
    color: var(--color-text-secondary); background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
}
.editor-page-canvas-wrap {
    position: relative; background: #fff; line-height: 0; overflow: hidden;
}
.editor-page-canvas-wrap img {
    display: block; width: 100%; height: auto;
}
.editor-text-zone.modified::after {
    content: ''; position: absolute; top: -2px; right: -2px;
    width: 7px; height: 7px; background: var(--color-green);
    border-radius: 50%; z-index: 5; pointer-events: none;
}
.editor-loading {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 32px; color: var(--color-text-secondary);
    font-size: 0.9rem;
}
.file-count { font-size: 0.82rem; color: var(--color-text-secondary); }

/* ── Page Split ────────────────────────────────────────────────── */
.canvas-wrapper { position: relative; width: 100%; box-shadow: var(--shadow); border-radius: 4px; overflow: hidden; background: #fff; cursor: crosshair; line-height: 0; }
.canvas-wrapper canvas { display: block; width: 100%; height: auto; }
.page-split-line { position: absolute; left: 0; right: 0; height: 0; z-index: 10; pointer-events: auto; }
.page-split-line::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 3px; background: var(--color-gold); transform: translateY(-50%); box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.page-split-line-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; background: var(--color-gold); color: #0a0e17; font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4); white-space: nowrap; cursor: grab; user-select: none; }
.page-split-line-label:active { cursor: grabbing; }
.page-split-line-label .psl-remove { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: rgba(10,14,23,0.25); color: #0a0e17; font-size: 0.65rem; cursor: pointer; transition: background 0.15s; }
.page-split-line-label .psl-remove:hover { background: var(--color-red); color: #fff; }

.page-split-line-v { position: absolute; top: 0; bottom: 0; width: 0; z-index: 10; pointer-events: auto; }
.page-split-line-v::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: var(--color-gold); transform: translateX(-50%); box-shadow: 0 0 8px rgba(245, 158, 11, 0.4); }
.page-split-line-v .page-split-line-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; background: var(--color-gold); color: #0a0e17; font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4); white-space: nowrap; cursor: grab; }

/* ── Crop Rectangle ─────────────────────────────────────────────── */
.crop-rect {
    position: absolute;
    border: 2px dashed #22d3ee;
    background: rgba(34, 211, 238, 0.12);
    z-index: 15;
    pointer-events: none;
    box-sizing: border-box;
}
.crop-rect::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 9999px rgba(255,255,255,0.06);
    pointer-events: none;
}
.crop-info-label {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #22d3ee;
    color: #0a0e17;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    box-shadow: 0 2px 10px rgba(34, 211, 238, 0.4);
    white-space: nowrap;
    user-select: none;
    z-index: 16;
    pointer-events: auto;
}
.crop-info-label .psl-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(10,14,23,0.25);
    color: #0a0e17;
    font-size: 0.65rem;
    cursor: pointer;
    transition: background 0.15s;
}
.crop-info-label .psl-remove:hover { background: var(--color-red); color: #fff; }
.crop-exec-area { display: none; width: 100%; max-width: 660px; margin-top: 12px; text-align: center; }
.crop-exec-area.visible { display: block; }


/* ── PDF Tools Page Header (override sticky for tool pages) ──── */
.header--tool {
    background: rgba(8, 12, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    position: sticky; top: 0; z-index: 100;
    padding: 0;
}
.header--tool .header-inner {
    display: flex; align-items: center; gap: 32px;
    max-width: var(--max-width); margin: 0 auto;
    padding: 0 24px; height: 56px;
}
.header--tool .header-inner .header-brand {
    max-width: none; margin: 0; padding: 0; width: auto;
    flex-shrink: 0;
}
.quota-info {
    display: block; max-width: var(--max-width); margin: 0 auto;
    padding: 0 24px 4px; width: 100%;
    color: var(--color-gold); font-size: 0.8rem; font-weight: 500;
}
.quota-info.quota-exhausted {
    color: var(--color-red);
}
.header--tool .header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }



/* ═════════════════════════════════════════════════════════════════════
   Image Compression
   ═════════════════════════════════════════════════════════════════════ */
.quality-slider {
    width: 100%; height: 6px;
    -webkit-appearance: none; appearance: none;
    background: linear-gradient(90deg, var(--color-green) 0%, var(--color-gold) 50%, var(--color-red) 100%);
    border-radius: 3px; outline: none; cursor: pointer; margin-top: 6px;
}
.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff; border: 2px solid var(--color-gold);
    cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: transform 0.15s;
}
.quality-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.quality-slider::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff; border: 2px solid var(--color-gold); cursor: pointer;
}

.compress-stats {
    display: flex; flex-wrap: wrap; gap: 16px;
    padding: 16px 20px; margin-top: 16px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.compress-stats-item {
    font-size: 0.85rem; color: var(--color-text-secondary);
}
.compress-stats-item strong { color: var(--color-text); }
.compress-stats-saved strong { color: var(--color-green); }

.compress-preview { margin-top: 16px; }

.compress-table {
    width: 100%; border-collapse: collapse;
    font-size: 0.85rem;
}
.compress-table th {
    text-align: left; padding: 10px 12px;
    background: var(--color-surface); color: var(--color-text-muted);
    font-weight: 600; border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.compress-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.compress-table tr:hover td { background: var(--color-surface-hover); }
.compress-processing { color: var(--color-gold); }
.compress-success { color: var(--color-green); font-weight: 600; }
.compress-warn { color: var(--color-red); }
.compress-error { color: var(--color-red); font-weight: 600; }
.compress-pending { color: var(--color-text-muted); }

.btn-download--small {
    padding: 4px 10px; font-size: 0.78rem;
}

.btn-secondary {
    padding: 10px 24px; border: 1px solid var(--color-border);
    border-radius: var(--radius-xs); background: var(--color-surface);
    color: var(--color-text); font-size: 0.92rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { border-color: var(--color-gold); background: var(--color-surface-hover); }

/* ═════════════════════════════════════════════════════════════════════
   Image Collage
   ═════════════════════════════════════════════════════════════════════ */
.collage-toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 12px 16px; margin-bottom: 12px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.collage-toolbar-group {
    display: flex; align-items: center; gap: 6px;
}
.collage-label {
    font-size: 0.82rem; color: var(--color-text-muted); white-space: nowrap;
}
.collage-size-input {
    width: 72px; padding: 4px 6px; text-align: center;
    background: var(--color-input-bg); border: 1px solid var(--color-input-border);
    border-radius: var(--radius-xs); color: var(--color-text);
    font-size: 0.82rem; font-family: inherit;
}
.collage-size-input:focus { border-color: var(--color-gold); outline: none; }

#collage-workspace {
    overflow: auto; text-align: center;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 2px; min-height: 200px;
    display: flex; align-items: center; justify-content: center;
}

#collage-canvas {
    display: block; cursor: default;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

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

/* Context menu */
.collage-context-menu {
    position: fixed; z-index: 1000;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    min-width: 160px; padding: 4px 0;
}
.context-menu-item {
    padding: 8px 16px; font-size: 0.85rem; color: var(--color-text-secondary);
    cursor: pointer; transition: all 0.15s; user-select: none;
}
.context-menu-item:hover {
    background: var(--color-surface-hover); color: var(--color-text);
}
.context-menu-item:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.context-menu-item:last-child  { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

/* ── Responsive
@media (max-width: 900px) {
    .main--with-sidebar { flex-direction: column; }
    .sidebar { width: 100%; display: flex; gap: 16px; padding-top: 0; }
    .sidebar-ad { flex: 1; min-height: 90px; margin-bottom: 0; }
}
@media (max-width: 640px) {
	    .header--tool .header-inner { gap: 12px; padding: 0 12px; }
    .quota-info { padding: 0 12px 4px; font-size: 0.75rem; }
    .tabs { flex-wrap: wrap; }
    .tab-btn { font-size: 0.8rem; padding: 10px; }
    .card { padding: 20px 16px; }
    .sidebar { flex-direction: column; }
    .header--tool .header-logo { width: 30px; height: 30px; }
}

/* ── Media Task List ─────────────────────────────────────────────── */
.task-list-card { margin-top: 24px; }
.task-list-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.task-list-header h2 { margin-bottom: 0 !important; }
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-list-empty {
    text-align: center; color: var(--color-text-muted);
    font-size: 0.85rem; padding: 24px 0;
}
.task-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s;
    flex-wrap: wrap;
}
.task-item:hover { border-color: var(--color-border-light); }
.task-item-icon { font-size: 1.3rem; flex-shrink: 0; }
.task-item-name {
    font-size: 0.85rem; font-weight: 600; color: var(--color-text);
    max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-item-arrow { color: var(--color-text-muted); font-size: 0.8rem; flex-shrink: 0; }
.task-item-format {
    font-size: 0.78rem; background: var(--color-surface);
    padding: 2px 10px; border-radius: 99px;
    color: var(--color-text-secondary); font-weight: 500;
    white-space: nowrap;
}
.task-item-quality {
    font-size: 0.75rem; color: var(--color-text-muted);
    white-space: nowrap;
}
.task-item-spacer { flex: 1; min-width: 0; }
.task-status {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.82rem; font-weight: 600; white-space: nowrap;
    padding: 2px 0;
}
.task-status-processing { color: var(--color-gold); }
.task-status-done { color: var(--color-green); }
.task-status-failed { color: var(--color-red); }
.task-actions {
    display: flex; gap: 6px; flex-shrink: 0;
}
.task-btn-download {
    padding: 4px 12px; font-size: 0.78rem;
    background: rgba(52, 211, 153, 0.12); color: var(--color-green);
    border-radius: var(--radius-xs); text-decoration: none;
    font-weight: 600; transition: background 0.2s;
    border: none; cursor: pointer; font-family: inherit;
    white-space: nowrap;
}
.task-btn-download:hover { background: rgba(52, 211, 153, 0.22); }
.task-btn-delete {
    padding: 4px 10px; font-size: 0.75rem;
    background: transparent; color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs); cursor: pointer;
    transition: all 0.2s; font-family: inherit;
    white-space: nowrap;
}
.task-btn-delete:hover { color: var(--color-red); border-color: var(--color-red); }
.task-btn-retry {
    padding: 4px 12px; font-size: 0.78rem;
    background: rgba(245, 158, 11, 0.12); color: var(--color-gold);
    border-radius: var(--radius-xs); font-weight: 600;
    transition: background 0.2s; border: none;
    cursor: pointer; font-family: inherit; white-space: nowrap;
}
.task-btn-retry:hover { background: rgba(245, 158, 11, 0.22); }
.task-error-text {
    font-size: 0.75rem; color: var(--color-red);
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-detail-row {
    width: 100%; display: flex; align-items: center; gap: 12px;
}

@media (max-width: 640px) {
    .task-item { gap: 8px; padding: 10px 12px; }
    .task-item-name { max-width: 120px; }
    .task-error-text { max-width: 100px; }
    .task-item-spacer { display: none; }
}

/* ═════════════════════════════════════════════════════════════════════
   Command Query (命令查询)
   ═════════════════════════════════════════════════════════════════════ */
.cq-tabs-wrapper {
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.cq-tabs {
    display: flex; gap: 8px; flex-wrap: nowrap;
    padding-bottom: 4px;
}
.cq-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
    white-space: nowrap; flex-shrink: 0;
    font-family: inherit;
}
.cq-tab:hover {
    border-color: var(--color-gold-dim);
    color: var(--color-text);
    background: var(--color-surface-hover);
}
.cq-tab.active {
    background: var(--color-gold-soft);
    border-color: var(--color-gold);
    color: var(--color-gold);
    box-shadow: var(--shadow-gold);
}
.cq-tab-icon { font-size: 1.1rem; }
.cq-tab-label { font-size: 0.88rem; }

/* Search */
.cq-search-wrap {
    position: relative; margin-bottom: 16px;
}
.cq-search-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    font-size: 1rem; pointer-events: none;
}
.cq-search-input {
    width: 100%; padding: 12px 16px 12px 44px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 0.95rem; font-family: inherit;
    outline: none; transition: border-color 0.2s;
}
.cq-search-input:focus {
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08);
}
.cq-search-input::placeholder { color: var(--color-text-muted); }

/* Meta bar */
.cq-meta {
    font-size: 0.82rem; color: var(--color-text-muted);
    margin-bottom: 16px;
}

/* Results */
.cq-results {
    display: grid; gap: 12px;
}
.cq-empty {
    text-align: center; padding: 60px 20px;
    color: var(--color-text-muted); font-size: 0.95rem;
}

/* Card */
.cq-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    transition: border-color 0.2s;
}
.cq-card:hover { border-color: var(--color-border-light); }
.cq-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.cq-card-name {
    font-weight: 700; font-size: 1.05rem;
    color: var(--color-gold);
    font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}
.cq-copy-btn {
    background: var(--color-gold-soft); border: 1px solid transparent;
    color: var(--color-gold); font-size: 0.85rem;
    padding: 4px 8px; border-radius: var(--radius-xs);
    cursor: pointer; transition: all 0.2s;
    line-height: 1; flex-shrink: 0;
}
.cq-copy-btn:hover { background: var(--color-gold-medium); border-color: var(--color-gold-dim); }
.cq-card-syntax {
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    padding: 10px 14px; margin-bottom: 10px;
    overflow-x: auto; white-space: pre-wrap; word-break: break-all;
    font-size: 0.85rem; line-height: 1.6;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
    color: var(--color-text);
}
.cq-card-desc {
    font-size: 0.9rem; color: var(--color-text-secondary);
    line-height: 1.6; margin-bottom: 8px;
}
.cq-card-example {
    background: var(--color-green-soft);
    border: 1px solid rgba(52, 211, 153, 0.15);
    border-radius: var(--radius-xs);
    padding: 8px 12px;
    font-size: 0.84rem; color: var(--color-green);
}
.cq-example-label {
    font-weight: 600; margin-right: 4px;
}
.cq-card-example code {
    font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

@media (max-width: 640px) {
    .cq-tab { padding: 8px 14px; font-size: 0.82rem; }
    .cq-card { padding: 12px 14px; }
    .cq-card-syntax { font-size: 0.78rem; padding: 8px 10px; }
}

/* ═════════════════════════════════════════════════════════════════════
   Unit Converter (单位换算)
   ═════════════════════════════════════════════════════════════════════ */

/* Tabs */
.uc-tabs { margin-bottom: 20px; flex-wrap: wrap; }

/* Live clock */
.uc-now {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 4px 24px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 16px; margin-bottom: 16px;
}
.uc-now-row {
    display: flex; align-items: center; gap: 8px;
}
.uc-now-label {
    font-size: 0.8rem; color: var(--color-text-muted);
    white-space: nowrap; min-width: 90px;
}
.uc-now-val {
    font-size: 0.9rem; font-weight: 600;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
    color: var(--color-text);
}
.uc-now-val.gold { color: var(--color-gold); }
.uc-copy-inline { flex-shrink: 0; }

/* Two-column panels */
.uc-two-col {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.uc-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 20px;
}
.uc-panel-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.uc-field { margin-bottom: 12px; }
.uc-label {
    display: block; font-size: 0.82rem; color: var(--color-text-muted);
    margin-bottom: 4px;
}
.uc-input {
    width: 100%; padding: 10px 14px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-input-border);
    border-radius: var(--radius-xs);
    color: var(--color-text); font-size: 0.9rem;
    font-family: inherit; outline: none;
    transition: border-color 0.2s;
}
.uc-input[type="datetime-local"] {
    color-scheme: dark;
    min-height: 44px;
    cursor: pointer;
    padding-right: 36px;
    position: relative;
}
.uc-input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    position: absolute;
    right: 8px;
    width: 24px;
    height: 24px;
    opacity: 0.85;
    transition: opacity 0.15s;
}
.uc-input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}
.uc-input:focus { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08); }
.uc-input::placeholder { color: var(--color-text-muted); }
.uc-btn-full { width: 100%; }

.uc-result {
    margin-top: 14px;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xs);
    padding: 12px 16px;
}
.uc-result-row {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0;
}
.uc-result-row + .uc-result-row { border-top: 1px solid var(--color-border); margin-top: 6px; padding-top: 10px; }
.uc-result-row span {
    font-size: 0.82rem; color: var(--color-text-muted); min-width: 60px;
}
.uc-result-row code {
    font-size: 0.9rem; color: var(--color-gold); font-weight: 600;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
    word-break: break-all;
}
.uc-result-row .cq-copy-btn { flex-shrink: 0; margin-left: auto; }

/* Generic converter row */
.uc-convert-row {
    display: flex; align-items: center; gap: 16px;
}
.uc-convert-input {
    display: flex; gap: 8px; flex: 1;
}
.uc-val-input {
    flex: 1; min-width: 120px;
}
.uc-unit-select {
    width: auto; min-width: 150px;
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 32px;
}
.uc-swap {
    font-size: 1.3rem; cursor: pointer; color: var(--color-text-muted);
    transition: color 0.2s; user-select: none; flex-shrink: 0;
    padding: 8px;
}
.uc-swap:hover { color: var(--color-gold); }

@media (max-width: 640px) {
    .uc-now { grid-template-columns: 1fr; gap: 8px; padding: 12px 14px; }
    .uc-two-col { grid-template-columns: 1fr; }
    .uc-panel { padding: 14px 16px; }
    .uc-convert-row { flex-direction: column; gap: 12px; }
    .uc-swap { transform: rotate(90deg); }
}
