:root {
    color-scheme: light;
    --page-bg: #f5f5f5;
    --surface: #ffffff;
    --surface-subtle: #fafafa;
    --surface-muted: #f3f2f1;
    --text: #242424;
    --text-muted: #616161;
    --text-subtle: #707070;
    --border: #d1d1d1;
    --border-strong: #bdbdbd;
    --accent: #0f6cbd;
    --accent-strong: #115ea3;
    --accent-tint: #ebf3fc;
    --navbar-bg: var(--accent);
    --navbar-height: 48px;
    --code-bg: #1f1f1f;
    --code-text: #f5f5f5;
    --danger: #b10e1c;
    --radius: 6px;
    --content-width: min(1220px, calc(100% - 48px));
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    min-width: 768px;
}

body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--page-bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

button,
input,
fluent-button,
fluent-text-input {
    font: inherit;
}

.site-header {
    flex: 0 0 var(--navbar-height);
    background: var(--navbar-bg);
    color: #ffffff;
}

.page {
    width: 100%;
    margin: 0;
}

.header-inner {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(280px, 560px) minmax(80px, 1fr);
    align-items: center;
    gap: 16px;
    width: 100%;
    height: var(--navbar-height);
    padding: 0 24px;
}

.title-block {
    min-width: 0;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: #ffffff;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0;
    text-decoration: none;
}

.navbar-brand:hover {
    opacity: 0.9;
}

.navbar-brand-logo {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.navbar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navbar-center {
    display: flex;
    justify-content: center;
    min-width: 0;
}

.navbar-search {
    width: 100%;
    max-width: 560px;
}

.summary {
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8125rem;
    white-space: nowrap;
    text-align: right;
}

#visible-count {
    display: inline;
    color: #ffffff;
    font-size: 1rem;
    line-height: 1;
    font-weight: 650;
}

.summary-muted {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.8125rem;
}

.page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 0 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.toolbar {
    flex: 0 0 auto;
    display: grid;
    position: sticky;
    top: 0;
    z-index: 10;
    width: var(--content-width);
    padding: 12px 16px;
    margin: 0 auto 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.search-input {
    width: 100%;
    max-width: none;
}

.platform-filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 34px;
    padding-top: 2px;
}

.filter-label {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.platform-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.platform-filter {
    min-width: 72px;
}

.status {
    flex: 0 0 auto;
    display: none;
    width: var(--content-width);
    margin: 12px auto 16px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-muted);
}

.status.is-visible {
    display: block;
}

.status.is-error {
    border-color: #eeacb2;
    color: var(--danger);
}

.script-list {
    flex: 0 0 auto;
    min-height: 0;
    display: grid;
    gap: 12px;
    align-content: start;
    overflow: visible;
    padding: 0 0 48px;
}

.script-card {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.25fr);
    gap: 24px;
    width: var(--content-width);
    margin: 0 auto;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    outline: none;
}

.script-card:hover,
.script-card:focus-visible {
    border-color: var(--border-strong);
}

.script-card-main {
    min-width: 0;
}

.script-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.script-name {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--text);
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 1.02rem;
    line-height: 1.35;
    font-weight: 700;
}

.script-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
    min-width: 0;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    background: var(--surface-subtle);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.meta-chip.is-admin {
    border-color: #eeacb2;
    color: var(--danger);
    background: #fdf3f4;
}

.script-description {
    margin: 0 0 14px;
    color: var(--text);
}

.script-detail {
    display: grid;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.detail-row {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
}

.detail-label {
    color: var(--text);
    font-weight: 600;
}

.detail-text {
    margin: 0;
}

.detail-list {
    margin: 0;
    padding-left: 18px;
}

.usage-list {
    display: grid;
    gap: 10px;
    align-content: start;
    min-width: 0;
}

.usage-item {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.usage-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    padding: 7px 8px 7px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
}

.usage-title {
    min-width: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.copy-button {
    flex: 0 0 auto;
}

.command-block {
    margin: 0;
    padding: 14px;
    overflow-x: auto;
    background: var(--code-bg);
    color: var(--code-text);
    font-family: "Cascadia Mono", "Consolas", "Courier New", monospace;
    font-size: 0.86rem;
    line-height: 1.55;
}

.command-block code {
    white-space: pre;
}

@media (max-width: 1040px) {
    .script-card {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    :root {
        --content-width: min(100% - 32px, 1220px);
    }

    .header-inner {
        grid-template-columns: minmax(176px, 1fr) minmax(260px, 1.25fr) auto;
        gap: 16px;
        padding: 0 16px;
    }

    .toolbar {
        padding: 14px;
    }

    .script-card {
        padding: 18px;
    }
}
