/* pdfcpu2 webui — quiet, local-first document workspace. No external assets. */
:root {
    color-scheme: light;
    --bg: #f4f5f2;
    --surface: #ffffff;
    --surface-subtle: #f8f9f7;
    --surface-hover: #f0f4f1;
    --sidebar: #fafbf9;
    --text: #202724;
    --text-soft: #69736e;
    --text-faint: #929b96;
    --line: #e1e5e1;
    --line-strong: #cbd2cd;
    --accent: #187764;
    --accent-hover: #116451;
    --accent-soft: #e8f3ef;
    --accent-faint: #f3f8f6;
    --danger: #bd4b46;
    --danger-soft: #fdf0ef;
    --warning: #a56b1c;
    --warning-soft: #fff7e8;
    --success: #187764;
    --shadow: 0 1px 2px rgba(25, 37, 31, .03), 0 8px 28px rgba(25, 37, 31, .035);
    --shadow-float: 0 16px 48px rgba(18, 28, 23, .16);
    --radius: 14px;
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #151917;
    --surface: #1c211e;
    --surface-subtle: #202622;
    --surface-hover: #29322d;
    --sidebar: #181d1a;
    --text: #e9eeeb;
    --text-soft: #a0aca5;
    --text-faint: #727e77;
    --line: #303832;
    --line-strong: #434e47;
    --accent: #55b79d;
    --accent-hover: #70c7af;
    --accent-soft: #233b32;
    --accent-faint: #1e2d27;
    --danger: #ee8b84;
    --danger-soft: #392523;
    --warning: #dbac65;
    --warning-soft: #342d20;
    --success: #65c2a8;
    --shadow: none;
    --shadow-float: 0 18px 54px rgba(0, 0, 0, .42);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    min-height: 100%;
}

html {
    background: var(--bg);
}

body {
    font: 14px/1.5 var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
    font: inherit;
}

button {
    color: inherit;
}

button, a, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
}

svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.svg-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Top navigation */
.topbar {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-left, .top-actions, .brand {
    display: flex;
    align-items: center;
}

.topbar-left {
    gap: 18px;
    min-width: 0;
}

.brand {
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
}

.brand-mark svg {
    width: 21px;
    height: 21px;
}

.brand-word {
    font-size: 20px;
    font-weight: 720;
    letter-spacing: -.6px;
}

.brand-word span {
    color: var(--accent);
}

.topbar-divider {
    width: 1px;
    height: 22px;
    background: var(--line);
}

.product-label {
    font-size: 13px;
    color: var(--text-soft);
}

.top-actions {
    gap: 8px;
}

.github-star-button {
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-subtle);
    color: var(--text-soft);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: color .15s, border-color .15s, background .15s;
}

.github-star-button:hover {
    color: var(--text);
    border-color: var(--line-strong);
    background: var(--surface-hover);
}

.github-star-button svg {
    width: 15px;
    height: 15px;
}

.github-star-button .star-icon {
    width: 13px;
    height: 13px;
    color: #b57a18;
}

.github-icon {
    fill: currentColor;
    stroke: none;
}

.local-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    font-size: 12px;
    margin-right: 10px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.icon-button {
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    color: var(--text-soft);
    transition: background .15s, color .15s, border-color .15s;
}

.icon-button:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

.icon-button.subtle {
    border-color: var(--line);
    width: 32px;
    height: 32px;
}

