:root {
    color-scheme: light dark;

    --bg: #ffffff;
    --bg-subtle: #f5f6f8;
    --panel: #ffffff;
    --text: #16181d;
    --text-muted: #565e6b;
    --border: #dde1e6;
    --border-strong: #c2c9d2;
    --accent: #1a5fd0;
    --accent-contrast: #ffffff;
    --accent-subtle: #eef4fd;
    --success: #19703c;
    --danger: #b3261e;
    --info: #1a5fd0;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(15, 17, 21, 0.06);

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --container: 1080px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --bg-subtle: #171a1f;
        --panel: #171a1f;
        --text: #e7eaee;
        --text-muted: #a2acb9;
        --border: #2a3038;
        --border-strong: #3a424d;
        --accent: #6cb0ff;
        --accent-contrast: #06101f;
        --accent-subtle: #16233a;
        --success: #5ecb8a;
        --danger: #ff8a80;
        --info: #6cb0ff;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

h1,
h2,
h3 {
    line-height: 1.25;
    margin: 0 0 0.4em;
}

p {
    margin: 0 0 1em;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

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

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--accent);
    color: var(--accent-contrast);
    padding: 0.5rem 0.9rem;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    left: 0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.site-brand:hover {
    text-decoration: none;
}

.site-brand__mark {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.site-nav {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
}

.site-nav a {
    color: var(--text-muted);
}

.site-nav a:hover,
.site-nav a:focus-visible {
    color: var(--text);
}

.site-main {
    padding: 32px 0 8px;
}

.page-intro {
    margin-bottom: 24px;
}

.page-intro h1 {
    font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.1rem);
    letter-spacing: -0.02em;
    margin-bottom: 0.25em;
}

.lede {
    color: var(--text-muted);
    font-size: 1.02rem;
    margin: 0;
}

.catalog__controls {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 10px;
}

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

.field--search {
    flex: 1 1 auto;
}

.field--category {
    flex: 0 0 220px;
}

.label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
}

.textarea {
    min-height: 8rem;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.input--search {
    padding: 0.7rem 0.85rem;
    font-size: 1rem;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.catalog__status {
    min-height: 1.3em;
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

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

.tool-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 12px;
}

.tool-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.tool-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.tool-card__link {
    display: block;
    padding: 14px 15px;
    color: inherit;
    height: 100%;
}

.tool-card__link:hover {
    text-decoration: none;
}

.tool-card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.tool-card__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

.tool-card__summary {
    margin: 0.4rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.badge {
    flex: 0 0 auto;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    white-space: nowrap;
}

.empty-state {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 2.25rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state__title {
    margin: 0;
    font-weight: 600;
    color: var(--text);
}

.empty-state__detail {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
}

.privacy-note {
    max-width: 640px;
    margin: 28px 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-footer {
    margin-top: 48px;
    border-top: 1px solid var(--border);
    padding: 20px 0;
}

.site-footer__inner {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px 24px;
    flex-wrap: wrap;
}

.site-footer__note,
.site-footer__meta {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.site-footer__note {
    max-width: 620px;
}

.status {
    margin: 0 0 1em;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    font-size: 0.875rem;
}

.status--info {
    border-left-color: var(--info);
}

.status--success {
    border-left-color: var(--success);
    color: var(--success);
}

.status--error {
    border-left-color: var(--danger);
    color: var(--danger);
}

.tool-header {
    margin-bottom: 20px;
}

.tool-header__title {
    font-size: clamp(1.4rem, 1.1rem + 1.4vw, 1.85rem);
    letter-spacing: -0.02em;
    margin-bottom: 0.2em;
}

.tool-header__summary {
    color: var(--text-muted);
    margin: 0;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.panel + .panel {
    margin-top: 12px;
}

.result,
.output {
    margin: 0;
    padding: 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--text-muted);
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
}

.btn--primary:hover {
    filter: brightness(1.05);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .site-main {
        padding-top: 24px;
    }

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

    .field--category {
        flex-basis: auto;
    }

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

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}
