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

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

body {
    margin: 0;
    background:
        radial-gradient(circle at 90% 5%, var(--theme-canvas-glow) 0, transparent 24rem),
        var(--theme-canvas);
    color: var(--theme-ink);
    font-family: var(--theme-font-sans);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

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

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

:focus-visible {
    outline: 3px solid var(--theme-focus);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -40px;
    z-index: 50;
    background: var(--theme-primary);
    color: var(--theme-on-primary);
    border-radius: 6px;
    padding: 8px 12px;
}

.skip-link:focus {
    top: 12px;
}

.app-shell {
    display: grid;
    grid-template-columns: 244px 1fr;
    min-height: 100dvh;
}

.sidebar {
    background: var(--theme-surface-sunken);
    border-right: 1px solid var(--theme-line);
    padding: 28px 18px 20px;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--theme-ink-strong);
}

.brand-mark {
    width: 36px;
    height: 36px;
}

.brand-dot {
    color: var(--theme-accent);
}

.sidebar-caption {
    color: var(--theme-muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 600;
    margin: 18px 0 28px 4px;
}

.nav-label {
    color: var(--theme-muted);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 600;
    margin: 0 8px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--theme-ink-soft);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--theme-surface-muted);
    color: var(--theme-ink);
}

.nav-item.active {
    background: var(--theme-selected);
    color: var(--theme-primary);
    font-weight: 600;
}

.nav-count {
    margin-left: auto;
    background: var(--theme-surface);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    color: var(--theme-muted);
}

.sidebar-note {
    margin-top: auto;
    color: var(--theme-muted);
    font-size: 13px;
    padding: 16px 8px 0;
}

.workspace {
    padding: 36px 40px 48px;
}

.page-kicker {
    color: var(--theme-muted);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
    margin: 0 0 10px;
}

.page-title {
    margin: 0 0 8px;
    font-size: 34px;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.page-copy {
    margin: 0 0 28px;
    color: var(--theme-ink-soft);
    max-width: 42rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.search {
    flex: 1 1 240px;
    background: var(--theme-control);
    border: 1px solid var(--theme-line-input);
    border-radius: 8px;
    padding: 10px 12px;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-tab {
    background: transparent;
    border: 1px solid var(--theme-line);
    border-radius: 999px;
    padding: 6px 12px;
    color: var(--theme-ink-soft);
}

.category-tab.selected,
.category-tab:hover {
    border-color: var(--theme-primary);
    color: var(--theme-ink);
    background: var(--theme-selected);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.tool-tile {
    display: flex;
    flex-direction: column;
    min-height: 168px;
    background: var(--theme-surface);
    border: 1px solid var(--theme-line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 10px 24px var(--theme-shadow);
}

.tool-tile:hover {
    border-color: var(--theme-primary);
}

.tool-category {
    color: var(--theme-accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.tool-tile h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.tool-tile p {
    margin: 0;
    color: var(--theme-muted);
    flex: 1;
}

.tool-open {
    margin-top: 16px;
    color: var(--theme-primary);
    font-weight: 600;
    font-size: 13px;
}

.empty-state {
    color: var(--theme-muted);
    padding: 24px 0;
}

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

.tool-header a {
    color: var(--theme-primary);
    font-size: 13px;
}

.io-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.io {
    width: 100%;
    min-height: 280px;
    resize: vertical;
    background: var(--theme-control);
    border: 1px solid var(--theme-line-input);
    border-radius: 10px;
    padding: 12px;
    font-family: var(--theme-font-mono);
    font-size: 13px;
    color: var(--theme-ink);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--theme-muted);
    font-size: 13px;
}

.field input,
.field select {
    background: var(--theme-control);
    border: 1px solid var(--theme-line-input);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--theme-ink);
}

.result {
    font-family: var(--theme-font-mono);
    background: var(--theme-surface);
    border: 1px solid var(--theme-line);
    border-radius: 10px;
    padding: 16px 18px;
    font-size: 22px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
}

.button {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    background: var(--theme-surface-muted);
}

.button.primary {
    background: var(--theme-primary);
    color: var(--theme-on-primary);
}

.button.primary:hover {
    background: var(--theme-primary-hover);
}

.banner {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.banner.error {
    background: var(--theme-danger-bg);
    border: 1px solid var(--theme-danger-border);
    color: var(--theme-danger);
}

#blazor-error-ui {
    background: var(--theme-danger-bg);
    color: var(--theme-danger);
    border-top: 1px solid var(--theme-danger-border);
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--theme-line);
    stroke-width: 8;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--theme-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 700;
    inset: calc(20vh + 3.25rem) 0 auto 0;
    color: var(--theme-muted);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--theme-line);
    }

    .workspace {
        padding: 24px 18px 40px;
    }

    .io-panel {
        grid-template-columns: 1fr;
    }
}
