/*
 * Shared "digital workbench" theme for every tool page.
 * The grid, calibration marks and restrained signal colours turn unrelated
 * utilities into one coherent instrument panel without changing tool logic.
 */
:root {
    --tool-paper: #f2f5f3;
    --tool-paper-deep: #e6ebe8;
    --tool-ink: #17272f;
    --tool-muted: #63737a;
    --tool-blueprint: #12334b;
    --tool-signal: #d64120;
    --tool-cyan: #2c8c99;
    --tool-success: #207863;
    --tool-warning: #b97819;
    --tool-line: rgba(18, 51, 75, 0.17);
    --tool-line-strong: rgba(18, 51, 75, 0.32);
    --tool-surface: rgba(255, 255, 255, 0.76);
    --tool-surface-strong: rgba(255, 255, 255, 0.96);
    --tool-shadow: 0 22px 64px rgba(18, 51, 75, 0.12);
    --tool-soft-shadow: 4px 4px 0 rgba(18, 51, 75, 0.055);
    --tool-code-bg: #f8faf9;
    --tool-green: var(--tool-cyan);
    --tool-green-dark: #236e78;
    --tool-coral: var(--tool-signal);
    --tool-gold: #e8a73a;
}

html {
    min-height: 100%;
    color-scheme: light;
    scroll-behavior: smooth;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    min-height: 100vh !important;
    padding: clamp(16px, 3vw, 34px) 0 56px !important;
    color: var(--tool-ink) !important;
    font-family: Aptos, "Microsoft YaHei", "PingFang SC", sans-serif !important;
    line-height: 1.6;
    background-color: var(--tool-paper) !important;
    background-image:
        linear-gradient(rgba(18, 51, 75, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 51, 75, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(18, 51, 75, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(18, 51, 75, 0.018) 1px, transparent 1px) !important;
    background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px !important;
    background-attachment: fixed !important;
    background-position: 0 0 !important;
}

body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    z-index: 999;
    height: 5px;
    background: linear-gradient(90deg, var(--tool-signal) 0 11%, var(--tool-cyan) 11% 18%, var(--tool-blueprint) 18% 100%);
}

body::after {
    content: "LOCAL / BROWSER TOOL";
    position: fixed;
    right: 14px;
    bottom: 10px;
    z-index: -1;
    color: rgba(18, 51, 75, 0.25);
    font: 700 0.58rem/1 "Cascadia Code", Consolas, monospace;
    letter-spacing: 0.14em;
    writing-mode: vertical-rl;
}

::selection {
    background: rgba(44, 140, 153, 0.24);
    color: var(--tool-blueprint);
}

a {
    color: inherit;
}

.container,
.tool-container,
.page,
main.container {
    width: min(1180px, calc(100% - 28px)) !important;
    max-width: 1180px !important;
    margin: 0 auto !important;
}

.ported-tool-nav {
    width: min(1180px, calc(100% - 28px));
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 0 auto 10px;
}

.header,
.tool-header,
.topbar {
    color: var(--tool-ink) !important;
}

body > .container > .header:first-child,
body > .tool-container > .header:first-child,
body > .container > .tool-header:first-child,
.container > .header:first-child,
.tool-header {
    position: relative !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: end !important;
    gap: 1.5rem !important;
    min-height: 180px !important;
    margin-bottom: 12px !important;
    padding: 54px clamp(22px, 4vw, 42px) 28px !important;
    overflow: hidden !important;
    border: 1px solid var(--tool-line-strong) !important;
    border-radius: 6px !important;
    background: var(--tool-surface) !important;
    box-shadow: var(--tool-shadow), 7px 7px 0 rgba(18, 51, 75, 0.055) !important;
    backdrop-filter: blur(10px) !important;
}

body > .container > .header:first-child::before,
body > .tool-container > .header:first-child::before,
body > .container > .tool-header:first-child::before,
.container > .header:first-child::before,
.tool-header::before {
    content: "ACTIVE INSTRUMENT" !important;
    position: absolute !important;
    top: 22px !important;
    left: clamp(22px, 4vw, 42px) !important;
    color: var(--tool-cyan) !important;
    font: 700 0.76rem/1 "Cascadia Code", Consolas, monospace !important;
    letter-spacing: 0.16em !important;
}

body > .container > .header:first-child::after,
body > .tool-container > .header:first-child::after,
body > .container > .tool-header:first-child::after,
.container > .header:first-child::after,
.tool-header::after {
    content: "" !important;
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 96px !important;
    height: 96px !important;
    border-left: 1px solid var(--tool-line) !important;
    background:
        linear-gradient(45deg, transparent 48.5%, rgba(18, 51, 75, 0.14) 49%, rgba(18, 51, 75, 0.14) 51%, transparent 51.5%) !important;
    pointer-events: none !important;
}

h1,
h2,
h3 {
    color: var(--tool-blueprint) !important;
}

h1 {
    font-family: "Bahnschrift SemiCondensed", "Arial Narrow", "Microsoft YaHei", sans-serif !important;
    font-weight: 700 !important;
    letter-spacing: -0.035em !important;
}

.header h1,
.tool-header h1 {
    display: flex !important;
    align-items: center !important;
    gap: 0.85rem !important;
    margin: 0 !important;
    font-size: clamp(1.85rem, 3.35vw, 3.05rem) !important;
    line-height: 1.04 !important;
}

.header p,
.tool-header p,
.subtitle,
.description,
.hint,
.help-text,
.muted {
    color: var(--tool-muted) !important;
}

.header p,
.tool-header p {
    max-width: 720px;
    margin-top: 10px !important;
    font-size: 1.04rem !important;
    line-height: 1.65 !important;
}

.tool-page-icon,
.icon-badge,
.category-icon {
    position: relative !important;
    min-width: 2.65rem !important;
    width: auto !important;
    height: 2.65rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 0.55rem !important;
    border: 1px solid var(--tool-line-strong) !important;
    border-radius: 4px !important;
    background: transparent !important;
    color: var(--tool-cyan) !important;
    font: 700 0.8rem/1 "Cascadia Code", Consolas, monospace !important;
    letter-spacing: -0.04em !important;
    box-shadow: 3px 3px 0 rgba(44, 140, 153, 0.15) !important;
    flex-shrink: 0 !important;
}

.tool-page-icon::after,
.icon-badge::after,
.category-icon::after {
    content: "";
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 7px;
    height: 7px;
    border: 2px solid var(--tool-paper);
    background: var(--tool-signal);
}

.back-link,
.home-link,
a.back,
.nav-back {
    min-height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 0 14px !important;
    border: 1px solid var(--tool-line-strong) !important;
    border-radius: 4px !important;
    background: rgba(255, 255, 255, 0.7) !important;
    color: var(--tool-blueprint) !important;
    text-decoration: none !important;
    font: 700 0.78rem/1 "Cascadia Code", Consolas, monospace !important;
    letter-spacing: 0.03em !important;
    box-shadow: 3px 3px 0 rgba(18, 51, 75, 0.08) !important;
    transition: transform 0.16s ease, color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease !important;
}

.back-link::before,
.home-link::before,
a.back::before,
.nav-back::before {
    content: "←";
    color: var(--tool-signal);
}

.back-link:hover,
.home-link:hover,
a.back:hover,
.nav-back:hover {
    background: var(--tool-blueprint) !important;
    color: #fff !important;
    transform: translate(-1px, -1px) !important;
    box-shadow: 4px 4px 0 rgba(214, 65, 32, 0.25) !important;
}

.tool-help-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    background: var(--tool-blueprint);
    color: #fff;
    font: 700 0.78rem/1 "Cascadia Code", Consolas, monospace;
    text-decoration: none;
    box-shadow: 5px 5px 0 rgba(44, 140, 153, 0.2);
    transition: transform 0.16s ease, background 0.16s ease;
}

