/* Shared UI primitives.
 * Loaded after each tool's own stylesheet so standard tools share one visual
 * language. Full-screen editors opt out with <body class="ui-editor">. */

:root {
    --ui-radius: 0px;
    --ui-control-height: 40px;
    --ui-control-font: 14px;
    --ui-border: #d8dde6;
    --ui-border-strong: #000000;
    --ui-muted: #666666;
    --ui-subtle: #fafafa;
    --ui-subtle-hover: #f4f4f4;
    --upload-bg: #eff6ff;
    --upload-bg-default: #fafafa;
    --upload-border: #d1d5db;
    --upload-border-strong: #1d4ed8;
    --upload-text: #1e40af;
}

/* ---- Form controls ---- */

body:not(.ui-editor) input[type="text"],
body:not(.ui-editor) input[type="number"],
body:not(.ui-editor) input[type="search"],
body:not(.ui-editor) input[type="url"],
body:not(.ui-editor) input[type="email"],
body:not(.ui-editor) input[type="password"],
body:not(.ui-editor) textarea,
body:not(.ui-editor) select {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: #ffffff;
    color: #000000;
    font-family: inherit;
    font-size: var(--ui-control-font);
}

body:not(.ui-editor) input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):not([type="hidden"]):not(.tool-search):not(.site-search__input),
body:not(.ui-editor) select {
    height: var(--ui-control-height);
}

body:not(.ui-editor) input[type="text"],
body:not(.ui-editor) input[type="number"],
body:not(.ui-editor) input[type="search"],
body:not(.ui-editor) input[type="url"],
body:not(.ui-editor) input[type="email"],
body:not(.ui-editor) input[type="password"],
body:not(.ui-editor) select {
    padding: 0 12px;
}

body:not(.ui-editor) textarea {
    padding: 10px 12px;
    line-height: 1.5;
    resize: vertical;
}

body:not(.ui-editor) input:focus,
body:not(.ui-editor) textarea:focus,
body:not(.ui-editor) select:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 3px #f2f2f2;
}

body:not(.ui-editor) input[type="checkbox"],
body:not(.ui-editor) input[type="radio"] {
    accent-color: #000000;
}

/* Native checks use the browser indicator, not the text-input focus wash. */
body:not(.ui-editor) input[type="checkbox"]:focus,
body:not(.ui-editor) input[type="radio"]:focus {
    outline: none;
    box-shadow: none;
}

body:not(.ui-editor) input[type="checkbox"]:focus-visible,
body:not(.ui-editor) input[type="radio"]:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

/* Range sliders draw their own focus state; no text-input focus wash. */
body:not(.ui-editor) input[type="range"]:focus {
    outline: none;
    box-shadow: none;
}

body:not(.ui-editor) input[type="range"]:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

/* ---- Buttons ---- */

body:not(.ui-editor) .btn {
    height: var(--ui-control-height);
    padding: 0 20px;
    border-radius: var(--ui-radius);
    font-size: var(--ui-control-font);
}

body:not(.ui-editor) .btn-small {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
}

body:not(.ui-editor) .btn-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    padding: 0;
    border-radius: 50%;
    font-size: 16px;
}

body:not(.ui-editor) .domain-actions .btn {
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

/* ---- Segmented control / tabs ---- */

body:not(.ui-editor) .segment-btn,
body:not(.ui-editor) .mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--ui-control-height);
    padding: 0 14px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: #ffffff;
    color: #000000;
    font-family: inherit;
    font-size: var(--ui-control-font);
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

body:not(.ui-editor) .segment-btn + .segment-btn {
    margin-left: -1px;
}

body:not(.ui-editor) .segment-btn:hover,
body:not(.ui-editor) .mode-btn:hover {
    border-color: var(--ui-border-strong);
}

body:not(.ui-editor) .segment-btn.active,
body:not(.ui-editor) .mode-btn.active,
body:not(.ui-editor) .position-btn.active {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

/* ---- Upload / drop surfaces ---- */

body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone),
body:not(.ui-editor) .file-drop,
body:not(.ui-editor) .upload-drop {
    padding: 48px 20px;
    border: 2px dashed var(--upload-border);
    border-radius: var(--ui-radius);
    background: var(--ui-subtle);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):hover,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):focus-visible,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragging,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragover,