.language-select {
    height: 34px;
    border: 0;
    background: transparent;
    color: var(--text-soft);
    padding: 0 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.mobile-nav-toggle {
    display: none;
}

/* Shell + tool navigation */
.app-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    max-width: 1600px;
    margin: 0 auto;
    min-height: calc(100vh - 64px);
}

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    padding: 24px 14px 18px;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.sidebar-heading {
    padding: 0 12px 12px;
    font-size: 10px;
    font-weight: 750;
    color: var(--text-faint);
    letter-spacing: .13em;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    padding-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.nav-group {
    margin-top: 19px;
    padding: 0 12px 6px;
    color: var(--text-faint);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.nav-group:first-child {
    margin-top: 2px;
}

.nav-item {
    appearance: none;
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 38px;
    padding: 8px 11px;
    border-radius: 8px;
    color: var(--text-soft);
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    transition: background .14s, color .14s;
    position: relative;
}

.nav-item:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.nav-item.active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 650;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.nav-item svg {
    width: 17px;
    height: 17px;
    stroke-width: 1.8;
}

.nav-item .nav-label {
    flex: 1;
}

/* Scrollbars — slim, rounded and theme-aware instead of the chunky OS default.
   Firefox: scrollbar-width/scrollbar-color set per container.
   Chromium & Safari: the pseudo-elements below. */
.nav::-webkit-scrollbar,
.thumb-strip::-webkit-scrollbar,
pre.report::-webkit-scrollbar,
textarea.text-out::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.nav::-webkit-scrollbar-track,
.thumb-strip::-webkit-scrollbar-track,
pre.report::-webkit-scrollbar-track,
textarea.text-out::-webkit-scrollbar-track {
    background: transparent;
}

.nav::-webkit-scrollbar-thumb,
.thumb-strip::-webkit-scrollbar-thumb,
pre.report::-webkit-scrollbar-thumb,
textarea.text-out::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.nav::-webkit-scrollbar-thumb:hover,
.thumb-strip::-webkit-scrollbar-thumb:hover,
pre.report::-webkit-scrollbar-thumb:hover,
textarea.text-out::-webkit-scrollbar-thumb:hover {
    background: var(--text-faint);
    background-clip: padding-box;
}

.thumb-strip, pre.report, textarea.text-out {
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}


.sidebar-foot {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding: 16px 10px 0;
}

.engine-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.engine-dot {
    width: 7px;
    height: 7px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--warning);
    flex: 0 0 auto;
}

.engine-dot.ok {
    background: var(--success);
}

.engine-dot.err {
    background: var(--danger);
}

.engine-status {
    font-size: 11px;
    color: var(--text-soft);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.engine-status.load {
    color: var(--warning);
}

.engine-status.ok {
    color: var(--success);
}

.engine-status.err {
    color: var(--danger);
}

.sidebar-foot p {
    color: var(--text-faint);
    font-size: 10px;
    line-height: 1.5;
    margin: 8px 0 0 15px;
}

/* Workspace */
.workspace {
    min-width: 0;
    padding: 36px clamp(22px, 3vw, 48px) 20px;
}

.workspace-intro {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 28px;
}

.eyebrow, .section-kicker {
    font-size: 10px;
    font-weight: 750;
    color: var(--accent);
    letter-spacing: .12em;
    margin: 0 0 7px;
}

.workspace-intro h1 {
    font-size: clamp(25px, 2.4vw, 34px);
    line-height: 1.18;
    letter-spacing: -.035em;
    margin: 0;
    font-weight: 680;
}

.workspace-intro > div > p:last-child {
    color: var(--text-soft);
    margin: 9px 0 0;
    font-size: 13px;
}

.wasm-badge {
    border: 1px solid var(--line);
    background: var(--surface-subtle);
    color: var(--text-faint);
    padding: 5px 9px;
    border-radius: 6px;
    font: 10px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
    margin-top: 22px;
}

.workbench {
    display: grid;
    grid-template-columns: minmax(320px, .82fr) minmax(440px, 1.18fr);
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}

.files-panel {
    padding: 20px;
}

.tool-panel {
    padding: 22px 24px 20px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-title-row {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.step-number {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 11px;
    color: var(--text-soft);
    font-weight: 700;
}

.panel-head h2 {
    font-size: 15px;
    letter-spacing: -.01em;
    margin: 0;
    font-weight: 680;
}

.panel-head p:not(.section-kicker) {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--text-faint);
}

.tool-panel-head {
    margin-bottom: 7px;
}

.tool-panel-head .section-kicker {
    margin: 0 0 2px;
    font-size: 9px;
}

.tool-panel-head h2 {
    font-size: 20px;
}

.tool-header-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
}

.tool-header-icon svg {
    width: 20px;
    height: 20px;
}

.tool-desc {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.6;
    margin: 0 0 18px 36px;
    max-width: 580px;
}

.file-head-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px;
}

.text-button:hover {
    text-decoration: underline;
}

/* File intake */
.dropzone {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    background: var(--surface-subtle);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.dropzone:hover, .dropzone.drag {
    border-color: var(--accent);
    background: var(--accent-faint);
}

.dropzone-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--accent);
}