.tool-help-fab::before {
    content: "?";
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 50%;
}

.tool-help-fab:hover {
    background: var(--tool-signal);
    transform: translate(-2px, -2px);
}

.panel,
.card,
.box,
.section,
.result-card,
.preview-panel,
.input-panel,
.output-panel,
.settings,
.options,
.options-bar,
.control-panel,
.drop-zone,
.drop-area,
.upload-area,
.converter-box,
.tool-card,
.ip-card {
    position: relative;
    border: 1px solid var(--tool-line) !important;
    border-radius: 5px !important;
    background: var(--tool-surface) !important;
    color: var(--tool-ink) !important;
    box-shadow: var(--tool-soft-shadow) !important;
    backdrop-filter: blur(8px) !important;
}

.panel,
.section,
.input-panel,
.output-panel,
.control-panel {
    margin-bottom: 12px !important;
}

.panel::before,
.input-panel::before,
.output-panel::before,
.control-panel::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 18px;
    width: 42px;
    height: 3px;
    z-index: 2;
    background: var(--tool-cyan);
}

.panel-header,
.card-header,
.section-header,
.panel-title-bar,
.toolbar,
.controls,
.tabs,
.tab-bar {
    border-color: var(--tool-line) !important;
    background: rgba(230, 235, 232, 0.66) !important;
    color: var(--tool-ink) !important;
}

.panel-title,
.card-title,
.section-title,
legend,
label,
th {
    color: var(--tool-blueprint) !important;
    font-weight: 800 !important;
}

.panel-title,
.card-title,
.section-title {
    font-family: "Bahnschrift SemiCondensed", "Arial Narrow", "Microsoft YaHei", sans-serif !important;
    letter-spacing: 0.01em !important;
}

