/* Professional MDFileConverter - ilovepdf.com inspired design */

/* Self-hosted Inter 4.1 (see /fonts/PROVENANCE.md). Latin subset, ~31 KB per weight. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/inter-700.woff2') format('woff2');
}

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

:root {
    --primary-color: #FF6B35;
    --primary-hover: #E55A2B;
    --secondary-color: #2C3E50;
    --accent-color: #3498DB;
    --success-color: #2ECC71;
    --warning-color: #F39C12;
    --error-color: #E74C3C;
    --bg-color: #F8F9FA;
    --card-bg: #FFFFFF;
    --input-bg: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --border-color: #E1E8ED;
    --shadow-light: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-medium: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-strong: 0 8px 24px rgba(0,0,0,0.15);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme — applied when <html data-theme="dark">.
   Keeps the same brand orange, swaps surfaces and text. */
[data-theme="dark"] {
    --primary-color: #FF7A47;
    --primary-hover: #FF8B5C;
    --secondary-color: #E2E8F0;
    --accent-color: #60A5FA;
    --success-color: #34D399;
    --warning-color: #FBBF24;
    --error-color: #F87171;
    --bg-color: #0F172A;
    --card-bg: #1E293B;
    --input-bg: #0F172A;
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --border-color: #334155;
    --shadow-light: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-medium: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-strong: 0 8px 24px rgba(0,0,0,0.5);
}

/* Smooth transition when toggling */
html, body, .hero, .mode-card, .panel, .drop-strip, textarea, input, button {
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-feature-settings: "cv11", "ss01";
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    /* Atmospheric brand lighting — a single warm radial behind everything.
       `fixed` attachment keeps the glow anchored to the viewport so scrolling
       never reveals a seam where the gradient ends. */
    background:
        radial-gradient(ellipse 1100px 600px at 50% -10%, rgba(255, 107, 53, 0.16), transparent 65%),
        var(--bg-color);
    background-attachment: fixed;
}

[data-theme="dark"] body {
    background:
        radial-gradient(ellipse 1100px 600px at 50% -10%, rgba(255, 122, 71, 0.14), transparent 65%),
        var(--bg-color);
    background-attachment: fixed;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Hero */
.hero {
    position: relative;
    text-align: center;
    padding: 48px 20px 36px;
    margin-bottom: 20px;
}

.hero-inner {
    max-width: 960px;
    margin: 0 auto;
}

.brand-mark {
    position: absolute;
    top: 18px;
    left: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-decoration: none;
    opacity: 0.9;
    z-index: 10;
}
.brand-mark:hover { opacity: 1; }
.brand-mark-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}
.brand-mark-text { line-height: 1; }

/* Theme toggle — mirrored position on the right of the hero */
.theme-toggle {
    position: absolute;
    top: 14px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
    box-shadow: var(--shadow-light);
}
.theme-toggle:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: var(--shadow-medium);
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(255, 107, 53, 0.10);
    border: 1px solid rgba(255, 107, 53, 0.22);
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 28px;
}

.hero-title {
    font-size: clamp(40px, 7vw, 76px);
    font-weight: 700;
    line-height: 1.03;
    letter-spacing: -0.035em;
    color: var(--text-primary);
    margin: 0 0 20px;
    white-space: nowrap;
}
@media (max-width: 760px) {
    .hero-title { white-space: normal; }
}

.hero-sub {
    font-size: clamp(16px, 1.6vw, 19px);
    line-height: 1.55;
    color: var(--text-secondary);
    max-width: 620px;
    margin: 0 auto;
    font-weight: 400;
}

/* Trust pills under the hero subhead. Five short claims, all defensibly
   true under the privacy-first / no-analytics posture. Wraps on mobile. */
.hero-trust-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 14px;
    margin: 24px auto 0;
    padding: 0;
    list-style: none;
    max-width: 720px;
}
.hero-trust-pills li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}
.hero-trust-pills li .icon {
    color: var(--success-color);
}
@media (max-width: 480px) {
    .hero-trust-pills {
        gap: 6px 10px;
        font-size: 12px;
    }
    .hero-trust-pills li { font-size: 12px; }
}

