/* Shared tool UI */
.tool-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.img-threshold-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.img-threshold-group[hidden] {
    display: none;
}

.tool-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .tool-split {
        grid-template-columns: 1fr;
    }
}

.tool-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tool-textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 320px;
    padding: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-light);
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.tool-textarea-sm {
    min-height: 120px;
}

.tool-textarea:focus {
    outline: none;
    border-color: var(--border-accent-strong);
    box-shadow: 0 0 0 3px var(--tint-accent);
}

.tool-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
}

.tool-status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    min-height: 1.25rem;
}

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

.tool-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
}

.tool-flags {
    display: flex;
    gap: 0.75rem;
    padding-top: 0.35rem;
}

.tool-preview {
    min-height: 80px;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

.tool-preview .regex-match {
    background: var(--border-accent);
    border-radius: 2px;
    outline: 1px solid var(--outline-accent);
}

.tool-subheading {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem;
}

.tool-matches {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tool-match-card {
    padding: 0.65rem 0.85rem;
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.tool-match-card strong {
    color: var(--accent);
}

.regex-code-desc {
    margin: -0.35rem 0 0.85rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.regex-lang-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.regex-lang-tab {
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.regex-lang-tab:hover {
    color: var(--text-light);
    border-color: var(--border-accent-soft);
}

.regex-lang-tab.active {
    border-color: var(--border-accent-medium);
    color: var(--accent);
    background: var(--tint-accent-hover);
}

.regex-code-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.regex-code-toolbar .btn {
    flex-shrink: 0;
}

.tool-select-sm {
    width: auto;
    min-width: 10rem;
}

.tool-color-input {
    width: 48px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    background: var(--bg-dark);
    cursor: pointer;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.color-swatch {
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border-on-surface);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.color-swatch:hover {
    transform: scale(1.03);
}

.color-swatch-fill {
    height: 80px;
}

.color-swatch-info {
    padding: 0.5rem 0.65rem;
    background: var(--surface-pre);
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Command palette */
.palette-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-scrim);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
}

.palette-overlay.open {
    display: flex;
}

.palette-dialog {
    width: min(540px, 92vw);
    background: var(--bg-darker);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.palette-search-row {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    border-bottom: 1px solid var(--surface-border);
}

.palette-input {
    width: 100%;
    padding: 1rem 1.15rem;
    font-size: 1rem;
    font-family: inherit;
    border: none;
    background: var(--bg-dark);
    color: var(--text-light);
    outline: none;
    flex: 1;
    min-width: 0;
}

.palette-cancel {
    display: none;
    align-items: center;
    flex-shrink: 0;
    padding: 0 1rem;
    border: none;
    background: transparent;
    color: var(--accent);
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.palette-list {
    list-style: none;
    max-height: 340px;
    overflow-y: auto;
    margin: 0;
    padding: 0.4rem;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.875rem;
}

.palette-item:hover,
.palette-item.active {
    background: var(--tint-accent);
}

.palette-item i {
    color: var(--accent);
    width: 1.25rem;
    text-align: center;
}

.palette-section {
    list-style: none;
    padding: 0.65rem 1.15rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.palette-section:not(:first-child) {
    margin-top: 0.25rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--surface-border);
}

.palette-hint {
    padding: 0.6rem 1.15rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--surface-border);
}

@media (max-width: 768px) {
    .palette-hint {
        display: none;
    }

    .palette-overlay {
        padding: 0;
        padding-top: calc(var(--mobile-bar-height, 2.75rem) + env(safe-area-inset-top, 0px));
        align-items: stretch;
        justify-content: stretch;
    }

    .palette-overlay.open {
        display: flex;
        flex-direction: column;
    }

    .palette-dialog {
        flex: 1;
        width: 100%;
        max-height: none;
        margin: 0;
        border-radius: 1rem 1rem 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        min-height: 0;
    }

    .palette-cancel {
        display: inline-flex;
    }

    .palette-input {
        padding: 0.85rem 0.75rem 0.85rem 1rem;
    }

    .palette-list {
        flex: 1;
        max-height: none;
        min-height: 0;
        padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
        -webkit-overflow-scrolling: touch;
    }

    .palette-item {
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
    }
}

/* iOS PWA: fixed overlays need compositor layer + high z-index in standalone */
html.is-pwa body.palette-open {
    overflow: visible;
}

html.is-pwa .palette-overlay.open {
    z-index: 10000;
    display: flex !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.tool-results {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.tool-result-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-size: 0.85rem;
}

.tool-result-row span {
    color: var(--text-muted);
    flex-shrink: 0;
}

.tool-result-row code {
    word-break: break-all;
    text-align: right;
}

.tool-callout {
    padding: 0.75rem 1rem;
    background: var(--tint-accent-hover);
    border-left: 3px solid var(--primary-color);
    border-radius: 0.25rem;
    font-size: 0.9rem;
}

.tool-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.nl-help {
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.nl-help summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
}

.nl-help-body {
    margin-top: 0.75rem;
    color: var(--text-secondary);
}

.nl-help-body ul {
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
}

.nl-help-body code {
    font-size: 0.8125rem;
}

.tool-input-narrow {
    width: 5rem;
    min-height: 38px;
}

.uuid-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.uuid-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.85rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
}

.pw-output {
    padding: 1rem;
    min-height: 3rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    word-break: break-all;
    white-space: pre-wrap;
    line-height: 1.6;
}

.unit-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.unit-chip {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: var(--surface-hover-strong);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

/* Cron builder */
.cron-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cron-preset {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.cron-preset:hover {
    color: var(--text-light);
    border-color: var(--border-accent);
}

.cron-preset.is-active {
    color: var(--accent);
    background: var(--tint-accent);
    border-color: var(--border-accent-medium);
}

.cron-builder {
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.cron-expr-row {
    display: flex;
    gap: 0.5rem;
}

.cron-expr-row .form-control {
    flex: 1;
    min-width: 0;
}

.cron-weekdays {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.cron-dow {
    min-width: 2.75rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-raised);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.cron-dow:hover {
    color: var(--text-light);
    border-color: var(--border-accent);
}

.cron-dow.is-active {
    color: var(--accent);
    background: var(--tint-accent);
    border-color: var(--border-accent-medium);
}

.md-preview {
    min-height: 320px;
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    overflow-y: auto;
    line-height: 1.6;
}

.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4, .md-preview h5, .md-preview h6 {
    margin: 1rem 0 0.5rem;
    font-weight: 600;
}

.md-preview h1 { font-size: 1.5rem; }
.md-preview h2 { font-size: 1.25rem; }
.md-preview h3 { font-size: 1.1rem; }
.md-preview h4 { font-size: 1rem; }
.md-preview h5 { font-size: 0.9375rem; }
.md-preview h6 { font-size: 0.875rem; color: var(--text-muted); }

.md-preview p { margin: 0.5rem 0; }

.md-preview code {
    padding: 0.15rem 0.35rem;
    background: var(--surface-code);
    border-radius: 0.2rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85em;
}

.md-preview pre {
    padding: 0.75rem;
    background: var(--surface-pre);
    border-radius: 0.25rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.md-preview pre code {
    padding: 0;
    background: none;
}

.md-preview blockquote {
    margin: 0.75rem 0;
    padding-left: 1rem;
    border-left: 3px solid var(--primary-color);
    color: var(--text-muted);
}

.md-preview ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.md-preview ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.md-preview hr {
    margin: 1rem 0;
    border: none;
    border-top: 1px solid var(--surface-border);
}

.md-preview del {
    color: var(--text-muted);
    text-decoration: line-through;
}

.md-preview img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.md-preview .md-table {
    width: 100%;
    margin: 0.75rem 0;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.md-preview .md-table th,
.md-preview .md-table td {
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--surface-border);
}

.md-preview .md-table th {
    background: var(--surface-raised);
    font-weight: 600;
}

.md-preview .md-task-list {
    list-style: none;
    padding-left: 0;
}

.md-preview .md-task {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    margin: 0.25rem 0;
}

.md-preview .md-task input {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.md-preview .md-task.is-done {
    color: var(--text-muted);
    text-decoration: line-through;
}

.md-table-preview {
    min-height: 8rem;
}

.md-doc-meta {
    margin: -0.5rem 0 1rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    background: var(--tint-accent-subtle);
    border: 1px solid var(--tint-accent-medium);
    border-radius: 999px;
}

.md-diff-preview {
    min-height: 12rem;
}

.md-preview pre code.hljs {
    background: transparent;
    padding: 0;
}

.md-tabs {
    flex-wrap: wrap;
}

.md-title-input {
    width: 9rem;
    min-height: auto;
}

.md-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.md-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 5.5rem;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.md-stat span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.md-stat strong {
    font-size: 1.05rem;
    color: var(--text-light);
}

.md-plain-preview {
    white-space: pre-wrap;
    font-family: inherit;
    line-height: 1.65;
}

.md-heading-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.md-heading-item {
    margin: 0.35rem 0;
    font-size: 0.9375rem;
    color: var(--text-light);
}

.md-heading-item.md-heading-l1 { padding-left: 0; font-weight: 600; }
.md-heading-item.md-heading-l2 { padding-left: 0.75rem; }
.md-heading-item.md-heading-l3 { padding-left: 1.5rem; font-size: 0.875rem; }
.md-heading-item.md-heading-l4 { padding-left: 2.25rem; font-size: 0.875rem; color: var(--text-secondary); }
.md-heading-item.md-heading-l5,
.md-heading-item.md-heading-l6 { padding-left: 3rem; font-size: 0.8125rem; color: var(--text-muted); }

.md-heading-slug {
    display: inline-block;
    margin-right: 0.35rem;
    padding: 0.1rem 0.35rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--accent);
    background: var(--tint-accent-hover);
    border-radius: var(--radius-sm);
}

.md-code-wrap {
    position: relative;
    margin: 0.75rem 0;
}

.md-code-lang {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    pointer-events: none;
}

.md-code-wrap pre {
    margin: 0;
}

.md-footnotes {
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.md-footnotes ol {
    padding-left: 1.25rem;
}

.md-fn a {
    text-decoration: none;
    font-weight: 600;
}

.md-fn-back {
    font-size: 0.75rem;
    margin-left: 0.25rem;
    text-decoration: none;
}

.md-mermaid-preview {
    min-height: 280px;
    overflow-x: auto;
}

.md-mermaid,
.md-mermaid svg {
    max-width: 100%;
}

.md-mermaid-error {
    border: 1px dashed var(--color-error);
    padding: 0.75rem;
    color: var(--color-error);
}

.md-refs-wrap {
    min-height: 320px;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.md-refs-table {
    margin: 0;
    font-size: 0.8125rem;
}

.md-refs-table td,
.md-refs-table th {
    vertical-align: top;
}

.md-ref-type {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 999px;
}

.md-ref-type-link { color: var(--accent); background: var(--tint-accent); }
.md-ref-type-image { color: var(--accent-2); background: var(--tint-accent-2); }

.md-preview a {
    color: var(--link);
}

.md-preview a:visited {
    color: var(--link-visited);
}

.md-preview a:hover {
    color: var(--link-hover);
}

.tool-code-block {
    min-height: 120px;
    max-height: 320px;
    overflow: auto;
    padding: 0.75rem;
    margin: 0;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.tool-code-block-hl {
    white-space: pre;
    word-break: normal;
}

.tool-code-block-hl code.hljs {
    display: block;
    padding: 0;
    background: transparent;
    font-size: inherit;
    line-height: 1.55;
}

.diff-output {
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    overflow: auto;
    max-height: 480px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
}

.diff-line {
    display: flex;
    padding: 0.1rem 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-gutter {
    flex-shrink: 0;
    width: 6.5rem;
    color: var(--text-muted);
    user-select: none;
    padding-right: 0.75rem;
}

.diff-equal { background: transparent; }
.diff-add { background: var(--color-diff-add-bg); }
.diff-remove { background: var(--color-diff-remove-bg); }

.img-drop {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    overflow: hidden;
}

.img-drop img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
}

.img-drop-active {
    border-color: var(--primary-color);
    background: var(--tint-accent-subtle);
}

.img-viewer {
    padding: 1rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    text-align: center;
}

.img-side-by-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.img-side-by-side figure {
    margin: 0;
}

.img-side-by-side figcaption {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.img-side-by-side img {
    max-width: 100%;
    border-radius: 0.25rem;
}

.img-slider-wrap {
    position: relative;
    margin: 0 auto;
    max-width: 100%;
}

.img-slider-stage {
    position: relative;
    overflow: hidden;
    border-radius: 0.25rem;
    user-select: none;
}

.img-slider-stage img {
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.img-slider-base {
    width: 100%;
    height: auto;
}

.img-slider-top {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.img-slider-top img {
    height: auto;
    max-width: none;
}

.img-slider-hit {
    position: absolute;
    inset: 0;
    z-index: 3;
    touch-action: none;
    cursor: col-resize;
}

.img-slider-hit.img-slider-dragging {
    cursor: col-resize;
}

.img-slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    background: var(--primary-color);
    pointer-events: none;
    z-index: 2;
}

.img-slider-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.img-slider {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    accent-color: var(--primary-color);
}

.tool-range {
    width: 8rem;
    accent-color: var(--primary-color);
}

.code-output {
    display: flex;
    justify-content: center;
    padding: 1.5rem;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    min-height: 200px;
    align-items: center;
}

.code-output canvas {
    max-width: 100%;
}

.code-output svg {
    max-width: 100%;
    height: auto;
}

.tool-file-input {
    width: auto;
    max-width: 14rem;
    min-height: 38px;
    padding: 0.25rem 0.5rem;
}

.qr-logo-preview {
    width: 40px;
    height: 40px;
    border-radius: 0.25rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.qr-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.code-example {
    padding: 0.1rem 0.35rem;
    border-radius: 0.2rem;
    background: var(--surface-code);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85em;
}

#codeFormatHelp .btn-sm {
    margin-left: 0.35rem;
    vertical-align: middle;
}

@media (max-width: 768px) {
    .img-side-by-side {
        grid-template-columns: 1fr;
    }
}

/* Time zone converter */
.tz-detected {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.tz-results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.5rem 0 0.75rem;
}

.tz-results-title {
    font-size: 1.1rem;
    margin: 0 0 0.25rem;
}

.tz-results-summary {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.tz-results-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    min-width: min(100%, 320px);
}

.tz-results-search {
    min-width: 180px;
    flex: 1;
}

.tz-table-wrap {
    max-height: min(60vh, 520px);
    overflow: auto;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.tz-table {
    margin-bottom: 0;
}

.tz-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-dark);
}

.tz-row-source {
    background: var(--tint-accent-faint) !important;
}

.tz-time-copy {
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    border-radius: 4px;
    transition: color var(--transition);
}

.tz-time-copy:hover {
    color: var(--accent);
}

.tz-offset {
    color: var(--text-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.tz-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border-radius: 999px;
    vertical-align: middle;
}

.tz-badge-source {
    color: var(--accent);
    background: var(--tint-accent-emphasis);
}

.tz-badge-you {
    color: var(--color-success);
    background: var(--color-success-bg);
}

@media (max-width: 768px) {
    .tz-results-controls {
        width: 100%;
    }

    .page-share-btn > span:not(.share-icon) {
        display: none;
    }
}

/* Share dialog */
.share-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    background: var(--overlay-backdrop);
    backdrop-filter: blur(3px);
}

.share-overlay[hidden] {
    display: none !important;
}

.share-overlay.open {
    display: flex !important;
}

body.share-open {
    overflow: hidden;
}

/* iOS PWA: body overflow:hidden breaks position:fixed modals in standalone */
html.is-pwa body.share-open {
    overflow: visible;
}

@media (max-width: 768px) {
    body.share-open {
        overflow: visible;
    }
}

html.is-pwa .share-overlay.open {
    z-index: 10000;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

@media (max-width: 768px) {
    .share-overlay.open {
        align-items: flex-end;
        padding: 0;
    }

    .share-overlay.open .share-dialog {
        width: 100%;
        border-radius: 1rem 1rem 0 0;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
}

.share-dialog {
    width: min(100%, 480px);
    padding: 1.35rem 1.5rem 1.5rem;
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.share-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.share-header h2 {
    font-size: 1.15rem;
    margin: 0;
}

.share-close {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: var(--radius-sm);
}

.share-close:hover {
    color: var(--text-light);
    background: var(--surface);
}

.share-desc {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.share-url-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.share-url-input {
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-native-btn {
    width: 100%;
    margin-bottom: 0.5rem;
}

.share-file-actions {
    margin-bottom: 0.5rem;
}

.share-file-actions .btn {
    width: 100%;
}

.share-import-row {
    margin-bottom: 0.25rem;
}

.share-import-btn {
    padding-left: 0;
    padding-right: 0;
    font-size: 0.8125rem;
}

.share-hint {
    margin: 0.75rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.share-hint-warn {
    color: var(--color-warning);
}

.pomodoro-display {
    font-size: clamp(2.5rem, 8vw, 4rem);
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.grad-preview {
    height: 120px;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
}

.con-sample {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    font-weight: 600;
    border: 1px solid var(--surface-border);
}

.meta-preview-card {
    padding: 1rem 1.25rem;
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.meta-g-title { color: var(--meta-title); font-size: 1.1rem; margin-bottom: 0.2rem; }
.meta-g-url { color: var(--meta-url); font-size: 0.8rem; margin-bottom: 0.25rem; }
.meta-g-desc { color: var(--meta-desc); font-size: 0.875rem; line-height: 1.45; }
.meta-s-url { color: var(--meta-url); font-size: 0.75rem; text-transform: uppercase; }
.meta-s-title { font-weight: 600; margin: 0.25rem 0; }
.meta-s-desc { color: var(--text-secondary); font-size: 0.875rem; }

.fav-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.fav-item {
    text-align: center;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.exif-preview img {
    display: block;
    margin: 0 auto;
}

.snip-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.w-100 { width: 100% !important; }

.imgb64-drop {
    margin-bottom: 1rem;
    padding: 2rem 1rem;
    text-align: center;
    background: var(--surface);
    border: 2px dashed var(--surface-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.imgb64-drop.is-dragover {
    border-color: var(--accent);
    background: var(--tint-accent-subtle);
}

.imgb64-drop p {
    margin: 0 0 0.35rem;
    color: var(--text-secondary);
}

.imgb64-preview img {
    display: block;
    max-width: 12rem;
    max-height: 12rem;
    margin: 0 auto;
    border-radius: var(--radius-sm);
}

.cc-preview-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cc-preview {
    flex: 1;
    min-height: 5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
}

.cc-picker {
    width: 3rem;
    height: 3rem;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.clamp-demo {
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    background: var(--bg-dark);
    resize: horizontal;
    overflow: auto;
    min-width: 240px;
    max-width: 100%;
}

.clamp-demo p {
    margin: 0;
    line-height: 1.4;
}

.cb-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.cb-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .cb-grid {
        grid-template-columns: 1fr;
    }
}

.cb-panel-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.cb-preview {
    min-height: 8rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: #fff;
}

.cb-filter-protan { filter: url(#cb-protanopia); }
.cb-filter-deutan { filter: url(#cb-deuteranopia); }
.cb-filter-tritan { filter: url(#cb-tritanopia); }

.cb-sample-gradient {
    height: 2.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.cb-sample-text {
    margin: 0 0 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.cb-sample-text-dark {
    color: #1a1a2e;
}

.cb-sample-swatches {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.cb-sample-swatches span {
    flex: 1;
    height: 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.svgopt-preview {
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.svgopt-preview svg {
    max-width: 100%;
    max-height: 200px;
}

.openapi-endpoints {
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
}

.openapi-search-bar {
    align-items: center;
    gap: 0.75rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.openapi-search-bar .form-control {
    flex: 1 1 16rem;
    min-width: 0;
}

.openapi-search-count {
    flex: 0 0 auto;
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.openapi-mark {
    background: color-mix(in srgb, var(--color-accent, #5caeeb) 35%, transparent);
    color: inherit;
    border-radius: 0.15rem;
    padding: 0 0.1rem;
}

.openapi-endpoint {
    padding: 0.25rem 0;
    font-size: 0.85rem;
}

.openapi-endpoint-desc {
    color: var(--text-muted);
}

.openapi-method {
    display: inline-block;
    min-width: 3.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    margin-right: 0.35rem;
}

.openapi-method-get { background: var(--color-success); color: #fff; }
.openapi-method-post { background: var(--color-accent, #5caeeb); color: #fff; }
.openapi-method-put { background: #eab308; color: #1a1a2e; }
.openapi-method-patch { background: #a855f7; color: #fff; }
.openapi-method-delete { background: var(--color-error); color: #fff; }
.openapi-method-head,
.openapi-method-options,
.openapi-method-trace { background: var(--text-muted); color: #fff; }

.openapi-tree {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    max-height: 480px;
    overflow: auto;
}

.openapi-node details {
    margin-left: 0.75rem;
}

.openapi-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.15rem 0;
}

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

.openapi-summary::before {
    content: '▸';
    display: inline-block;
    width: 1rem;
    color: var(--text-muted);
}

.openapi-node details[open] > .openapi-summary::before {
    content: '▾';
}

.openapi-leaf {
    display: flex;
    gap: 0.5rem;
    padding: 0.1rem 0 0.1rem 1rem;
    flex-wrap: wrap;
}

.openapi-key {
    color: var(--color-accent, #5caeeb);
}

.openapi-type,
.openapi-val {
    color: var(--text-muted);
    word-break: break-all;
}

.har-table .har-url {
    max-width: 28rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
}

.li-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
}

/* Mobile-native tool layout (shared across all tools) */
@media (max-width: 768px) {
    body.tool-page .main-content {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    body.tool-page .btn {
        min-height: 36px;
        padding: 0.45rem 0.85rem;
        font-size: 0.8125rem;
    }

    body.tool-page .btn-primary {
        min-width: 0;
        box-shadow: none;
    }

    body.tool-page .form-control,
    body.tool-page .form-select {
        min-height: 2.75rem;
        border-radius: 0.625rem;
    }

    body.tool-page .form-label {
        font-size: 0.75rem;
    }

    body.tool-page .page-body > p:first-child,
    body.tool-page .page-body > .tool-hint:first-child {
        font-size: 0.8125rem;
        line-height: 1.45;
        margin-bottom: 0.85rem;
        color: var(--text-muted);
    }

    body.tool-page .page-body .tool-subheading,
    body.tool-page .page-body h2:not(.share-header h2) {
        font-size: 0.8125rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        margin: 1.1rem 0 0.4rem;
    }

    /* iOS-style grouped form sections */
    body.tool-page .page-body .row {
        margin-left: 0;
        margin-right: 0;
        padding: 0.15rem 0.85rem;
        background: var(--bg-dark);
        border: 1px solid var(--surface-border);
        border-radius: 0.625rem;
    }

    body.tool-page .page-body .row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    body.tool-page .page-body .row > [class*="col-"] + [class*="col-"] {
        border-top: 1px solid var(--surface-border);
    }

    body.tool-page .page-body .row .form-label {
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        margin-bottom: 0.2rem;
    }

    body.tool-page .page-body .row .form-control,
    body.tool-page .page-body .row .form-select {
        min-height: 2.25rem;
        padding: 0.35rem 0;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    body.tool-page .page-body .row .form-control:focus,
    body.tool-page .page-body .row .form-select:focus {
        box-shadow: none;
    }

    body.tool-page .page-body .form-control,
    body.tool-page .page-body .form-select {
        border-radius: 0.625rem;
    }

    /* Compact segmented toolbars */
    body.tool-page .tool-toolbar {
        flex-wrap: wrap;
        gap: 0.35rem;
        padding: 0.25rem;
        background: var(--bg-dark);
        border: 1px solid var(--surface-border);
        border-radius: 0.625rem;
    }

    body.tool-page .tool-toolbar .form-label {
        flex: 1 1 100%;
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        margin: 0.15rem 0.35rem 0;
    }

    body.tool-page .tool-toolbar .btn {
        flex: 1 1 calc(50% - 0.35rem);
        min-width: 0;
        min-height: 2.125rem;
        padding: 0.35rem 0.55rem;
        font-size: 0.8125rem;
        font-weight: 600;
        border-radius: 0.45rem;
        box-shadow: none;
    }

    body.tool-page .tool-toolbar .btn-primary {
        min-width: 0;
        background: var(--accent);
    }

    body.tool-page .tool-toolbar .tool-checkbox,
    body.tool-page .tool-toolbar .tool-flags {
        flex: 1 1 100%;
        padding: 0.25rem 0.35rem 0.15rem;
        font-size: 0.8125rem;
    }

    body.tool-page .tool-toolbar .form-select,
    body.tool-page .tool-toolbar .tool-select-sm {
        flex: 1 1 100%;
        min-width: 0;
        min-height: 2.25rem;
    }

    /* Primary actions — full-width iOS-style buttons */
    body.tool-page .page-body > .btn,
    body.tool-page .page-body > .btn-primary,
    body.tool-page .page-body > .btn-secondary {
        display: flex;
        width: 100%;
        min-height: 2.75rem;
        margin-bottom: 0.75rem;
        border-radius: 0.625rem;
        font-size: 0.9375rem;
        font-weight: 600;
        box-shadow: none;
    }

    body.tool-page .page-body > .btn-primary {
        min-width: 0;
        background: var(--accent);
    }

    body.tool-page .page-body .btn-primary:not(.btn-sm):not(.tool-toolbar .btn):not(.table .btn) {
        display: inline-flex;
        width: 100%;
        min-height: 2.75rem;
        border-radius: 0.625rem;
        font-weight: 600;
        box-shadow: none;
    }

    body.tool-page .page-body .btn-primary:not(.btn-sm):not(.tool-toolbar .btn):not(.table .btn) {
        min-width: 0;
        background: var(--accent);
    }

    body.tool-page .page-body .btn-sm {
        min-height: 1.875rem;
        padding: 0.25rem 0.55rem;
        font-size: 0.75rem;
        border-radius: 0.45rem;
    }

    /* Text areas & panes */
    body.tool-page .tool-textarea {
        min-height: 220px;
        padding: 0.75rem;
        border-radius: 0.625rem;
        font-size: 0.875rem;
    }

    body.tool-page .tool-textarea-sm {
        min-height: 100px;
    }

    body.tool-page .tool-pane {
        margin-bottom: 0.75rem;
    }

    body.tool-page .tool-pane .form-label {
        font-size: 0.6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        margin-bottom: 0.35rem;
    }

    body.tool-page .tool-split {
        gap: 0.75rem;
    }

    /* Results & output cards */
    body.tool-page .tool-results,
    body.tool-page .tool-preview,
    body.tool-page .tool-match-card,
    body.tool-page .nl-help {
        border-radius: 0.625rem;
        padding: 0.75rem 0.85rem;
    }

    body.tool-page .tool-result-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
        padding: 0.35rem 0;
        border-bottom: 1px solid var(--surface-border);
    }

    body.tool-page .tool-result-row:last-child {
        border-bottom: none;
    }

    body.tool-page .tool-result-row code {
        text-align: left;
        font-size: 0.8125rem;
    }

    /* Tables — tighter, card rows where possible */
    body.tool-page .page-body .table {
        font-size: 0.8125rem;
        border: 1px solid var(--surface-border);
        border-radius: 0.625rem;
        overflow: hidden;
    }

    body.tool-page .page-body .table th,
    body.tool-page .page-body .table td {
        padding: 0.55rem 0.65rem;
    }

    body.tool-page .page-body .table td:last-child:has(.btn) {
        width: auto;
    }

    /* Misc controls */
    body.tool-page .regex-lang-tabs {
        gap: 0.25rem;
        padding: 0.2rem;
        background: var(--bg-dark);
        border: 1px solid var(--surface-border);
        border-radius: 0.625rem;
    }

    body.tool-page .regex-lang-tab {
        flex: 1 1 auto;
        text-align: center;
        min-height: 2rem;
        padding: 0.35rem 0.45rem;
        font-size: 0.75rem;
    }

    body.tool-page .color-swatches {
        gap: 0.5rem;
    }

    body.tool-page .tool-file-input {
        font-size: 0.8125rem;
    }

    body.tool-page .tool-status {
        font-size: 0.8125rem;
        margin-top: 0.5rem;
    }
}