body:not(.ui-editor) .file-drop:hover,
body:not(.ui-editor) .file-drop:focus-visible,
body:not(.ui-editor) .file-drop.dragging,
body:not(.ui-editor) .upload-drop:hover,
body:not(.ui-editor) .upload-drop:focus-visible,
body:not(.ui-editor) .upload-drop.is-dragover {
    border-color: var(--upload-border-strong);
    background-color: var(--upload-bg);
}

body:not(.ui-editor) .drop-title,
body:not(.ui-editor) .drop-zone > p:first-child:not([data-upload-hint]) {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    color: #000000;
}

body:not(.ui-editor) [data-upload-hint] {
    margin: 0;
    color: #666666;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    transition: color 0.15s ease;
}

body:not(.ui-editor) .drop-desc,
body:not(.ui-editor) .drop-zone > p + p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ui-muted);
}

/* ---- Range sliders ---- */

body:not(.ui-editor) input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    background: transparent;
    cursor: pointer;
}

body:not(.ui-editor) input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: #dddddd;
}

body:not(.ui-editor) input[type="range"]::-moz-range-track {
    height: 4px;
    background: #dddddd;
}

body:not(.ui-editor) input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border: 0;
    border-radius: 50%;
    background: #000000;
}

body:not(.ui-editor) input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 0;
    border-radius: 50%;
    background: #000000;
}

/* ---- Preview canvas inside split-panel image tools ---- */

body:not(.ui-editor) .preview-inner {
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ---- Section descriptions ---- */

body:not(.ui-editor) .section-header > div > p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--ui-muted);
}

/* Text curve uses ID-scoped compact number fields; keep them aligned with the
 * shared control tokens without changing its JS hooks. */
body:not(.ui-editor) .range-row #curveValue,
body:not(.ui-editor) .range-row #radiusValue,
body:not(.ui-editor) .range-row #rotationValue,
body:not(.ui-editor) .range-row #fontSizeValue {
    height: var(--ui-control-height);
    padding: 0 8px;
    border-color: var(--ui-border);
    border-radius: var(--ui-radius);
    font-size: var(--ui-control-font);
}

body:not(.ui-editor) .segment-btn,
body:not(.ui-editor) .mode-btn {
    white-space: nowrap;
}

body:not(.ui-editor) .mode-btn {
    padding: 0 10px;
}

/* The homepage search input sits inside its own bordered wrapper. */
body:not(.ui-editor) input.tool-search,
body:not(.ui-editor) input.tool-search:focus {
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}



body:not(.ui-editor) .position-btn {
    height: var(--ui-control-height);
    padding: 0 6px;
    border-radius: var(--ui-radius);
    font-size: var(--ui-control-font);
}

@media (max-width: 768px) {
    /* Page-level mobile overrides used to collapse the gap below the nav. */
    body:not(.ui-editor) .container {
        padding-top: 32px;
    }

    /* Keep each tool's mobile header on the shared type scale. */
    body:not(.ui-editor) .header h1 {
        font-size: 22px;
    }

    body:not(.ui-editor) .header p {
        font-size: 14px;
    }
}


body:not(.ui-editor) .card {
    border-color: var(--tiat-border-soft, #e5e7eb);
}


body:not(.ui-editor) .upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: 0 auto 10px;
    color: #4b5563;
    transition: color 0.15s ease;
}

body:not(.ui-editor) .upload-icon svg {
    width: 100%;
    height: 100%;
}

/* Reserve the hint line before the dynamic upload text is injected. */
body:not(.ui-editor) [data-upload-hint] {
    min-height: 1.5em;
}

@media (max-width: 480px) {
    body:not(.ui-editor) [data-upload-hint] {
        min-height: 3em;
    }
}


body:not(.ui-editor) .drop-title {
    margin-bottom: 0;
}

body:not(.ui-editor) .drop-title + .drop-desc,
body:not(.ui-editor) .drop-title + [data-upload-hint] {
    margin-top: 2px;
}