.dropzone-icon svg {
    width: 17px;
    height: 17px;
}

.dropzone strong {
    display: block;
    font-size: 12px;
    font-weight: 650;
}

.dropzone div > span {
    display: block;
    color: var(--text-faint);
    font-size: 10px;
    margin-top: 2px;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.file-grid:empty {
    display: none;
}

.empty {
    color: var(--text-soft);
    font-size: 12px;
    padding: 22px 6px 6px;
    text-align: center;
}

.file-grid > .empty {
    grid-column: 1 / -1;
}

.file-card {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
    cursor: pointer;
    min-width: 0;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

.file-card:hover {
    border-color: var(--line-strong);
    box-shadow: 0 3px 12px rgba(20, 35, 27, .06);
    transform: translateY(-1px);
}

.file-card.selected, .file-card.checked {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.file-card.disabled {
    opacity: .46;
    cursor: not-allowed;
}

.file-card.disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--line);
}

.file-thumb {
    height: 116px;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--line);
}

.file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.file-thumb .file-placeholder {
    width: 38px;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--text-faint);
}

.file-placeholder svg {
    width: 35px;
    height: 35px;
    stroke-width: 1.25;
}

.file-thumb.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 25%, color-mix(in srgb, var(--surface) 70%, transparent) 50%, transparent 75%);
    animation: shimmer 1.5s infinite;
    transform: translateX(-100%);
}

@keyframes shimmer {
    to {
        transform: translateX(100%);
    }
}

.file-meta {
    padding: 9px 10px 10px;
}

.file-name {
    font-size: 11px;
    font-weight: 620;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 4px;
}

.file-sub {
    color: var(--text-faint);
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: 3px;
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
}

.file-sub .lock, .file-sub .probe-error {
    color: var(--warning);
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-type-icon {
    width: 10px;
    height: 10px;
}

.file-del {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    color: var(--text-soft);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, color .15s, background .15s;
    z-index: 2;
}

.file-card:hover .file-del, .file-del:focus-visible {
    opacity: 1;
}

.file-del:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.file-del svg {
    width: 13px;
    height: 13px;
}

.selection-check {
    position: absolute;
    top: 7px;
    left: 7px;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: transparent;
    z-index: 1;
}

.selection-check svg {
    width: 13px;
    height: 13px;
    stroke-width: 2.5;
}

.selected .selection-check, .checked .selection-check {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.file-order {
    position: absolute;
    left: 7px;
    bottom: 52px;
    min-width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

.result-badge {
    display: inline-flex;
    margin-left: 5px;
    color: var(--accent);
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
}

/* Selected files, order queue and dedicated attachment picker */
.tool-target {
    margin: 0 0 20px;
}

.target-empty {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px;
    border: 1px dashed var(--line-strong);
    background: var(--surface-subtle);
    border-radius: 9px;
    color: var(--text-soft);
    font-size: 11px;
}

.target-empty svg {
    width: 16px;
    height: 16px;
    color: var(--text-faint);
}

.target-file {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--accent-faint);
    border-radius: 9px;
}

.target-file-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 38px;
    color: var(--accent);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.target-file-icon svg {
    width: 19px;
    height: 19px;
}

.target-file-info {
    min-width: 0;
    flex: 1;
}

.target-file-info b {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    font-weight: 620;
}

.target-file-info span {
    display: block;
    color: var(--text-faint);
    font-size: 10px;
    margin-top: 2px;
}

.target-change {
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 10px;
    padding: 5px 0 5px 8px;
}

.order-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
}

.order-head span {
    color: var(--text-soft);
    font-size: 10px;
}

.order-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.order-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 0;
}

.order-item.dragging {
    opacity: .45;
}

.order-item.drag-over {
    border-color: var(--accent);
}

.drag-handle {
    color: var(--text-faint);
    cursor: grab;
    display: grid;
    place-items: center;
}

.drag-handle svg {
    width: 15px;
    height: 15px;
    stroke-width: 3;
}