/* Motion — staggered entrance on first paint, respects reduced-motion. */
@media (prefers-reduced-motion: no-preference) {
    .privacy-badge,
    .hero-title,
    .hero-sub,
    .hero-trust-pills {
        animation: heroFadeUp 0.55s cubic-bezier(0.2, 0, 0, 1) both;
    }
    .privacy-badge       { animation-delay: 0.05s; }
    .hero-title          { animation-delay: 0.14s; }
    .hero-sub            { animation-delay: 0.24s; }
    .hero-trust-pills    { animation-delay: 0.32s; }

    .drop-strip.file-dropped {
        animation: dropPulse 0.45s ease-out;
    }
}
@keyframes heroFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes dropPulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.35); }
    100% { box-shadow: 0 0 0 24px rgba(255, 107, 53, 0); }
}

/* Icon base class — every <svg class="icon"> picks these up. */
.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    vertical-align: -0.15em;
    color: currentColor;
}
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }
.icon--spin { animation: icon-spin 1s linear infinite; }
@keyframes icon-spin { to { transform: rotate(360deg); } }

/* Tool grid (Phase 1 redesign, locked 2026-05-18).
   iLovePDF-style card grid: filter chips on top, fluid CSS Grid below.
   Each card is an <a href="#<slug>"> for shareability + Phase 2 URL hand-off.
   Backward-compat: .mode-card class + data-mode attr kept (app.js contract). */
.tool-grid-wrapper {
    max-width: 1120px;
    margin: 0 auto 40px;
}

.tool-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
    justify-content: center;
}

.filter-chip {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    line-height: 1.2;
}
.filter-chip:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}
.filter-chip.active,
.filter-chip[aria-pressed="true"] {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.filter-chip:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Below 640px the chips become horizontally scrollable rather than wrap,
   to preserve scannability when they get longer (Phase 3 adds more). */
@media (max-width: 640px) {
    .tool-filter-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding: 4px 4px 8px;
        margin-left: -4px;
        margin-right: -4px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
}

/* Card grid: auto-fit lets the columns reflow 1/2/3/4 across breakpoints
   with no extra media queries. minmax(220px, 1fr) is the visual sweet spot. */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
@media (max-width: 480px) {
    .tool-grid { gap: 12px; }
}

/* Mode card (class name kept for app.js click contract).
   Re-styled as an iLovePDF-style horizontal card: tinted icon left, text right. */
.mode-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 16px;
    min-height: 110px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-light);
    position: relative;
    overflow: hidden;
}
.mode-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}
.mode-card:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
.mode-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 4px 14px rgba(255, 107, 53, 0.18);
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(255, 107, 53, 0.05) 100%);
}
/* Dark mode needs more orange in the gradient — the 5% tint disappears on slate. */
[data-theme="dark"] .mode-card.active {
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(255, 122, 71, 0.14) 100%);
}
.mode-card.active::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    background: var(--primary-color);
}

/* Icon "tile" inside each card — tinted square left of the text */
.tool-card-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 107, 53, 0.10);
    color: var(--primary-color);
    border-radius: 10px;
    flex-shrink: 0;
}
.mode-card.active .tool-card-icon-wrap {
    background: rgba(255, 107, 53, 0.16);
}
.mode-icon {
    width: 22px;
    height: 22px;
    color: currentColor;
}

.tool-card-content {
    flex: 1 1 auto;
    min-width: 0;
}
.mode-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 4px;
}
.mode-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* Filter behavior: hide cards not matching the active category.
   Driven by JS toggling data-filter on .tool-grid. */
.tool-grid[data-filter="convert-from-md"] .mode-card:not([data-category="convert-from-md"]),
.tool-grid[data-filter="convert-to-md"] .mode-card:not([data-category="convert-to-md"]),
.tool-grid[data-filter="markdown-tools"] .mode-card:not([data-category="markdown-tools"]) {
    display: none;
}