body:not(.ui-editor) .upload-file {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

body:not(.ui-editor) .upload-file__check {
    display: inline-flex;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
}

body:not(.ui-editor) .upload-file__check svg {
    width: 100%;
    height: 100%;
}

body:not(.ui-editor) .upload-file__action {
    margin-left: 4px;
    padding-left: 8px;
    border-left: 1px solid #cbd5e1;
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
    white-space: nowrap;
}

body:not(.ui-editor) .file-info-main {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

body:not(.ui-editor) .file-info .upload-file__check {
    flex: 0 0 16px;
    margin-top: 2px;
    color: var(--upload-text);
}

body:not(.ui-editor) .file-info .file-size {
    display: inline-block;
}

body:not(.ui-editor) .file-info .upload-file__action {
    vertical-align: middle;
}

body:not(.ui-editor) .file-info #clearFileBtn {
    margin-left: auto;
}

body:not(.ui-editor) .file-drop.has-file .file-info-main {
    padding-right: 26px;
}

body:not(.ui-editor) .file-drop.has-file .file-info {
    min-height: 0;
    padding: 0;
}


body:not(.ui-editor) .has-file .upload-icon,
body:not(.ui-editor) .has-file .drop-message,
body:not(.ui-editor) .has-file .drop-title,
body:not(.ui-editor) .has-file .drop-desc,
body:not(.ui-editor) .has-file [data-upload-hint] {
    display: none;
}

body:not(.ui-editor) .has-file .upload-file {
    margin-top: 0;
}

/* Every upload surface uses the light blue wash; interactive states use a blue border. */
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone),
body:not(.ui-editor) .file-drop,
body:not(.ui-editor) .upload-drop {
    background-color: var(--upload-bg-default);
}

body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):hover,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):focus-visible,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragging,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragover,
body:not(.ui-editor) .file-drop:hover,
body:not(.ui-editor) .file-drop:focus-visible,
body:not(.ui-editor) .file-drop.dragging,
body:not(.ui-editor) .upload-drop:hover,
body:not(.ui-editor) .upload-drop:focus-visible,
body:not(.ui-editor) .upload-drop.is-dragover {
    border-color: var(--upload-border-strong);
    background-color: var(--upload-bg);
}

body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).has-file,
body:not(.ui-editor) .file-drop.has-file,
body:not(.ui-editor) .upload-drop.has-file {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-width: 1px;
    border-style: solid;
    border-color: var(--upload-border-strong);
    background-color: var(--upload-bg);
}

body:not(.ui-editor) .has-file .file-info,
body:not(.ui-editor) .has-file .upload-file {
    width: 100%;
}

body:not(.ui-editor) .has-file .upload-file,
body:not(.ui-editor) .has-file .file-name,
body:not(.ui-editor) .has-file .file-size {
    color: var(--upload-text);
}

body:not(.ui-editor) .has-file .file-info {
    border-color: transparent;
    background: transparent;
}


/* Hover/focus/drag feedback for the icon and format hint. */
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):hover .upload-icon,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):focus-visible .upload-icon,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragging .upload-icon,
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragover .upload-icon,
body:not(.ui-editor) .file-drop:hover .upload-icon,
body:not(.ui-editor) .file-drop:focus-visible .upload-icon,
body:not(.ui-editor) .file-drop.dragging .upload-icon,
body:not(.ui-editor) .upload-drop:hover .upload-icon,
body:not(.ui-editor) .upload-drop:focus-visible .upload-icon,
body:not(.ui-editor) .upload-drop.dragging .upload-icon {
    color: var(--upload-border-strong);
}

body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):hover [data-upload-hint],
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone):focus-visible [data-upload-hint],
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragging [data-upload-hint],
body:not(.ui-editor) .drop-zone:not(.upload-preview-area .drop-zone).dragover [data-upload-hint],
body:not(.ui-editor) .file-drop:hover [data-upload-hint],
body:not(.ui-editor) .file-drop:focus-visible [data-upload-hint],
body:not(.ui-editor) .file-drop.dragging [data-upload-hint],
body:not(.ui-editor) .upload-drop:hover [data-upload-hint],
body:not(.ui-editor) .upload-drop:focus-visible [data-upload-hint],
body:not(.ui-editor) .upload-drop.dragging [data-upload-hint] {
    color: var(--upload-border-strong);
}


/* Leading download icon for primary buttons */
.download-icon {
    display: inline-flex;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

.download-icon svg {
    width: 100%;
    height: 100%;
}

.btn > .download-icon {
    margin-right: 6px;
}