.order-number {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 9px;
    font-weight: 700;
    flex: 0 0 auto;
}

.order-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

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

.order-actions button {
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    display: grid;
    place-items: center;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: 5px;
}

.order-actions button:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.order-actions button:disabled {
    opacity: .25;
}

.order-actions svg {
    width: 13px;
    height: 13px;
}

.seams-button {
    margin-top: 9px;
}

.attachment-intake {
    border: 1px dashed var(--line-strong);
    border-radius: 9px;
    padding: 12px;
    background: var(--surface-subtle);
    margin-top: 8px;
}

.attachment-intake.drag {
    border-color: var(--accent);
    background: var(--accent-faint);
}

.attachment-intake-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.attachment-intake-head strong {
    font-size: 11px;
}

.attachment-intake p {
    margin: 4px 0 0;
    color: var(--text-faint);
    font-size: 10px;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 9px;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 4px 7px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 10px;
}

.attachment-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip button {
    border: 0;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    padding: 0;
    display: grid;
}

.attachment-chip svg {
    width: 11px;
    height: 11px;
}

.thumb-strip {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.seam {
    min-width: 130px;
}

.seam-page img {
    width: 130px;
    max-height: 180px;
    object-fit: contain;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.seam .cap {
    color: var(--text-soft);
    font-size: 9px;
    margin-top: 4px;
}

/* Forms */
.tool-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.tool-form:empty {
    display: none;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field > label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-soft);
}

.field .req::after {
    content: " *";
    color: var(--danger);
}

.field input[type="text"], .field input[type="password"], .field input[type="number"], .field select, .field textarea, .control {
    width: 100%;
    height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    padding: 8px 10px;
    outline: none;
    font-size: 12px;
    transition: border-color .15s, box-shadow .15s;
}

.field input:hover, .field select:hover, .control:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
}

.field input:focus, .field select:focus, .field textarea:focus, .control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.field input::placeholder {
    color: var(--text-faint);
}

.field .hint {
    color: var(--text-faint);
    font-size: 9px;
    line-height: 1.45;
}

.field.wide, .wide, .tool-form .note, .advanced-options {
    grid-column: 1 / -1;
}

.field.inline {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    padding: 8px 0;
}

.field.inline > label {
    color: var(--text);
    font-size: 11px;
    font-weight: 500;
    order: 0;
}

.field.inline input[type="checkbox"], .switch-row input[type="checkbox"] {
    appearance: none;
    width: 34px;
    height: 19px;
    border-radius: 20px;
    border: 1px solid var(--line-strong);
    background: var(--line);
    position: relative;
    cursor: pointer;
    margin: 0;
    flex: 0 0 auto;
    transition: background .15s, border-color .15s;
    order: 1;
}

.field.inline input[type="checkbox"]::after, .switch-row input[type="checkbox"]::after {
    content: "";
    position: absolute;
    width: 13px;
    height: 13px;
    top: 2px;
    left: 2px;
    background: var(--surface);
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
    transition: transform .15s;
}

.field.inline input[type="checkbox"]:checked, .switch-row input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.field.inline input[type="checkbox"]:checked::after, .switch-row input[type="checkbox"]:checked::after {
    transform: translateX(15px);
}

.field input[type="color"] {
    width: 100%;
    height: 38px;
    padding: 4px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
}

.tool-form .note {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    color: var(--text-soft);
    background: var(--surface-subtle);
    border-radius: 8px;
    padding: 10px 11px;
    font-size: 10px;
    line-height: 1.55;
    margin: 0;
}

.tool-form .note svg {
    width: 14px;
    height: 14px;
    margin-top: 1px;
}

.advanced-options {
    border-top: 1px solid var(--line);
    padding-top: 2px;
    margin-top: 1px;
}

.advanced-options summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 0;
}

.advanced-options summary::-webkit-details-marker {
    display: none;
}

.advanced-options summary::after {
    content: "+";
    font-size: 17px;
    font-weight: 400;
    color: var(--text-faint);
}

.advanced-options[open] summary::after {
    content: "−";
}

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 5px 0 3px;
}

.image-file-control {
    display: flex;
    gap: 6px;
}