label,
legend {
    font-size: 0.94rem !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
select,
textarea {
    border: 1px solid var(--tool-line-strong) !important;
    border-radius: 3px !important;
    background: var(--tool-surface-strong) !important;
    color: var(--tool-ink) !important;
    font-family: inherit !important;
    outline: none !important;
    box-shadow: inset 0 1px 2px rgba(18, 51, 75, 0.035) !important;
}

textarea,
pre,
code,
.code,
.output,
.editor,
.preview,
.result,
.log,
.terminal {
    color: var(--tool-ink) !important;
    background: var(--tool-code-bg) !important;
}

textarea,
pre,
code,
.code,
.editor,
.terminal {
    font-family: "Cascadia Code", Consolas, "Microsoft YaHei", monospace !important;
}

textarea::placeholder,
input::placeholder {
    color: rgba(99, 115, 122, 0.7) !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--tool-cyan) !important;
    box-shadow: 0 0 0 3px rgba(44, 140, 153, 0.13) !important;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--tool-cyan) !important;
}

button,
.btn,
.button,
input[type="button"],
input[type="submit"] {
    min-height: 38px;
    border: 1px solid var(--tool-line-strong) !important;
    border-radius: 3px !important;
    background: rgba(255, 255, 255, 0.85) !important;
    color: var(--tool-blueprint) !important;
    font-weight: 800 !important;
    cursor: pointer !important;
    box-shadow: 2px 2px 0 rgba(18, 51, 75, 0.07) !important;
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease !important;
}

button:hover:not(:disabled),
.btn:hover:not(:disabled),
.button:hover:not(:disabled),
input[type="button"]:hover:not(:disabled),
input[type="submit"]:hover:not(:disabled) {
    background: #fff !important;
    transform: translate(-1px, -1px) !important;
    box-shadow: 4px 4px 0 rgba(18, 51, 75, 0.1) !important;
}

.btn-primary,
.btn.primary,
button.primary,
.button.primary,
input.primary,
.btn.active,
button.active,
.tab.active,
.filter-chip.active {
    border-color: var(--tool-blueprint) !important;
    background: var(--tool-blueprint) !important;
    color: #fff !important;
    box-shadow: 3px 3px 0 rgba(214, 65, 32, 0.22) !important;
}

.btn-primary:hover,
.btn.primary:hover,
button.primary:hover,
.button.primary:hover,
input.primary:hover {
    background: #0b273b !important;
}

.btn-success,
.btn.success,
button.success,
.button.success,
input.success {
    border-color: var(--tool-success) !important;
    background: var(--tool-success) !important;
    color: #fff !important;
}

.btn-danger,
button.danger,
.btn.danger,
.button.danger,
input.danger,
.btn-error {
    border-color: var(--tool-signal) !important;
    background: var(--tool-signal) !important;
    color: #fff !important;
}

button:disabled,
.btn:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.48 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

button:focus-visible,
.btn:focus-visible,
.button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--tool-signal) !important;
    outline-offset: 3px !important;
}

.status,
.status-bar,
.message,
.info,
.notice {
    border-color: var(--tool-line) !important;
    border-radius: 3px !important;
    background: rgba(230, 235, 232, 0.62) !important;
    color: var(--tool-muted) !important;
    font-size: 0.92rem !important;
}

.status::before,
.status-bar::before {
    color: var(--tool-cyan);
}

.status.success,
.status-bar.success,
.message.success,
.success-text {
    color: var(--tool-success) !important;
}

.status.error,
.status-bar.error,
.message.error,
.error,
.error-line,
.error-text {
    color: #c64529 !important;
    border-color: rgba(214, 65, 32, 0.45) !important;
}

table {
    border-color: var(--tool-line) !important;
    border-collapse: collapse !important;
}

td,
th {
    border-color: var(--tool-line) !important;
}

th {
    background: rgba(230, 235, 232, 0.72) !important;
}

.drop-overlay {
    color: var(--tool-cyan) !important;
    border-color: var(--tool-cyan) !important;
    background: rgba(44, 140, 153, 0.14) !important;
    backdrop-filter: blur(8px) !important;
}

@media (max-width: 768px) {
    body {
        padding: 14px 0 52px !important;
        background-attachment: scroll !important;
    }

    body > .container > .header:first-child,
    body > .tool-container > .header:first-child,
    body > .container > .tool-header:first-child,
    .container > .header:first-child,
    .tool-header {
        grid-template-columns: 1fr !important;
        align-items: stretch !important;
        min-height: 0 !important;
        padding: 52px 20px 22px !important;
    }

    .header h1,
    .tool-header h1 {
        align-items: flex-start !important;
        font-size: clamp(1.7rem, 7.6vw, 2.65rem) !important;
    }

    .tool-page-icon,
    .icon-badge,
    .category-icon {
        margin-top: 2px !important;
    }

    .back-link,
    .home-link,
    a.back,
    .nav-back {
        width: max-content !important;
    }

    .tool-help-fab {
        right: 12px;
        bottom: 12px;
    }
}

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