/* My Tools page (app/templates/tools/index.html) */

.tl-hero {
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: var(--radius-xl, 20px);
    padding: 28px 32px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}
.tl-hero::after {
    content: '';
    position: absolute; right: -80px; top: -80px;
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(var(--t-500-rgb, 99, 102, 241), 0.14) 0%, transparent 70%);
    pointer-events: none;
}
.tl-hero-icon {
    width: 60px; height: 60px; border-radius: 16px; flex-shrink: 0;
    background: var(--primary-gradient); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 26px;
    box-shadow: 0 8px 20px rgba(var(--t-500-rgb, 99, 102, 241), 0.3);
}
.tl-hero-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-main); margin: 0 0 6px; }
.tl-hero-sub { font-size: 14px; color: var(--text-muted); margin: 0; max-width: 620px; line-height: 1.6; }

.tl-search { position: relative; width: 100%; max-width: 340px; z-index: 1; }
.tl-search i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.tl-search input { height: 48px; border-radius: 14px; padding-left: 44px; border: 1px solid var(--border); font-size: 14px; }
.tl-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--t-500-rgb, 99, 102, 241), 0.15); }

.tl-section-title { font-size: 16px; font-weight: 700; color: var(--text-main); margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.tl-section-title i { color: #f59e0b; }

.tl-note {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
    background: var(--t-50, #eef2ff); color: var(--text-main); font-size: 14px;
}
.tl-note i { color: var(--primary); font-size: 18px; }
.tl-note a { color: var(--primary-dark); font-weight: 600; }

.tl-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.tl-tab {
    flex-shrink: 0; border: 1px solid var(--border); background: #fff; color: var(--text-muted);
    font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 999px; transition: all .15s;
}
.tl-tab:hover { color: var(--primary-dark); border-color: var(--primary); }
.tl-tab.active { background: var(--primary-gradient); color: #fff; border-color: transparent; }

.tl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tl-card {
    display: flex; flex-direction: column; background: #fff; border: 1px solid #edf2f7; border-radius: 16px;
    padding: 20px; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tl-card[hidden] { display: none; }
.tl-card:hover { transform: translateY(-3px); border-color: rgba(var(--t-500-rgb, 99, 102, 241), 0.4); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.06); }
.tl-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tl-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.tl-icon {
    width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--t-50, #eef2ff); color: var(--primary); font-size: 21px;
}
.tl-uses { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.tl-title { font-size: 16px; font-weight: 700; color: var(--text-main); margin: 0 0 6px; }
.tl-desc { font-size: 13px; color: var(--text-muted); line-height: 1.55; margin: 0 0 14px; flex: 1; }
.tl-open { margin-top: auto; font-size: 13px; font-weight: 700; color: var(--primary-dark); display: inline-flex; align-items: center; gap: 6px; }
.tl-card:hover .tl-open i { transform: translateX(3px); }
.tl-open i { transition: transform .15s; }

.tl-empty { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.tl-empty i { font-size: 36px; display: block; margin-bottom: 8px; }

@media (max-width: 575.98px) {
    .tl-hero { padding: 20px; }
    .tl-hero-title { font-size: 24px; }
    .tl-search { max-width: none; }
    .tl-grid { grid-template-columns: 1fr; }
}

/* Dark mode */
[data-bs-theme="dark"] .tl-hero,
[data-bs-theme="dark"] .tl-card,
[data-bs-theme="dark"] .tl-tab,
html.dark-theme .tl-hero,
html.dark-theme .tl-card,
html.dark-theme .tl-tab { background: var(--dark-2, #161b22); border-color: var(--dark-border, #30363d); }
[data-bs-theme="dark"] .tl-tab.active,
html.dark-theme .tl-tab.active { background: var(--primary-gradient); border-color: transparent; }
[data-bs-theme="dark"] .tl-icon,
[data-bs-theme="dark"] .tl-note,
html.dark-theme .tl-icon,
html.dark-theme .tl-note { background: rgba(var(--t-500-rgb, 99, 102, 241), 0.15); }
[data-bs-theme="dark"] .tl-open,
[data-bs-theme="dark"] .tl-note a,
html.dark-theme .tl-open,
html.dark-theme .tl-note a { color: var(--t-300, #a5b4fc); }

/* ---------- Tool pages (tools/_layout.html) ---------- */
.tl-hero-sm { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; padding: 22px 28px; }
.tl-hero-sm .tl-hero-title { font-size: 26px; }
.tl-private {
    position: relative; z-index: 1; font-size: 12px; font-weight: 600; color: #047857; background: #ecfdf5;
    border-radius: 999px; padding: 6px 12px; display: inline-flex; align-items: center; gap: 6px;
}

.tl-panel { background: #fff; border: 1px solid #edf2f7; border-radius: 16px; padding: 20px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.03); }
.tl-panel-title { font-size: 15px; font-weight: 700; color: var(--text-main); margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.tl-panel .form-label { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.tl-meta { font-size: 12.5px; color: var(--text-muted); }
.tl-meta a { color: var(--primary-dark); font-weight: 600; }

.tl-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
    min-height: 220px; border: 2px dashed rgba(var(--t-500-rgb, 99, 102, 241), 0.35); border-radius: 14px;
    background: var(--t-50, #eef2ff); cursor: pointer; padding: 24px; margin: 0; transition: background .15s, border-color .15s;
}
.tl-drop[hidden] { display: none; }
.tl-drop:hover, .tl-drop:focus-visible, .tl-drop.is-over { border-color: var(--primary); background: rgba(var(--t-500-rgb, 99, 102, 241), 0.12); outline: none; }
.tl-drop i { font-size: 38px; color: var(--primary); }
.tl-drop strong { font-size: 16px; color: var(--text-main); }
.tl-drop span { font-size: 13px; color: var(--text-muted); }

.tl-preview-wrap {
    display: flex; align-items: center; justify-content: center; min-height: 240px; padding: 16px; border-radius: 12px;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 20px 20px;
}
.tl-preview-wrap[hidden] { display: none; }
.tl-preview { max-width: 100%; max-height: 420px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15); background: #fff; }
.tl-preview-sign { max-height: 220px; }

.tl-btn-primary { background: var(--primary-gradient); color: #fff; font-weight: 700; border: 0; border-radius: 10px; padding: 10px 16px; }
.tl-btn-primary:hover, .tl-btn-primary:focus { color: #fff; filter: brightness(1.05); }
.tl-btn-primary:disabled { opacity: .55; color: #fff; }
.tl-btn-light { background: #f8fafc; color: var(--text-main); border: 1px solid var(--border); border-radius: 10px; font-weight: 600; }
.tl-btn-light:hover { background: var(--t-50, #eef2ff); color: var(--primary-dark); border-color: var(--primary); }

.tl-result { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.tl-result[hidden] { display: none; }
.tl-result-head { display: flex; gap: 14px; align-items: center; }
.tl-result-head img { width: 72px; height: 72px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.tl-result-size { font-size: 26px; font-weight: 800; color: var(--text-main); line-height: 1.2; }

.tl-status { font-size: 13px; padding: 10px 12px; border-radius: 10px; background: #f1f5f9; color: var(--text-main); margin-top: 12px; }
.tl-status[hidden] { display: none; }
.tl-status.is-ok { background: #ecfdf5; color: #047857; }
.tl-status.is-warn { background: #fff7ed; color: #b45309; }

.tl-files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.tl-files:empty { display: none; }
.tl-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.tl-file > i { font-size: 20px; color: var(--primary); }
.tl-file-num { font-size: 12px; font-weight: 700; color: var(--text-muted); min-width: 16px; }
.tl-file-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-file-name small { display: block; font-weight: 400; font-size: 12px; color: var(--text-muted); }

.tl-seg { display: flex; gap: 6px; padding: 4px; background: #f1f5f9; border-radius: 12px; }
.tl-seg label { flex: 1; margin: 0; position: relative; }
.tl-seg input { position: absolute; opacity: 0; pointer-events: none; }
.tl-seg span { display: block; text-align: center; font-size: 13px; font-weight: 600; padding: 8px 6px; border-radius: 9px; color: var(--text-muted); cursor: pointer; }
.tl-seg input:checked + span { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08); }
.tl-seg input:focus-visible + span { outline: 2px solid var(--primary); }

.tl-outputs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tl-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tl-thumbs > .tl-file { grid-column: 1 / -1; }
.tl-thumb { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: #fff; text-align: center; }
.tl-thumb img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #f8fafc; border-radius: 6px; }
.tl-thumb span { font-size: 12px; font-weight: 600; color: var(--primary-dark); }
.tl-thumb:hover { border-color: var(--primary); }

.tl-big-result { padding: 16px; border-radius: 12px; background: var(--t-50, #eef2ff); }
.tl-big-num { font-size: 30px; font-weight: 800; color: var(--text-main); line-height: 1.25; }
.tl-big-num small { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-right: 6px; }

.tl-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tl-stats div { padding: 12px; border-radius: 12px; background: var(--t-50, #eef2ff); }
.tl-stats strong { display: block; font-size: 22px; font-weight: 800; color: var(--text-main); }
.tl-stats span { font-size: 12px; color: var(--text-muted); }
.tl-textarea { border-radius: 12px; font-size: 15px; line-height: 1.6; resize: vertical; }

.tl-back { font-size: 14px; font-weight: 600; color: var(--primary-dark); text-decoration: none; }
.tl-back:hover { text-decoration: underline; }

@media (max-width: 575.98px) {
    .tl-hero-sm { padding: 18px; }
    .tl-hero-sm .tl-hero-title { font-size: 21px; }
    .tl-drop { min-height: 170px; }
}

/* Tool pages — dark mode */
[data-bs-theme="dark"] .tl-panel, [data-bs-theme="dark"] .tl-file, [data-bs-theme="dark"] .tl-thumb,
html.dark-theme .tl-panel, html.dark-theme .tl-file, html.dark-theme .tl-thumb { background: var(--dark-2, #161b22); border-color: var(--dark-border, #30363d); }
[data-bs-theme="dark"] .tl-drop, [data-bs-theme="dark"] .tl-big-result, [data-bs-theme="dark"] .tl-stats div,
html.dark-theme .tl-drop, html.dark-theme .tl-big-result, html.dark-theme .tl-stats div { background: rgba(var(--t-500-rgb, 99, 102, 241), 0.1); }
[data-bs-theme="dark"] .tl-preview-wrap, html.dark-theme .tl-preview-wrap { background: repeating-conic-gradient(#21262d 0% 25%, #161b22 0% 50%) 50% / 20px 20px; }
[data-bs-theme="dark"] .tl-btn-light, [data-bs-theme="dark"] .tl-seg, [data-bs-theme="dark"] .tl-status,
html.dark-theme .tl-btn-light, html.dark-theme .tl-seg, html.dark-theme .tl-status { background: var(--dark-3, #21262d); border-color: var(--dark-border, #30363d); color: var(--text-main); }
[data-bs-theme="dark"] .tl-seg input:checked + span, html.dark-theme .tl-seg input:checked + span { background: var(--dark-2, #161b22); color: var(--t-300, #a5b4fc); }
[data-bs-theme="dark"] .tl-status.is-ok, html.dark-theme .tl-status.is-ok { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
[data-bs-theme="dark"] .tl-status.is-warn, html.dark-theme .tl-status.is-warn { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
[data-bs-theme="dark"] .tl-private, html.dark-theme .tl-private { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
[data-bs-theme="dark"] .tl-thumb span, [data-bs-theme="dark"] .tl-back, [data-bs-theme="dark"] .tl-meta a,
html.dark-theme .tl-thumb span, html.dark-theme .tl-back, html.dark-theme .tl-meta a { color: var(--t-300, #a5b4fc); }

/* ---------- Markdown viewer (tools/markdown.html) ---------- */
.md-bar { padding: 12px 14px; }
.md-modes { padding: 3px; }
.md-modes span { padding: 6px 12px; white-space: nowrap; }
.md-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.md-wrap[data-mode="write"] { grid-template-columns: 1fr; }
.md-wrap[data-mode="write"] .md-view { display: none; }
.md-wrap[data-mode="read"] { grid-template-columns: 1fr; }
.md-wrap[data-mode="read"] .md-edit { display: none; }
.md-edit { padding: 0; overflow: hidden; position: sticky; top: 84px; }
.md-head { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-main); }
.md-src { display: block; width: 100%; height: calc(100vh - 220px); min-height: 420px; border: 0; resize: none; padding: 16px; outline: none;
    font: 13.5px/1.65 ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace; color: var(--text-main); background: transparent; tab-size: 4; }
.md-view { padding: 0; display: flex; align-items: flex-start; min-height: 420px; }
.md-wrap[data-mode="split"] .md-view { max-height: calc(100vh - 180px); overflow: auto; }
.md-wrap[data-mode="split"] .md-toc { display: none; }
.md-toc { flex: 0 0 230px; position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; padding: 24px 0 24px 20px; border-right: 1px solid var(--border); }
.md-toc[hidden] { display: none; }
.md-toc-title { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.md-toc a { display: block; font-size: 13px; color: var(--text-muted); text-decoration: none; padding: 4px 12px 4px 0; line-height: 1.4; }
.md-toc a:hover { color: var(--primary-dark); }
.md-toc a.lvl-2 { padding-left: 10px; }
.md-toc a.lvl-3 { padding-left: 22px; font-size: 12.5px; }

.md-body { flex: 1; min-width: 0; padding: 28px 36px 40px; font-size: 16px; line-height: 1.75; color: var(--text-main); word-wrap: break-word; }
.md-wrap[data-mode="read"] .md-body { max-width: 860px; margin: 0 auto; }
.md-body > :first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { font-weight: 700; line-height: 1.3; margin: 1.6em 0 .6em; scroll-margin-top: 90px; color: var(--text-main); }
.md-body h1 { font-size: 2em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 1.5em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.22em; }
.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body pre, .md-body .md-table { margin: 0 0 1em; }
.md-body ul, .md-body ol { padding-left: 1.6em; }
.md-body li + li { margin-top: .25em; }
.md-body li > input[type="checkbox"] { margin: 0 .5em 0 -1.4em; vertical-align: middle; }
.md-body li:has(> input[type="checkbox"]) { list-style: none; }
.md-body a { color: var(--primary-dark); text-decoration: underline; text-underline-offset: 2px; }
.md-body img { max-width: 100%; border-radius: 8px; }
.md-body hr { border: 0; border-top: 2px solid var(--border); margin: 2em 0; opacity: 1; }
.md-body blockquote { border-left: 4px solid var(--primary); background: var(--t-50, #eef2ff); padding: 10px 18px; border-radius: 0 10px 10px 0; color: var(--text-main); }
.md-body blockquote > :last-child { margin-bottom: 0; }
.md-body code { font: .88em ui-monospace, SFMono-Regular, Consolas, monospace; background: rgba(135, 131, 120, .15); color: #c7254e; padding: .15em .4em; border-radius: 5px; }
.md-body pre { position: relative; padding: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: #f6f8fa; }
.md-body pre code { display: block; padding: 16px 18px; overflow-x: auto; background: transparent; color: inherit; font-size: 13.5px; line-height: 1.6; border-radius: 0; }
.md-body pre code.hljs { background: transparent; }
.md-lang { position: absolute; top: 8px; right: 70px; font: 600 11px/1 system-ui, sans-serif; text-transform: uppercase; color: #94a3b8; padding: 5px 0; }
.md-copy { position: absolute; top: 6px; right: 8px; font-size: 12px; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: #475569; opacity: .85; }
.md-copy:hover { opacity: 1; color: var(--primary-dark); }
.md-table { overflow-x: auto; }
.md-body table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md-body th { background: var(--t-50, #eef2ff); font-weight: 700; }
.md-body tr:nth-child(even) td { background: rgba(148, 163, 184, .06); }
.md-empty { text-align: center; color: var(--text-muted); padding: 80px 16px; }
.md-empty i { font-size: 44px; display: block; margin-bottom: 8px; }
.md-dropmask { position: fixed; inset: 0; z-index: 2000; background: rgba(var(--t-500-rgb, 99, 102, 241), .18); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.md-dropmask[hidden] { display: none; }
.md-dropmask div { background: #fff; color: var(--primary-dark); font-weight: 700; padding: 20px 28px; border-radius: 14px; border: 2px dashed var(--primary); font-size: 17px; }

@media (max-width: 991.98px) {
    .md-wrap, .md-wrap[data-mode="split"] { grid-template-columns: 1fr; }
    .md-edit { position: static; }
    .md-src { height: 50vh; min-height: 260px; }
    .md-wrap[data-mode="split"] .md-view { max-height: none; }
    .md-toc { display: none !important; }
    .md-body { padding: 20px 18px 28px; font-size: 15.5px; }
}

[data-bs-theme="dark"] .md-body pre, html.dark-theme .md-body pre { background: #0d1117; }
[data-bs-theme="dark"] .md-body code, html.dark-theme .md-body code { color: #f9a8d4; }
[data-bs-theme="dark"] .md-body pre code, html.dark-theme .md-body pre code { color: #e6edf3; }
[data-bs-theme="dark"] .md-body blockquote, html.dark-theme .md-body blockquote,
[data-bs-theme="dark"] .md-body th, html.dark-theme .md-body th { background: rgba(var(--t-500-rgb, 99, 102, 241), .12); }
[data-bs-theme="dark"] .md-body a, html.dark-theme .md-body a { color: var(--t-300, #a5b4fc); }
[data-bs-theme="dark"] .md-copy, html.dark-theme .md-copy, [data-bs-theme="dark"] .md-dropmask div, html.dark-theme .md-dropmask div { background: #161b22; color: #c9d1d9; }

/* ============ Image Format Converter (image-converter.js) ============ */
.ic-formats { font-size: 11.5px !important; letter-spacing: .3px; opacity: .85; }
.ic-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ic-count { font-weight: 700; color: var(--text-main); margin-right: auto; }
.ic-viewer { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 14px; }
.ic-viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px; border-bottom: 1px solid var(--border); }
.ic-view-seg { min-width: 260px; }
.ic-zoom { display: flex; gap: 4px; }
.ic-stage { position: relative; height: 440px; min-height: 0; padding: 16px; border-radius: 0; overflow: auto; display: flex; }
.ic-stage.ic-bg-white { background: #fff; }
.ic-stage.ic-bg-dark { background: #0d1117; }
.ic-canvas { position: relative; margin: auto; flex-shrink: 0; box-shadow: 0 4px 18px rgba(0, 0, 0, .18); touch-action: none; }
.ic-canvas > img, .ic-canvas > canvas, .ic-out-layer, .ic-out-layer img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ic-canvas > img[hidden], .ic-canvas > canvas[hidden], .ic-out-layer[hidden], .ic-split[hidden] { display: none; }
.ic-out-layer:not(.is-split) { clip-path: none !important; }
.ic-stage.is-zoomed .ic-canvas img, .ic-stage.is-zoomed .ic-canvas canvas { image-rendering: pixelated; }
.ic-split { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); cursor: ew-resize; }
.ic-split span { position: absolute; top: 50%; left: -17px; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%; background: #fff; color: #334155;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); transform: rotate(90deg); font-size: 14px; }
.ic-busy { position: absolute; top: 10px; right: 10px; font-size: 12px; font-weight: 600; background: rgba(15, 23, 42, .78); color: #fff; padding: 4px 10px; border-radius: 999px; }
.ic-busy[hidden] { display: none; }
.ic-info { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; font-size: 12.5px; color: var(--text-muted); border-top: 1px solid var(--border); }
.ic-info:empty { display: none; }
.ic-info strong { color: var(--text-main); }
.ic-tag { display: inline-block; min-width: 72px; text-align: center; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 1px 8px; border-radius: 999px; background: #e2e8f0; color: #334155; }
.ic-tag.is-out { background: var(--t-100, #e0e7ff); color: var(--primary-dark); }
.is-down { color: #059669; }
.is-up { color: #d97706; }
.ic-err { color: #dc2626 !important; }

.ic-files { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.ic-file { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: #fff; min-width: 0; }
.ic-file.is-current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--t-500-rgb, 99, 102, 241), .2); }
.ic-thumb { flex-shrink: 0; width: 54px; height: 54px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; cursor: pointer;
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
.ic-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ic-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ic-file-name { font-size: 13.5px; font-weight: 600; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic-file-main small { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic-out { color: var(--text-main) !important; font-weight: 600; }

.ic-settings { position: sticky; top: 90px; }
.ic-formats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.ic-fmt { margin: 0; position: relative; }
.ic-fmt input { position: absolute; opacity: 0; pointer-events: none; }
.ic-fmt span { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.ic-fmt strong { font-size: 14px; color: var(--text-main); }
.ic-fmt small { font-size: 10.5px; color: var(--text-muted); line-height: 1.2; }
.ic-fmt span:hover { border-color: var(--primary); }
.ic-fmt input:checked + span { border-color: var(--primary); background: var(--t-50, #eef2ff); box-shadow: 0 0 0 1px var(--primary) inset; }
.ic-fmt input:checked + span strong { color: var(--primary-dark); }
.ic-fmt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.ic-fmt.is-off span { opacity: .45; cursor: not-allowed; }
.ic-sec { border: 1px solid var(--border); border-radius: 12px; margin-top: 10px; }
.ic-sec[hidden] { display: none; }
.ic-sec summary { padding: 10px 12px; font-size: 13.5px; font-weight: 700; color: var(--text-main); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.ic-sec summary::-webkit-details-marker { display: none; }
.ic-sec summary::after { content: "\F282"; font-family: "bootstrap-icons"; margin-left: auto; font-size: 12px; transition: transform .2s; }
.ic-sec[open] summary::after { transform: rotate(180deg); }
.ic-sec-body { padding: 0 12px 12px; }
.ic-sec-body [hidden] { display: none !important; }
.ic-presets { display: flex; flex-wrap: wrap; gap: 4px; }
.ic-presets .btn { font-size: 11.5px; padding: 2px 8px; }
.ic-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.tl-btn-light.is-on { background: var(--t-50, #eef2ff); border-color: var(--primary); color: var(--primary-dark); }
.ic-progress { height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.ic-progress[hidden] { display: none; }
.ic-progress span { display: block; height: 100%; width: 0; background: var(--primary-gradient); transition: width .2s; }

@media (max-width: 1199.98px) { .ic-settings { position: static; } }
@media (max-width: 575.98px) {
    .ic-stage { height: 320px; padding: 10px; }
    .ic-view-seg { min-width: 0; width: 100%; }
    .ic-files { grid-template-columns: minmax(0, 1fr); }
}

[data-bs-theme="dark"] .ic-file, html.dark-theme .ic-file { background: var(--dark-2, #161b22); border-color: var(--dark-border, #30363d); }
[data-bs-theme="dark"] .ic-viewer, [data-bs-theme="dark"] .ic-viewer-head, [data-bs-theme="dark"] .ic-info, [data-bs-theme="dark"] .ic-sec, [data-bs-theme="dark"] .ic-fmt span,
html.dark-theme .ic-viewer, html.dark-theme .ic-viewer-head, html.dark-theme .ic-info, html.dark-theme .ic-sec, html.dark-theme .ic-fmt span { border-color: var(--dark-border, #30363d); }
[data-bs-theme="dark"] .ic-fmt input:checked + span, html.dark-theme .ic-fmt input:checked + span,
[data-bs-theme="dark"] .tl-btn-light.is-on, html.dark-theme .tl-btn-light.is-on { background: rgba(var(--t-500-rgb, 99, 102, 241), .18); }
[data-bs-theme="dark"] .ic-fmt input:checked + span strong, html.dark-theme .ic-fmt input:checked + span strong { color: var(--t-300, #a5b4fc); }
[data-bs-theme="dark"] .ic-tag, html.dark-theme .ic-tag { background: #30363d; color: #e2e8f0; }
[data-bs-theme="dark"] .ic-tag.is-out, html.dark-theme .ic-tag.is-out { background: rgba(var(--t-500-rgb, 99, 102, 241), .25); color: var(--t-200, #c7d2fe); }
[data-bs-theme="dark"] .ic-progress, html.dark-theme .ic-progress { background: #30363d; }
[data-bs-theme="dark"] .ic-thumb, html.dark-theme .ic-thumb { background: repeating-conic-gradient(#30363d 0% 25%, #161b22 0% 50%) 50% / 12px 12px; }

/* ============ PDF to JPG (pdf-to-images.js) ============ */
.pj-file { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pj-file .tl-file { flex: 1; min-width: 220px; }
.pj-select { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.pj-select .form-control { max-width: 170px; }
.pj-select .pj-sel-count { margin-left: auto; font-weight: 600; color: var(--text-muted); }
.pj-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.pj-page { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 2px solid var(--border); border-radius: 12px; background: #fff; cursor: pointer; text-align: center; user-select: none; }
.pj-page:hover { border-color: rgba(var(--t-500-rgb, 99, 102, 241), .5); }
.pj-page.is-on { border-color: var(--primary); background: var(--t-50, #eef2ff); }
.pj-page canvas, .pj-page img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #f8fafc; border-radius: 6px; }
.pj-page .pj-check { position: absolute; top: 12px; left: 12px; width: 22px; height: 22px; border-radius: 6px; border: 2px solid #cbd5e1; background: #fff; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; }
.pj-page.is-on .pj-check { background: var(--primary); border-color: var(--primary); }
.pj-page-label { font-size: 12px; font-weight: 600; color: var(--text-main); }
.pj-page-out { font-size: 11.5px; color: var(--primary-dark); font-weight: 600; }
.pj-page .pj-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.pj-page:hover .pj-actions, .pj-page:focus-within .pj-actions { opacity: 1; }
.pj-actions button { width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(15, 23, 42, .75); color: #fff; font-size: 13px; }
.pj-lightbox { border: 0; border-radius: 16px; padding: 0; width: min(1100px, 96vw); max-height: 94vh; background: #0f172a; color: #fff; }
.pj-lightbox::backdrop { background: rgba(15, 23, 42, .7); }
.pj-lb-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #1e293b; }
.pj-lb-head strong { margin-right: auto; }
.pj-lb-head button { border: 0; background: #1e293b; color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.pj-lb-body { overflow: auto; max-height: calc(94vh - 56px); padding: 12px; text-align: center; background: repeating-conic-gradient(#1e293b 0% 25%, #0f172a 0% 50%) 50% / 20px 20px; }
.pj-lb-body img { max-width: 100%; height: auto; box-shadow: 0 4px 20px rgba(0, 0, 0, .4); }
.pj-lb-body.is-full img { max-width: none; }
.pj-estimate { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 0; }

[data-bs-theme="dark"] .pj-page, html.dark-theme .pj-page { background: var(--dark-2, #161b22); border-color: var(--dark-border, #30363d); }
[data-bs-theme="dark"] .pj-page.is-on, html.dark-theme .pj-page.is-on { background: rgba(var(--t-500-rgb, 99, 102, 241), .15); border-color: var(--primary); }
[data-bs-theme="dark"] .pj-page canvas, html.dark-theme .pj-page canvas { background: #0d1117; }
[data-bs-theme="dark"] .pj-page .pj-check, html.dark-theme .pj-page .pj-check { background: #0d1117; border-color: #475569; }
[data-bs-theme="dark"] .pj-page-out, html.dark-theme .pj-page-out { color: var(--t-300, #a5b4fc); }