/* Disabled card (kept for future feature pauses). */
.mode-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.mode-card.disabled:hover {
    transform: none;
    box-shadow: var(--shadow-light);
    border-color: var(--border-color);
}
.mode-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fff;
    background: var(--text-secondary);
    padding: 3px 8px;
    border-radius: 999px;
    z-index: 2;
}

/* Main Workspace */
.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

/* Compact drop strip — sits BELOW the editor in viewer-first layout.
   One horizontal row: icon, label + extensions, and trust guarantees. */
.drop-strip {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 20px;
    margin: 20px 0 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.drop-strip:hover {
    border-color: rgba(255, 107, 53, 0.35);
    box-shadow: 0 2px 10px rgba(255, 107, 53, 0.08);
}

.drop-strip.drag-over {
    border-color: var(--primary-color);
    transform: scale(1.002);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.18), 0 6px 18px rgba(255, 107, 53, 0.15);
}

/* Locked while an async conversion is in flight. pointer-events suppresses
   click + the bulk of drag/drop in modern browsers; app.js also self-guards
   the drop handler (defense in depth). */
.drop-strip.busy {
    pointer-events: none;
    opacity: 0.6;
    cursor: progress;
}

.drop-strip-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    color: var(--primary-color);
}

.drop-strip-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.drop-strip-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.drop-strip-exts {
    font-size: 12px;
    color: var(--text-secondary);
    font-feature-settings: "tnum";
}

/* Below 768px, hide the extensions line to reclaim horizontal space.
   (The drop-strip-trust pills moved to the hero in Phase 1.) */
@media (max-width: 768px) {
    .drop-strip-exts { display: none; }
}

/* File Controls */
.file-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-btn {
    background: var(--primary-color);
    color: white;
    height: 44px;
    padding: 0 22px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
}

.file-input-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.file-status {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Compact Editor Panels */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-light);
    display: flex;
    flex-direction: column;
    height: clamp(420px, 55vh, 640px);
}

/* Flush label, no surface chrome — reads as workspace, not a card */
.panel-header {
    padding: 14px 20px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h2 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.panel-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-small {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-small:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-small.secondary {
    background: var(--text-secondary);
}

.btn-small.clear {
    background: var(--error-color);
}

/* Text Areas and Preview */
#inputArea,
#outputSource {
    flex: 1;
    border: none;
    padding: 20px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    background: var(--card-bg);
    color: var(--text-primary);
}

#inputArea:focus,
#outputSource:focus {
    background: rgba(255, 107, 53, 0.02);
}

#preview {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--card-bg);
    color: var(--text-primary);
}
#preview h1, #preview h2, #preview h3, #preview h4, #preview h5, #preview h6 {
    color: var(--text-primary);
    margin-top: 1.2em;
    margin-bottom: 0.5em;
}
#preview p { margin-bottom: 0.8em; }
#preview code {
    background: var(--bg-color);
    color: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}
#preview pre {
    background: var(--bg-color);
    color: var(--text-primary);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}
#preview pre code { background: transparent; padding: 0; color: inherit; }
#preview blockquote {
    border-left: 4px solid var(--primary-color);
    margin: 1em 0;
    padding: 8px 16px;
    background: var(--bg-color);
    color: var(--text-secondary);
}
#preview a { color: var(--primary-color); }
#preview table { border-collapse: collapse; width: 100%; margin: 1em 0; }
#preview th, #preview td { border: 1px solid var(--border-color); padding: 8px 12px; text-align: left; }
#preview th { background: var(--bg-color); }

