:host {
    display: block;
    min-height: 100vh;
}

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

body {
    background: #0f172a;
}

/* ── Design Token Layer ─────────────────────────────────────────────────── */
.app-shell {
    /* Colors — surface */
    --c-canvas:          #FFFFFF;
    --c-surface-soft:    #F5F6F7;
    --c-hairline:        #D8DADF;
    --c-hairline-soft:   rgba(10, 19, 23, 0.12);

    /* Colors — text */
    --c-ink-deep:        #0A1317;
    --c-ink:             #1C2B33;
    --c-ink-button:      #1C1C1C;
    --c-on-ink-button:   #FFFFFF;
    --c-charcoal:        #606770;
    --c-slate:           #90949C;
    --c-steel:           #BEC3C9;
    --c-stone:           #DADDE1;

    /* Colors — brand/accent */
    --c-primary:         #0064E0;
    --c-primary-deep:    #0143B5;
    --c-primary-soft:    rgba(0, 100, 224, 0.15);
    --c-on-primary:      #FFFFFF;

    /* Colors — semantic */
    --c-success:         #25A244;
    --c-warning:         #FFD700;
    --c-attention:       #E37D00;
    --c-critical:        #D92D20;

    /* Radius */
    --r-xs:     2px;
    --r-sm:     4px;
    --r-md:     6px;
    --r-lg:     8px;
    --r-xl:     16px;
    --r-xxl:    24px;
    --r-xxxl:   32px;
    --r-feature: 40px;
    --r-full:   100px;
    --r-circle: 50%;

    /* Spacing */
    --sp-xxs:        4px;
    --sp-xs:         8px;
    --sp-sm:         10px;
    --sp-md:         12px;
    --sp-base:       16px;
    --sp-lg:         20px;
    --sp-xl:         24px;
    --sp-xxl:        32px;
    --sp-xxxl:       40px;
    --sp-section-sm: 48px;
    --sp-section:    64px;
    --sp-section-lg: 80px;
    --sp-hero:       120px;

    /* Elevation */
    --shadow-0: none;
    --shadow-1: rgba(0, 0, 0, 0.2) 1px 1px 0px 0px;
    --shadow-2: rgba(20, 22, 26, 0.3) 0px 1px 4px 0px;

    /* Semantic aliases */
    --bg:             var(--c-canvas);
    --bg-soft:        var(--c-surface-soft);
    --text:           var(--c-ink);
    --text-heading:   var(--c-ink-deep);
    --text-secondary: var(--c-charcoal);
    --text-tertiary:  var(--c-slate);
    --border:         var(--c-hairline);
    --border-soft:    var(--c-hairline-soft);

    scrollbar-gutter: stable;
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Optimistic VF", "Montserrat", "Inter", -apple-system, BlinkMacSystemFont,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    font-size: 16px;
    line-height: 1.50;
    letter-spacing: -0.16px;
    font-feature-settings: "ss01", "ss02";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.18s ease, color 0.18s ease;
}

* {
    box-sizing: border-box;
}

/* Dark theme — supplemental token overrides */
.app-shell[data-theme="dark"] {
    --bg:             #0F172A;
    --bg-soft:        #1E293B;
    --c-canvas:       #1E293B;
    --c-surface-soft: #162033;
    --text:           #E2E8F0;
    --text-heading:   #F8FAFC;
    --text-secondary: #94A3B8;
    --text-tertiary:  #64748B;
    --border:         #334155;
    --border-soft:    rgba(255, 255, 255, 0.12);
    --c-ink-deep:     #F8FAFC;
    --c-ink:          #E2E8F0;
    --c-charcoal:     #94A3B8;
    --c-slate:        #64748B;
    --c-steel:        #475569;
    --c-stone:        #334155;
    --c-hairline:     #334155;
    --c-hairline-soft: rgba(255, 255, 255, 0.12);
    --shadow-2:       rgba(2, 6, 23, 0.4) 0px 1px 6px 0px;
}

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

button {
    font: inherit;
    color: inherit;
}

[hidden] {
    display: none !important;
}

/* ── Top Navigation ─────────────────────────────────────────────────────── */
.app {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-base);
    padding: 0 var(--sp-xxl);
    height: 64px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-lg);
    background: var(--c-ink-button);
    color: var(--c-on-ink-button);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    flex: 0 0 auto;
}

.brand-copy {
    min-width: 0;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.16px;
    color: var(--text-heading);
    white-space: nowrap;
}

.brand-tag {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 var(--sp-xs);
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.33;
}

.brand-hint {
    margin: 2px 0 0;
    color: var(--text-tertiary);
    font-size: 12px;
    line-height: 1.33;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    flex: 0 0 auto;
}

/* Pill-tab style buttons (lang / theme toggles) */
.top-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 48px;
    flex: 0 0 48px;
    height: 32px;
    padding: 0;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.14px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.top-action:active {
    background: var(--c-ink-deep);
    border-color: var(--c-ink-deep);
    color: var(--c-canvas);
}