.image-file-control select {
    min-width: 0;
    flex: 1;
}

.image-file-control .icon-button {
    border: 1px solid var(--line-strong);
    height: 38px;
    width: 38px;
    border-radius: 8px;
    flex: 0 0 auto;
}

/* Run + progress */
.tool-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
    margin-top: 20px;
}

.run-hint {
    color: var(--text-faint);
    font-size: 10px;
}

.primary, .secondary-button {
    min-height: 38px;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
}

.primary {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
}

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

.primary:active:not(:disabled) {
    transform: translateY(1px);
}

.primary:disabled {
    opacity: .45;
}

.run-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-width: 150px;
}

.run-button svg {
    width: 15px;
    height: 15px;
}

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

.secondary-button:hover {
    background: var(--surface-hover);
}

.busy {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-soft);
    background: var(--accent-faint);
    padding: 10px 12px;
    border-radius: 8px;
    margin-top: 14px;
    font-size: 11px;
}

.busy > span:last-child {
    margin-left: auto;
    color: var(--text-faint);
    font-size: 9px;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Results */
.result {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.result-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.result-status-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--success);
}

.result-status-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
}

.result-head.err .result-status-icon {
    background: var(--danger-soft);
    color: var(--danger);
}

.result-title {
    font-size: 12px;
    font-weight: 700;
}

.result-sub {
    display: block;
    color: var(--text-soft);
    font-size: 11px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.result-actions {
    margin-left: auto;
    display: flex;
    gap: 7px;
}

.result-actions a, .result-actions button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--accent);
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    font-size: 10px;
    font-weight: 650;
    cursor: pointer;
}

.result-actions a.ghost, .result-actions button.ghost {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line-strong);
}

.result-actions svg {
    width: 13px;
    height: 13px;
}

.result-head.err {
    padding: 12px;
    background: var(--danger-soft);
    border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--line));
    border-radius: 9px;
}

.kv {
    margin: 13px 0 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    font-size: 10px;
}

.kv dt {
    color: var(--text-faint);
}

.kv dd {
    margin: 0;
    overflow-wrap: anywhere;
}

pre.report, textarea.text-out {
    width: 100%;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-subtle);
    color: var(--text);
    padding: 12px;
    font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
    white-space: pre-wrap;
    overflow: auto;
}

pre.report {
    max-height: 340px;
}

textarea.text-out {
    min-height: 220px;
    resize: vertical;
}

table.list {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 11px;
}

table.list th, table.list td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 8px 6px;
}

table.list th {
    color: var(--text-faint);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

table.list td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.batch-status {
    margin-top: 12px;
}

.batch-status .item {
    display: flex;
    align-items: baseline;
    gap: 7px;
    font-size: 10px;
    padding: 4px 0;
}

.batch-status .ok {
    color: var(--success);
}

.batch-status .fail {
    color: var(--danger);
}

.result .thumb-strip img {
    max-width: 180px;
    max-height: 220px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-subtle);
}

/* Dialog + notifications */
dialog.dialog {
    width: min(460px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 15px;
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-float);
}

dialog.dialog::backdrop {
    background: rgba(17, 25, 21, .45);
    backdrop-filter: blur(3px);
}

.star-dialog {
    width: min(420px, calc(100vw - 32px)) !important;
    text-align: center;
}

.star-dialog-form {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.star-dialog-close {
    position: absolute;
    right: -12px;
    top: -12px;
}

.star-dialog-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    color: var(--text);
    margin: 4px 0 20px;
}

.star-dialog-icon svg {
    width: 36px;
    height: 36px;
}

.star-dialog .eyebrow {
    margin-bottom: 7px;
}

.star-dialog h2 {
    margin: 0;
    font-size: 25px;
    line-height: 1.25;
    letter-spacing: -.03em;
}

.star-dialog h2 + p {
    max-width: 330px;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 1.7;
    margin: 12px 0 21px;
}

.star-dialog-link {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #fff;
    text-decoration: none;
}

.star-dialog-link > svg:first-child {
    width: 16px;
    height: 16px;
}

.star-dialog-link .star-link-arrow {
    width: 14px;
    height: 14px;
    margin-left: auto;
}