/* View Toggle */
.view-toggle {
    display: flex;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.view-toggle button {
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-weight: 500;
}

.view-toggle button.active {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Batch Processing - More Prominent */
.batch-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin: 30px 0;
    overflow: hidden;
    box-shadow: var(--shadow-light);
}

.batch-header {
    background: linear-gradient(135deg, #FF6B35 0%, #E55A2B 100%);
    color: white;
    padding: 20px 25px;
    text-align: center;
}

.batch-header h3 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.batch-header p {
    opacity: 0.9;
    font-size: 1rem;
}

.batch-content {
    padding: 25px;
}

.batch-file-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    background: var(--bg-color);
}

.batch-file-item {
    display: grid;
    grid-template-columns: 2fr 1fr 80px 30px;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    transition: var(--transition);
    background: var(--card-bg);
}

.batch-file-item:hover {
    background: rgba(255, 107, 53, 0.08);
}

.batch-file-item:last-child {
    border-bottom: none;
}

.batch-file-item.processing {
    background: rgba(243, 156, 18, 0.1);
    border-left: 4px solid var(--warning-color);
}

.batch-file-item.completed {
    background: rgba(46, 204, 113, 0.1);
    border-left: 4px solid var(--success-color);
}

.batch-file-item.error {
    background: rgba(231, 76, 60, 0.1);
    border-left: 4px solid var(--error-color);
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
}

.file-mode {
    background: var(--accent-color);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
}

.file-status {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: capitalize;
    text-align: center;
}

.batch-file-item.processing .file-status {
    color: var(--warning-color);
}

.batch-file-item.completed .file-status {
    color: var(--success-color);
}

.batch-file-item.error .file-status {
    color: var(--error-color);
}

.remove-btn {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
}

.remove-btn:hover {
    background: var(--error-color);
    color: white;
}

/* Batch Controls */
.batch-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    height: 44px;
    padding: 0 22px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

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

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    height: 44px;
    padding: 0 22px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* Export Section — flat, relies on whitespace + centering for hierarchy */
.export-section {
    padding: 40px 20px 24px;
    text-align: center;
    margin-top: 24px;
}

.export-section h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.export-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.export-buttons button {
    height: 44px;
    padding: 0 22px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    min-width: 140px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
}

#copyOutput {
    background: var(--accent-color);
    color: white;
}

#downloadOutput {
    background: var(--success-color);
    color: white;
}

.export-buttons button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.export-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Options Panel — flat, no card chrome */
.options-panel {
    padding: 24px 8px 8px;
    margin: 12px 0 20px;
}

.options-panel h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.options-grid label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.options-grid input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

/* Field controls (select / text input) used by the PDF options panel.
   The text-to-md panel uses bare checkbox labels; PDF options need
   labelled selects + inputs, so these lay out vertically. */
/* More specific than `.options-grid label` so flex-direction/alignment win. */
.options-panel .opt-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    cursor: default;
}

.opt-label {
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.opt-field select,
.opt-field input[type="text"] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.opt-field select:focus,
.opt-field input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

.opt-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opt-inline select {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .workspace,
    .editor-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .panel {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .hero {
        padding: 56px 16px 40px;
    }

    .brand-mark {
        top: 14px;
        left: 16px;
    }

    .mode-card {
        flex: 0 0 180px;
        padding: 20px 15px;
    }

    .batch-file-item {
        grid-template-columns: 2fr 30px;
        gap: 10px;
    }
    
    .file-mode,
    .file-status {
        display: none;
    }
    
    .batch-controls,
    .export-buttons {
        flex-direction: column;
    }
    
    .btn-primary,
    .btn-secondary,
    .export-buttons button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 48px 12px 32px;
    }

    .mode-card {
        padding: 20px 15px;
    }

    .mode-icon {
        font-size: 2rem;
    }

    .panel {
        height: 250px;
    }
}

/* ============================================================
 * Mode-shape switching (Phase 2 — Mermaid editor groundwork)
 *
 * Two co-existing root containers per page:
 *   .converter-shape — the existing converter UI (drop strip,
 *                      file controls, workspace, batch, export).
 *   .editor-shape    — the Mermaid editor mount point (#editorRoot).
 *
 * Visibility is driven by <body data-shape> so the active shape
 * paints correctly on first byte (no FOUC). app.js's applyShape()
 * keeps body.dataset.shape in sync at runtime.
 * ============================================================ */

.editor-shape { display: none; }
body[data-shape="editor"] .converter-shape { display: none; }
body[data-shape="editor"] .editor-shape { display: block; }

/* Mode card variant: distinguish the Mermaid card from the 9
 * converters with a small EDITOR pill. Phase 2 directory cards. */
.mode-card .mode-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 7px;
    background: rgba(255, 107, 53, 0.12);
    color: var(--primary-color);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    vertical-align: middle;
}
[data-theme="dark"] .mode-card .mode-badge {
    background: rgba(255, 122, 71, 0.18);
}