.top-action:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ── Page Layout ─────────────────────────────────────────────────────────── */
.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--sp-section-sm) var(--sp-xxl) var(--sp-section);
}

/* ── Panels (card-product-feature pattern) ───────────────────────────────── */
.panel {
    background: var(--c-canvas);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    padding: var(--sp-xxl);
}

.app-shell[data-theme="dark"] .panel {
    background: var(--bg-soft);
}

.panel + .panel {
    margin-top: var(--sp-xxl);
}

/* ── Overview ─────────────────────────────────────────────────────────────── */
.overview {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-xl);
    flex-wrap: wrap;
}

.overview-copy {
    min-width: 0;
    flex: 1 1 420px;
}

/* heading-lg: 36px / 500 / 1.28 / ss01 ss02 */
.page-title {
    margin: 0;
    font-size: clamp(28px, 3.5vw, 36px);
    font-weight: 500;
    line-height: 1.28;
    letter-spacing: 0;
    font-feature-settings: "ss01", "ss02";
    color: var(--text-heading);
}

/* subtitle-md: 18px / 400 / 1.44 */
.page-subtitle {
    margin: var(--sp-sm) 0 0;
    max-width: 640px;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.44;
    letter-spacing: 0;
    color: var(--text-secondary);
}

/* badge-success used as device status indicator */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-xs);
    height: 40px;
    padding: 0 var(--sp-base);
    border-radius: var(--r-full);
    background: rgba(37, 162, 68, 0.12);
    color: var(--c-success);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.14px;
    line-height: 1.43;
    flex: 0 0 auto;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--r-circle);
    background: var(--c-success);
}

/* ── Section Header ───────────────────────────────────────────────────────── */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
    margin-bottom: var(--sp-xl);
    flex-wrap: wrap;
}

/* heading-sm: 24px / 500 / 1.25 / ss01 ss02 */
.section-title {
    margin: 0;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: 0;
    font-feature-settings: "ss01", "ss02";
    color: var(--text-heading);
}

/* body-sm: 14px / 400 / 1.43 */
.section-note {
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.43;
    letter-spacing: -0.14px;
}

/* ── Card Grids ───────────────────────────────────────────────────────────── */
.recommended-grid,
.client-grid,
.site-grid,
.notice-grid {
    display: grid;
    gap: var(--sp-xl);
}

.client-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.site-grid,
.notice-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ── Entry Cards (card-icon-feature pattern) ──────────────────────────────── */
.entry-card {
    background: var(--c-canvas);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-xl);
    padding: var(--sp-xl);
    display: flex;
    flex-direction: column;
}

.entry-card.site-card {
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.entry-card.site-card .entry-description {
    margin-bottom: 0;
}

.entry-card.recommended {
    background: rgba(0, 100, 224, 0.04);
    border-color: rgba(0, 100, 224, 0.24);
}

.app-shell[data-theme="dark"] .entry-card {
    background: var(--bg-soft);
}

.app-shell[data-theme="dark"] .entry-card.recommended {
    background: rgba(0, 100, 224, 0.08);
    border-color: rgba(0, 100, 224, 0.32);
}

.entry-card.site-card:hover,
.entry-card.site-card:focus-visible {
    background: var(--c-ink-button);
    border-color: var(--c-ink-button);
    color: var(--c-on-ink-button);
    transform: translateY(-2px);
}

.entry-card.site-card:hover .entry-title,
.entry-card.site-card:hover .entry-description,
.entry-card.site-card:hover .badge,
.entry-card.site-card:focus-visible .entry-title,
.entry-card.site-card:focus-visible .entry-description,
.entry-card.site-card:focus-visible .badge {
    color: var(--c-on-ink-button);
}

.entry-card.site-card:hover .entry-icon,
.entry-card.site-card:focus-visible .entry-icon {
    background: rgba(255, 255, 255, 0.16);
    color: var(--c-on-ink-button);
}

.entry-card.site-card:hover .badge,
.entry-card.site-card:focus-visible .badge {
    background: rgba(255, 255, 255, 0.16);
}

.entry-card.site-card:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

.entry-card.notice-card {
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.entry-card.notice-card:hover {
    background: var(--c-ink-button);
    border-color: var(--c-ink-button);
    color: var(--c-on-ink-button);
    transform: translateY(-2px);
}

.entry-card.notice-card:hover .entry-title,
.entry-card.notice-card:hover .entry-description,
.entry-card.notice-card:hover .badge {
    color: var(--c-on-ink-button);
}

.entry-card.notice-card:hover .entry-icon {
    background: rgba(255, 255, 255, 0.16);
    color: var(--c-on-ink-button);
}

.entry-card.notice-card:hover .badge {
    background: rgba(255, 255, 255, 0.16);
}

.entry-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-md);
    margin-bottom: var(--sp-md);
}

