/* ============ Ark Image Tracer — upload a picture, get real SVG shapes ============ */

:root {
    --accent: #4f46e5;
    --accent-soft: #eef2ff;
    --bg: #f4f6fa;
    --chrome: #ffffff;
    --border: #dde3ec;
    --text: #1f2937;
    --muted: #6b7280;
    --danger: #dc2626;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
    --radius: 8px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
}

#itr-app {
    display: grid;
    grid-template-rows: 48px 1fr 28px;
    height: 100vh;
}

/* ---------- Top bar ---------- */

#itr-topbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    background: var(--chrome);
    border-bottom: 1px solid var(--border);
    z-index: 20;
    overflow-x: auto;
    scrollbar-width: none;
}
#itr-topbar::-webkit-scrollbar { display: none; }

.it-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: var(--accent);
    padding-right: 12px;
    white-space: nowrap;
}
.it-brand-mark {
    width: 22px;
    height: 22px;
    stroke: var(--accent);
    stroke-width: 2;
    fill: var(--accent-soft);
}
.it-brand-logo {
    width: auto;
    height: 30px;
    max-width: 150px;
    object-fit: contain;
    flex: none;
}

.it-group { display: flex; align-items: center; gap: 2px; }
.it-sep { width: 1px; height: 24px; background: var(--border); margin: 0 6px; flex: none; }
.it-spacer { flex: 1; }

.it-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex: none;
}
.it-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}
.it-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: #c7d2fe; }
.it-btn:disabled { opacity: .4; cursor: default; }
.it-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: #c7d2fe; color: var(--accent); }
.it-btn-label span { font-size: 13px; }
.it-zoom-label { font-variant-numeric: tabular-nums; min-width: 54px; }

.it-nav-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    padding: 0 8px;
}
.it-nav-link:hover { text-decoration: underline; }

/* ---------- Segmented controls ---------- */

.it-fmt {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    flex: none;
}
.it-fmt.it-fmt-wrap { flex-wrap: wrap; border-radius: 6px; }
.it-fmt button {
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--chrome);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    padding: 6px 10px;
    cursor: pointer;
    flex: 1 1 auto;
    white-space: nowrap;
}
.it-fmt button:last-child { border-right: 0; }
.it-fmt button:hover { background: var(--accent-soft); }
.it-fmt button.active { background: var(--accent); color: #fff; }

/* ---------- Stage ---------- */

#itr-main {
    display: grid;
    grid-template-columns: 1fr 300px;
    min-height: 0;
}

#itr-stage {
    position: relative;
    overflow: auto;
    background:
        linear-gradient(45deg, #eceff5 25%, transparent 25%, transparent 75%, #eceff5 75%),
        linear-gradient(45deg, #eceff5 25%, transparent 25%, transparent 75%, #eceff5 75%),
        var(--bg);
    background-size: 18px 18px;
    background-position: 0 0, 9px 9px;
}
#itr-stage.it-dragover { outline: 2px dashed var(--accent); outline-offset: -8px; }

#itr-content {
    position: relative;
    margin: 24px auto;
    box-shadow: var(--shadow);
    background: #fff;
    display: none;
}
body.itr-loaded #itr-content { display: block; }

/* Both panes fill the stack exactly, so Split only has to clip the top one. */
.itr-pane { position: absolute; inset: 0; overflow: hidden; }
.itr-pane img, .itr-pane svg { display: block; width: 100%; height: 100%; }
#itr-pane-image { z-index: 2; }

body.itr-view-image #itr-pane-svg { visibility: hidden; }
body.itr-view-svg #itr-pane-image { visibility: hidden; }

#itr-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
    cursor: ew-resize;
    z-index: 5;
}
.it-divider-grip {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 44px;
    margin: -22px 0 0 -11px;
    border-radius: 11px;
    background: var(--accent);
    box-shadow: var(--shadow);
}
.it-divider-grip::before,
.it-divider-grip::after {
    content: "";
    position: absolute;
    top: 15px;
    width: 2px;
    height: 14px;
    background: rgba(255, 255, 255, .85);
}
.it-divider-grip::before { left: 8px; }
.it-divider-grip::after { left: 12px; }

/* Outline mode draws every traced element's edge over its own fill. */
body.itr-outlines #itr-svg svg * {
    stroke: #e11d48 !important;
    stroke-width: .6px !important;
    vector-effect: non-scaling-stroke;
}

/* ---------- Dropzone ---------- */

#itr-dropzone {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
    cursor: pointer;
    text-align: center;
    padding: 24px;
}
body.itr-loaded #itr-dropzone { display: none; }
.it-drop-icon {
    width: 44px;
    height: 44px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.it-drop-title { margin: 4px 0 0; font-size: 16px; font-weight: 600; color: var(--text); }
.it-drop-sub { margin: 0; font-size: 12px; }

.it-primary {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    padding: 9px 18px;
    cursor: pointer;
}
.it-primary:hover { background: #4338ca; }

/* ---------- Progress ---------- */

#itr-busy {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(244, 246, 250, .55);
    backdrop-filter: blur(1px);
    z-index: 10;
}
.it-busy-card {
    background: var(--chrome);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    min-width: 220px;
    text-align: center;
}
.it-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--accent-soft);
    overflow: hidden;
}
.it-bar-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .12s linear;
}
.it-busy-card p { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Options panel ---------- */

#itr-panel {
    background: var(--chrome);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px;
}

.it-sec {
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 12px;
}
.it-sec:last-child { border-bottom: 0; }
.it-sec h3 {
    margin: 0 0 8px;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.it-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.it-row > label {
    flex: 0 0 74px;
    font-size: 13px;
    color: var(--muted);
}
.it-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.it-row input[type="number"] {
    width: 68px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}
.it-row select {
    flex: 1;
    min-width: 0;
    height: 30px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--chrome);
}
.it-val {
    flex: 0 0 auto;
    min-width: 46px;
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.it-check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    margin-bottom: 7px;
    cursor: pointer;
}
.it-check input { accent-color: var(--accent); }

.it-note {
    margin: 6px 0 0;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--muted);
}
.it-note code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    background: var(--accent-soft);
    border-radius: 3px;
    padding: 0 3px;
}

.it-actions { gap: 6px; margin-top: 10px; }
.it-actions .it-btn {
    flex: 1;
    border-color: var(--border);
}

.it-stats {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    font-size: 12.5px;
}
.it-stats dt { color: var(--muted); }
.it-stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Status bar ---------- */

#itr-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    background: var(--chrome);
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}
#itr-status.it-error { color: var(--danger); }
#itr-fileinfo { font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
    #itr-main { grid-template-columns: 1fr 260px; }
}