/* ============================================================
 * Mermaid Diagram Editor
 *
 * Editor-shape UI mounted into #editorRoot by mermaid-parser.js.
 * Layout mirrors the converter workspace (2-pane editor + preview)
 * but with the editor-specific buttons + templates strip below.
 * ============================================================ */

.mermaid-editor {
    max-width: 1280px;
    margin: 0 auto;
    padding: 8px 0 24px;
}
.mermaid-editor__header { text-align: center; margin: 0 0 24px; }
.mermaid-editor__title {
    font-size: clamp(22px, 2.4vw, 28px);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 6px;
}
.mermaid-editor__sub {
    font-size: 14.5px;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.55;
}

.mermaid-editor__panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.mermaid-editor__pane {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    display: flex;
    flex-direction: column;
    min-height: 420px;
    overflow: hidden; /* clip terminal corners against the rounded card */
}
.mermaid-editor__pane-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 14px 18px 10px;
    margin: 0;
    border-bottom: 1px solid var(--border-color);
}
/* Terminal look for the code pane — black background, white text,
 * editorial contrast against the warm page. Same treatment in light
 * and dark site themes; an editor "screen" inside the app like iTerm2. */
.mermaid-editor__pane--code {
    background: #0d0d0d;
    border-color: #0d0d0d;
}
.mermaid-editor__pane--code .mermaid-editor__pane-label {
    background: #1a1a1a;
    color: rgba(248, 248, 242, 0.65);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
.mermaid-editor__textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    background: #0d0d0d;
    color: #f8f8f2;
    caret-color: #f8f8f2;
    padding: 14px 18px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13.5px;
    line-height: 1.55;
    tab-size: 4;
    -moz-tab-size: 4;
}
.mermaid-editor__textarea::placeholder { color: rgba(248, 248, 242, 0.35); }
.mermaid-editor__textarea::selection { background: rgba(255, 107, 53, 0.35); }
.mermaid-editor__output {
    flex: 1;
    padding: 18px;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
}
.mermaid-editor__output svg { max-width: 100%; height: auto; }
.mermaid-editor__status {
    padding: 8px 18px;
    border-top: 1px solid var(--border-color);
    font-size: 12.5px;
    color: var(--text-secondary);
    min-height: 1.5em;
}
.mermaid-editor__status--error { color: var(--error-color); }
.mermaid-editor__error {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--error-color);
    white-space: pre-wrap;
    margin: 0;
    padding: 12px 14px;
    background: rgba(231, 76, 60, 0.06);
    border-left: 3px solid var(--error-color);
    border-radius: 6px;
    max-width: 100%;
    overflow: auto;
}

.mermaid-editor__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.mermaid-editor__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
.mermaid-editor__btn:hover:not(:disabled) { border-color: var(--primary-color); }
.mermaid-editor__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mermaid-editor__btn.busy { cursor: progress; }
.mermaid-editor__btn.btn--primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255,107,53,0.18), 0 4px 12px rgba(255,107,53,0.18);
}
.mermaid-editor__btn.btn--primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.mermaid-editor__btn .icon { width: 16px; height: 16px; }

.mermaid-editor__auto {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-left: auto;
    user-select: none;
}
.mermaid-editor__auto input { width: 16px; height: 16px; accent-color: var(--primary-color); }

.mermaid-editor__templates { margin-top: 4px; }
.mermaid-editor__template-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.mermaid-editor__template-btn {
    padding: 8px 14px;
    height: auto;
    min-height: 36px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.mermaid-editor__template-btn:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
    background: rgba(255, 107, 53, 0.04);
}

@media (max-width: 768px) {
    .mermaid-editor__panes {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .mermaid-editor__pane { min-height: 320px; }
    .mermaid-editor__auto { margin-left: 0; width: 100%; }
}