.entry-title-wrap {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    min-width: 0;
}

.entry-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-lg);
    background: var(--bg-soft);
    font-size: 18px;
    flex: 0 0 auto;
}

/* subtitle-lg: 18px / 700 / 1.44 */
.entry-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.44;
    letter-spacing: 0;
    color: var(--text-heading);
}

/* body-sm: 14px / 400 / 1.43 */
.entry-description {
    margin: 0 0 var(--sp-xl);
    flex: 1;
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: -0.14px;
    color: var(--text-secondary);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
/* caption-bold: 12px / 700 / 1.33 */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px var(--sp-sm);
    border-radius: var(--r-full);
    background: var(--bg-soft);
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.33;
    white-space: nowrap;
    flex: 0 0 auto;
}

.badge.badge-success {
    background: rgba(37, 162, 68, 0.12);
    color: var(--c-success);
}

.badge.badge-warning {
    background: var(--c-warning);
    color: var(--c-ink-deep);
}

.badge.badge-attention {
    background: var(--c-attention);
    color: #FFFFFF;
}

/* ── Button Row ───────────────────────────────────────────────────────────── */
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-xs);
    margin-top: auto;
}

/* ── button-primary: black pill for marketing CTAs ────────────────────────── */
/* button-md: 14px / 700 / 1.43 / -0.14px */
.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 14px var(--sp-xl);
    border-radius: var(--r-full);
    border: 1px solid transparent;
    background: var(--c-ink-button);
    color: var(--c-on-ink-button);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.14px;
    line-height: 1.43;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.action-button:hover,
.action-button:focus-visible {
    background: var(--c-on-ink-button);
    border-color: var(--c-ink-button);
    color: var(--c-ink-button);
    transform: translateY(-1px);
}

.action-button:active {
    background: var(--c-charcoal);
    border-color: var(--c-charcoal);
    color: var(--c-on-ink-button);
    transform: translateY(0);
}

.action-button:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ── toggle-button: ghost outline variant ─────────────────────────────────── */
.toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px var(--sp-xl);
    border-radius: var(--r-full);
    border: 2px solid var(--border-soft);
    background: transparent;
    color: var(--text-heading);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.14px;
    line-height: 1.43;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.toggle-button:hover,
.toggle-button:focus-visible {
    background: var(--c-ink-button);
    border-color: var(--c-ink-button);
    color: var(--c-on-ink-button);
    transform: translateY(-1px);
}

.toggle-button:active {
    background: var(--c-charcoal);
    border-color: var(--c-charcoal);
    color: var(--c-on-ink-button);
    transform: translateY(0);
}

.toggle-button:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

.toggle-row {
    display: flex;
    justify-content: center;
    margin-top: var(--sp-xl);
}

/* ── Collapsible Panel ────────────────────────────────────────────────────── */
.collapsible-panel {
    margin-top: 0;
    padding-top: 0;
    padding-bottom: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    border-color: transparent;
    transition: max-height 0.28s ease, opacity 0.22s ease, transform 0.28s ease,
        padding 0.28s ease, margin-top 0.28s ease, border-color 0.2s ease;
    will-change: max-height, opacity, transform;
}

.collapsible-panel.is-open {
    margin-top: var(--sp-xxl);
    padding-top: var(--sp-xxl);
    padding-bottom: var(--sp-xxl);
    max-height: 2400px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    border-color: var(--border-soft);
    box-shadow: var(--shadow-2);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
/* caption: 12px / 400 / 1.33 */
.footer {
    margin-top: var(--sp-xxl);
    padding-top: var(--sp-xxl);
    border-top: 1px solid var(--border-soft);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.33;
    letter-spacing: 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
/* Tablet: 768–1023px */
@media (max-width: 1023px) {
    .topbar {
        padding: 0 var(--sp-xl);
    }

    .page {
        padding: var(--sp-xl) var(--sp-xl) var(--sp-section-sm);
    }
}

/* Mobile: <768px */
@media (max-width: 767px) {
    .topbar {
        padding: 0 var(--sp-base);
        height: 56px;
    }

    .page {
        padding: var(--sp-xl) var(--sp-base) var(--sp-xxl);
    }

    .panel {
        padding: var(--sp-xl);
    }

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

    .site-grid,
    .notice-grid {
        grid-template-columns: 1fr;
    }

    .status-chip {
        width: 100%;
        justify-content: flex-start;
    }

    .page-subtitle {
        font-size: 16px;
    }

    .section-title {
        font-size: 20px;
    }

    .collapsible-panel.is-open {
        padding-top: var(--sp-xl);
        padding-bottom: var(--sp-xl);
    }

    .toggle-button {
        width: 100%;
    }
}

/* Small mobile: <480px */
@media (max-width: 479px) {
    .page-title {
        font-size: 24px;
    }

    .page-subtitle {
        font-size: 14px;
    }
}