.star-dialog-link > span {
    margin-right: auto;
}

.star-later {
    border: 0;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    font-size: 11px;
    padding: 12px 14px 7px;
}

.star-later:hover {
    color: var(--text);
}

.star-note {
    color: var(--text-faint);
    border-top: 1px solid var(--line);
    width: 100%;
    margin-top: 10px;
    padding-top: 14px;
    font-size: 9px;
}

.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
}

.dialog-head h3 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -.02em;
}

.prefs-grid {
    display: grid;
    gap: 15px;
}

.prefs-grid > label:not(.switch-row) {
    display: grid;
    grid-template-columns: 1fr 150px;
    align-items: center;
    gap: 16px;
    color: var(--text-soft);
    font-size: 12px;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
    padding-top: 15px;
}

.switch-row strong {
    display: block;
    font-size: 12px;
    font-weight: 550;
}

.switch-row small {
    display: block;
    color: var(--text-faint);
    font-size: 10px;
    margin-top: 2px;
}

.prefs-note {
    display: flex;
    gap: 8px;
    color: var(--text-faint);
    background: var(--surface-subtle);
    padding: 10px;
    border-radius: 8px;
    font-size: 10px;
    line-height: 1.5;
    margin: 20px 0 0;
}

.prefs-note svg {
    width: 14px;
    height: 14px;
    margin-top: 1px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.toast-region {
    position: fixed;
    right: 22px;
    bottom: 22px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    z-index: 100;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: min(390px, calc(100vw - 32px));
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-float);
    font-size: 12px;
    animation: toast-in .18s ease-out;
}

.toast.error {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.toast svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.toast.error svg {
    color: var(--danger);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.workspace-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    color: var(--text-faint);
    font-size: 10px;
    padding: 22px 2px 0;
}

.workspace-footer span:first-child {
    font-weight: 650;
}

@media (max-width: 1180px) {
    .workbench {
        grid-template-columns: minmax(290px, .8fr) minmax(390px, 1.2fr);
    }

    .workspace {
        padding-inline: 24px;
    }

    .file-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 940px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .mobile-nav-toggle {
        display: inline-grid;
    }

    .topbar {
        padding-inline: 14px;
    }

    .topbar-left {
        gap: 10px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 64px;
        bottom: 0;
        width: 248px;
        transform: translateX(-100%);
        transition: transform .2s;
        box-shadow: var(--shadow-float);
    }

    body.nav-open .sidebar {
        transform: translateX(0);
    }

    .nav-backdrop {
        position: fixed;
        inset: 64px 0 0;
        background: rgba(15, 23, 19, .38);
        z-index: 25;
    }

    body.nav-open .nav-backdrop {
        display: block;
    }

    .workbench {
        grid-template-columns: minmax(270px, .8fr) minmax(370px, 1.2fr);
    }
}

@media (max-width: 760px) {
    .product-label, .topbar-divider, .local-badge, .wasm-badge {
        display: none;
    }

    .github-star-button span {
        display: none;
    }

    .github-star-button {
        padding-inline: 9px;
    }

    .workspace {
        padding: 24px 16px 16px;
    }

    .workspace-intro {
        margin-bottom: 22px;
    }

    .workspace-intro h1 {
        font-size: 27px;
    }

    .workbench {
        grid-template-columns: 1fr;
    }

    .file-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tool-panel {
        padding: 20px;
    }

    .workspace-footer {
        flex-direction: column;
        gap: 3px;
    }
}

@media (max-width: 430px) {
    .brand-word {
        font-size: 18px;
    }

    .top-actions {
        gap: 1px;
    }

    .file-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .files-panel {
        padding: 16px;
    }

    .file-thumb {
        height: 105px;
    }

    .tool-form, .advanced-grid {
        grid-template-columns: 1fr;
    }

    .field.wide, .wide, .tool-form .note, .advanced-options {
        grid-column: 1;
    }

    .tool-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .run-button {
        width: 100%;
    }

    .run-hint {
        text-align: center;
    }

    .result-actions {
        margin-left: 0;
        width: 100%;
    }

    .prefs-grid > label:not(.switch-row) {
        grid-template-columns: 1fr 125px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
