/* Hermes presentation refinement. Existing theme, permissions and actions stay authoritative. */
:root {
    --ui-space-1: 4px;
    --ui-space-2: 8px;
    --ui-space-3: 12px;
    --ui-space-4: 16px;
    --ui-space-6: 24px;
    --ui-space-8: 32px;
    --ui-radius: 8px;
    --ui-radius-small: 5px;
    --ui-text: #e1e7eb;
    --ui-secondary: #b1bec7;
    --ui-meta: #96a7b2;
    --ui-surface: rgba(11, 17, 21, .92);
    --ui-surface-raised: rgba(18, 26, 32, .94);
    --ui-border: rgba(211, 229, 239, .16);
    --ui-readable-body: max(14px, calc(13px * var(--ui-scale-factor, 1)));
    --ui-readable-small: max(12px, calc(11px * var(--ui-scale-factor, 1)));
    --ui-readable-meta: max(12px, calc(10.5px * var(--ui-scale-factor, 1)));
    --ui-readable-heading: clamp(17px, calc(17px * var(--ui-scale-factor, 1)), 22px);
    --ui-readable-title: clamp(24px, calc(24px * var(--ui-scale-factor, 1)), 32px);
    --text-primary: var(--ui-text);
    --text-secondary: var(--ui-secondary);
    --hermes-page-x: clamp(16px, 2.1vw, 32px);
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { color: var(--ui-text); font-size: var(--ui-readable-body); }
*, *::before, *::after { box-sizing: border-box; }
:where(button, a, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
:where(button, summary, a, input, select, textarea) { -webkit-tap-highlight-color: rgba(var(--accent-rgb), .16); }
:where(button, input, select, textarea) { max-width: 100%; }
:where(input, select, textarea) { min-width: 0; }
select, option, optgroup { color: var(--ui-text); background-color: #101a20; color-scheme: dark; }
select:disabled, input:disabled, textarea:disabled { color: var(--ui-secondary); }
button:disabled { cursor: not-allowed; }
.app-shell :is(button, input, select, textarea) { font-size: var(--ui-readable-small); }
.app-shell :is(button, select, input:not([type="range"]):not([type="checkbox"]):not([type="radio"])) { min-height: 40px; }
.app-shell :is(button, select, textarea, input:not([type="range"]):not([type="checkbox"]):not([type="radio"])) { border-radius: var(--ui-radius-small); }
.app-shell :is(p, li, dd) { line-height: 1.6; }
.app-shell :is(.portal-card, .quest-market-panel, .quest-market-detail, .management-panel, .admin-utility-panel) { min-width: 0; }

.portal-heading, .amp-heading { gap: 16px; padding-right: 0; }
.portal-heading h1, .amp-heading h1 { font-size: var(--ui-readable-title) !important; line-height: 1.2; letter-spacing: -.025em; }
.portal-heading p, .amp-heading p { max-width: 76ch; color: var(--ui-secondary); font-size: var(--ui-readable-body) !important; letter-spacing: 0; }
.section-kicker { color: var(--ui-meta); font-size: var(--ui-readable-meta) !important; letter-spacing: .06em; }
.section-kicker > span { color: var(--accent); }
.portal-content, .amp-content { overscroll-behavior: contain; scrollbar-gutter: stable; padding-bottom: max(32px, env(safe-area-inset-bottom)) !important; }
.portal-content :is(h2, h3), .amp-content :is(h2, h3) { line-height: 1.3; }
.portal-grid > *, .portal-content > *, .amp-content > * { min-width: 0; }
.portal-content :is(p, dd, code, .detail-value), .amp-content :is(p, dd, code) { overflow-wrap: anywhere; }
.portal-content :is(pre, textarea), .amp-content :is(pre, textarea) { max-width: 100%; }

/* Keep technical chrome, with readable labels and consistent interactive states. */
.brand-home { flex-shrink: 0; }
.brand-name { letter-spacing: .14em; }
.top-actions { min-width: 0; }
.top-wallet-balances { height: 44px; border-color: var(--ui-border); border-radius: var(--ui-radius-small); }
.top-wallet-balance small { color: var(--ui-meta); letter-spacing: .06em; }
.top-wallet-balance b { font-size: var(--ui-readable-body); }
.top-wallet-balance em { font-size: var(--ui-readable-meta); }
.hermes-site-group, .hermes-site-home, .hermes-site-menu-item { color: var(--ui-secondary); font-size: var(--ui-readable-small); letter-spacing: .04em; }
.hermes-site-group, .hermes-site-home { min-height: var(--hermes-nav-height); }
.hermes-site-menu, .hermes-site-submenu, .menu-panel { border-color: var(--ui-border); border-radius: var(--ui-radius); background: #0b1217; }
.hermes-site-menu-item { min-height: 42px; white-space: normal; line-height: 1.4; padding-block: 9px; }
.hermes-site-menu-item.locked, .hermes-site-menu-item:disabled { opacity: .6; }
.hermes-site-menu-item:hover, .hermes-site-menu-item:focus-visible, .hermes-site-menu-item.active { color: var(--accent); background: rgba(var(--accent-rgb), .08); }
.hermes-site-menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hermes-mobile-nav-heading, .hermes-mobile-utilities, .hermes-nav-backdrop { display: none; }

/* Account and wallet: shared charcoal surfaces rather than stronger neon. */
.hermes-account-summary { gap: 16px; }
.hermes-account-hero { gap: 20px; padding: 24px; border-radius: var(--ui-radius); border-color: var(--ui-border); background: linear-gradient(110deg, rgba(var(--accent-rgb), .055), transparent 55%), var(--ui-surface); }
.hermes-account-identity h2 { overflow-wrap: anywhere; white-space: normal; line-height: 1.2; }
.hermes-account-handle, .hermes-account-kicker, .hermes-account-badge, .hermes-account-side small { color: var(--ui-meta); font-size: var(--ui-readable-meta); letter-spacing: .04em; }
.hermes-account-badge { min-height: 30px; padding: 6px 10px; }
.hermes-account-side p { font-size: var(--ui-readable-small); line-height: 1.5; color: var(--ui-secondary); }
.hermes-account-hero-state small { color: var(--ui-meta); font-size: var(--ui-readable-meta); letter-spacing: .04em; }
.hermes-account-hero-state span { color: var(--ui-secondary); font-size: var(--ui-readable-small); }
.hermes-account-groups { gap: 16px; }
.hermes-account-group { border-color: var(--ui-border); border-radius: var(--ui-radius); background: var(--ui-surface); }
.hermes-account-group > header { gap: 16px; padding: 16px; }
.hermes-account-group > header small { font-size: var(--ui-readable-meta); color: var(--ui-meta); letter-spacing: .06em; }
.hermes-account-group > header b { font-size: var(--ui-readable-heading); color: var(--ui-text); font-weight: 500; letter-spacing: 0; }
.hermes-account-group > header > span { color: var(--ui-secondary); font-size: var(--ui-readable-small); letter-spacing: 0; }
.hermes-account-field { padding: 16px; }
.hermes-account-field small, .hermes-account-footstat small { font-size: var(--ui-readable-meta); letter-spacing: .04em; color: var(--ui-meta); }
.hermes-account-field b { font-size: var(--ui-readable-body); color: var(--ui-text); letter-spacing: 0; }
.hermes-account-field p, .hermes-account-footstat span { font-size: var(--ui-readable-small); color: var(--ui-secondary); letter-spacing: 0; }
.hermes-account-footstrip { border-color: var(--ui-border); border-radius: var(--ui-radius); overflow: hidden; }
.profile-edit-section, .ui-scale-settings, .ui-setting-card { border-color: var(--ui-border); border-radius: var(--ui-radius); }
.profile-edit-section label, .profile-edit-section p, .profile-edit-section small { color: var(--ui-secondary); }
.hermes-currency-body { padding: 16px; }
.hermes-currency-bundle { padding: 20px; gap: 12px; border-radius: var(--ui-radius); border-color: var(--ui-border); background: var(--ui-surface-raised); }
.hermes-currency-bundle h3 { font-size: var(--ui-readable-heading); font-weight: 500; }
.hermes-currency-bundle p, .hermes-currency-support p, .hermes-currency-status { font-size: var(--ui-readable-body); color: var(--ui-secondary); }
.hermes-currency-price { font-size: clamp(24px, 2.4vw, 30px); font-variant-numeric: tabular-nums; }
.hermes-currency-grant { font-size: var(--ui-readable-body) !important; font-weight: 600; }
.hermes-currency-status { border-left: 2px solid var(--accent); padding: 10px 12px; background: rgba(var(--accent-rgb), .04); }
.hermes-currency-muted, .hermes-currency-history, .hermes-currency-admin, .hermes-currency-ledger { font-size: var(--ui-readable-small); color: var(--ui-secondary); }
.hermes-currency-store summary { min-height: 44px; padding: 12px 0; }
.hermes-currency-checkout button:disabled { opacity: 1; color: #9faeb8; background: rgba(0,0,0,.12); border-color: var(--ui-border); }
.hermes-currency-ledger th { color: var(--ui-text); }
.hermes-currency-admin > div { padding-top: 12px; }

/* Catalogue, shop, builder and reusable forms. No prices or action handlers change. */
.store-v2-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 16px; align-items: stretch; }
.store-v2-card { grid-template-rows: 180px minmax(0, 1fr); border-radius: var(--ui-radius); border-color: var(--ui-border); background: var(--ui-surface); }
.store-v2-card-body { padding: 16px; gap: 12px; }
.store-v2-card-heading h3 { font-size: var(--ui-readable-heading); line-height: 1.35; letter-spacing: 0; }
.store-v2-card-heading small, .store-v2-rarity, .store-v2-price span { font-size: var(--ui-readable-meta); color: var(--ui-meta); letter-spacing: .035em; }
.store-v2-description { font-size: var(--ui-readable-body); color: var(--ui-secondary); line-height: 1.6; }
.store-v2-price b { font-size: var(--ui-readable-body); }
.store-v2-card-footer { align-items: center; grid-template-columns: minmax(0,1fr) auto; }
.store-v2-purchase:disabled { color: var(--ui-meta); }
.store-v2-card.equipped { border-color: rgba(var(--accent-rgb), .45); }
.store-v2-card.equipped .store-v2-purchase:disabled { color: var(--accent); }
.store-v2-intro p, .store-v2-controls-copy p, .store-v2-empty span { color: var(--ui-secondary); font-size: var(--ui-readable-small); }
.store-v2-category-nav, .store-v2-links { flex-wrap: wrap; gap: 8px; }
.quest-market-head h2, .dino-builder-main h2 { font-size: var(--ui-readable-heading); }
.quest-market-notice, .dino-builder-feedback { font-size: var(--ui-readable-small); line-height: 1.6; color: var(--ui-secondary); }
.quest-market-detail, .quest-market-panel { border-radius: var(--ui-radius); }
.dino-builder-field { display: grid; gap: 6px; }
.dino-builder-species { height: auto !important; min-height: 90px !important; padding: 12px; align-items: stretch; }
.dino-builder-species > * { width: 100%; align-self: stretch; text-align: left; }
.dino-builder-field > span { font-size: var(--ui-readable-small); color: var(--ui-text); }
.dino-builder-field small, .dino-builder-muted, .dino-builder-breakdown { font-size: var(--ui-readable-small); color: var(--ui-secondary); }
.dino-builder-layout { grid-template-columns: minmax(230px, .65fr) minmax(0, 2fr); gap: 16px; }
.dino-builder-stat-row { font-size: var(--ui-readable-small); }
.dino-builder-color-choice { min-height: 32px; }
.dino-builder-badge { white-space: normal; text-align: right; }
.quest-market-search, .quest-market-category, .profile-edit-section :is(input, select, textarea) { color: var(--ui-text); border-color: var(--ui-border); background: #0d171d; }

/* Shared operational views. Wide tables get a local scroller, not a wider page. */
.fleet-intro p, .fleet-cell small, .fleet-meta, .hermes-stats-intro p, .hermes-stat-card p { color: var(--ui-secondary); }
.fleet-cell, .hermes-instance-stat-row, .hermes-leader-row, .instance-card { min-width: 0; }
.fleet-cell :is(b, span), .selected-server-heading h2 { overflow-wrap: anywhere; }
.hermes-leader-controls label, .hermes-stats-tracking { font-size: var(--ui-readable-small); }
.portal-content table, .amp-content table { max-width: 100%; }
.portal-content th, .amp-content th { color: var(--ui-text); }
.portal-content td, .amp-content td { font-size: var(--ui-readable-small); }
.management-panel, .admin-utility-panel { border-radius: var(--ui-radius); border-color: var(--ui-border); }
.workspace-command, .workspace-tools, .control-actions, .profile-avatar-actions, .community-compose-actions { flex-wrap: wrap; }
.workspace-tabs { min-width: 0; overflow-x: auto; }
.community-message-body, .community-message-text, .community-message-header { min-width: 0; overflow-wrap: anywhere; }
.community-message-text { font-size: var(--ui-readable-body); }
.transcript-log { font-size: var(--ui-readable-body); }
.composer { min-width: 0; }
.composer input { min-width: 0; }
.hermes-repair-console { max-width: 100%; }
.hermes-repair-console .hr-heading, .hr-controls, .hr-pills { min-width: 0; }
.hermes-repair-console .hr-pill { max-width: min(230px, 46vw); }

/* Tablet and phone: one compact header, existing navigation becomes a drawer. */
@media (max-width: 1023px) {
    :root { --hermes-nav-height: 0px !important; --topbar-height: calc(64px + env(safe-area-inset-top)) !important; --hermes-page-x: 16px; }
    .topbar { z-index: 100; padding: env(safe-area-inset-top) 16px 0; height: var(--topbar-height); }
    .brand-mark { width: 46px; height: 36px; }
    .brand-block { gap: 8px; }
    .brand-name { font-size: var(--ui-readable-small); letter-spacing: .1em; }
    .top-actions { gap: 8px; }
    .top-utility-button, .menu-button { width: 44px; height: 44px; min-width: 44px; }
    .top-wallet-balance { min-width: 62px; padding: 5px 8px; }
    .top-wallet-balance b { font-size: 14px; }
    .top-wallet-balance small { font-size: 10px; }
    .top-wallet-balance em { font-size: 11px; }
    .hermes-site-nav.active { display: block; }
    .hermes-site-nav-v2 {
        position: fixed; inset: var(--topbar-height) 0 0 auto; z-index: 95;
        width: min(420px, 100%); height: auto; padding-bottom: env(safe-area-inset-bottom);
        visibility: hidden; transform: translateX(100%); overflow: auto; overscroll-behavior: contain;
        background: #0b1217; border-left: 1px solid var(--ui-border); box-shadow: -12px 0 36px #0006;
        transition: transform .18s ease, visibility .18s ease;
    }
    .hermes-site-nav-v2.is-mobile-open { visibility: visible; transform: translateX(0); }
    .hermes-site-nav-v2 .hermes-site-nav-inner { height: auto; display: flex; flex-direction: column; align-items: stretch; padding: 16px; overflow: visible; }
    .hermes-mobile-nav-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--ui-border); }
    .hermes-mobile-nav-heading strong { font-size: var(--ui-readable-heading); font-weight: 500; }
    .hermes-mobile-nav-heading button { width: 44px; min-height: 44px; font-size: 24px; background: transparent; border: 1px solid var(--ui-border); color: var(--ui-text); }
    .hermes-site-nav-v2 .hermes-site-home { display: flex; margin: 0; padding: 12px; min-height: 48px; justify-content: flex-start; }
    .hermes-site-nav-v2 .hermes-site-groups { display: flex; flex-direction: column; align-items: stretch; width: 100%; }
    .hermes-site-group-wrap { flex-direction: column; border-top: 1px solid rgba(211,229,239,.08); }
    .hermes-site-nav-v2 .hermes-site-group { width: 100%; min-height: 48px; justify-content: flex-start; gap: 10px; padding: 12px; font-size: var(--ui-readable-body); letter-spacing: .035em; }
    .hermes-site-nav-v2 .hermes-site-icon { display: grid; width: 18px; height: 18px; }
    .hermes-site-group-chevron { margin-left: auto; }
    .hermes-site-group.active::after { inset: 10px auto 10px 0; width: 2px; height: auto; }
    .hermes-site-menu, .hermes-site-submenu, .hermes-site-group-wrap.align-right > .hermes-site-menu {
        position: static; inset: auto; width: 100%; max-height: none; border: 0; border-radius: 0; padding: 0 0 8px 12px; margin: 0; box-shadow: none; background: transparent;
    }
    .hermes-site-group-wrap:hover > .hermes-site-menu, .hermes-site-group-wrap:focus-within > .hermes-site-menu,
    .hermes-site-parent-wrap:hover > .hermes-site-submenu, .hermes-site-parent-wrap:focus-within > .hermes-site-submenu { display: none; }
    .hermes-site-group-wrap.open > .hermes-site-menu, .hermes-site-parent-wrap.parent-open > .hermes-site-submenu { display: block; }
    .hermes-site-menu-item { min-height: 44px; font-size: var(--ui-readable-body); letter-spacing: 0; }
    .hermes-site-submenu { padding-left: 12px; border-left: 1px solid rgba(var(--accent-rgb), .3); }
    .hermes-mobile-utilities { display: grid; gap: 12px; padding-top: 16px; margin-top: 12px; border-top: 1px solid var(--ui-border); }
    .hermes-mobile-utilities .top-utility-strip { display: flex; flex-wrap: wrap; gap: 8px; }
    .hermes-mobile-utilities .menu-panel { position: static; inset: auto; width: 100%; max-height: none; display: block; opacity: 1; visibility: visible; transform: none; padding: 0; border: 0; box-shadow: none; background: transparent; }
    .hermes-mobile-utilities .menu-categories { display: none; }
    .hermes-mobile-utilities .menu-identity { padding: 12px; overflow-wrap: anywhere; }
    .hermes-mobile-utilities .menu-utility { padding: 0; }
    .hermes-mobile-utilities .menu-panel button { min-height: 44px; white-space: normal; }
    .hermes-nav-backdrop.is-open { display: block; position: fixed; z-index: 90; inset: var(--topbar-height) 0 0; width: 100%; height: auto; border: 0; border-radius: 0; background: #0009; }
    .top-audio-popup { position: fixed; top: auto; bottom: max(16px, env(safe-area-inset-bottom)); right: 16px; left: 16px; width: auto; max-height: 60dvh; overflow: auto; }
    body:is([data-view="portal"], [data-view="amp"], [data-view="community"]) :is(.portal-view, .amp-view, .community-view) { height: calc(100dvh - var(--topbar-height)); }
    .hermes-account-hero { grid-template-columns: 88px minmax(0,1fr); }
    .hermes-account-avatar { width: 80px; height: 80px; }
    .hermes-account-side, .hermes-account-hero-state { grid-column: 1 / -1; border-left: 0; padding-left: 0; }
    .hermes-account-edit-primary { grid-column: 1 / -1; width: 100%; min-height: 48px; }
    .hermes-account-groups { grid-template-columns: 1fr; }
    .hermes-account-group.game-links { grid-column: auto; }
    .store-v2-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .dino-builder-layout { grid-template-columns: minmax(0,1fr); }
    .dino-builder-catalogue { position: static; }
    .fleet-community-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .community-view { grid-template-columns: minmax(150px,180px) minmax(0,1fr) minmax(140px,170px); }
}

@media (max-width: 639px) {
    :root { --hermes-page-x: 12px; }
    .topbar { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
    .brand-sub { display: none; }
    .brand-mark { width: 36px; height: 32px; }
    .brand-name { font-size: 12px; }
    .brand-block { gap: 6px; }
    .top-actions { gap: 6px; }
    .top-wallet-balance { min-width: 48px; padding-inline: 6px; }
    .top-wallet-balance small { display: none; }
    .top-wallet-balance b { gap: 3px; font-size: 13px; }
    .top-wallet-balance em { font-size: 11px; }
    .top-wallet-balances { max-width: 142px; }
    .top-wallet-balance b > span { max-width: 65px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .portal-content, .amp-content { width: 100% !important; padding-top: 16px !important; scrollbar-gutter: auto; }
    .amp-content { display: block; }
    .amp-content > * { flex-shrink: 0; }
    .amp-heading { display: block; }
    .admin-local-nav { overflow-x: auto; min-height: 44px; }
    .admin-local-nav button { flex: 1 0 auto; white-space: nowrap; }
    .host-strip, .instance-detail { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); height: auto; }
    .host-strip > div, .instance-detail > div { min-width: 0; padding: 12px; overflow-wrap: anywhere; }
    .instance-detail > div:first-child { grid-column: 1 / -1; }
    .instance-toolbar { height: auto; min-height: 44px; }
    .instance-grid { min-height: 130px; }
    .instance-controls { display: grid; grid-template-columns: minmax(0,1fr); }
    .control-caption { min-width: 0; padding: 12px; }
    .admin-maintenance { flex-wrap: wrap; }
    .server-workspace { min-height: 360px; }
    .workspace-tabs { flex-wrap: wrap; }
    .workspace-tabs > span { flex: 1 1 100%; margin-left: 0; padding: 10px; }
    .workspace-panel.active { min-height: 260px; }
    .portal-heading, .amp-heading { flex-direction: column; align-items: flex-start; gap: 12px; padding-bottom: 16px !important; }
    .portal-heading h1, .amp-heading h1 { font-size: 24px !important; }
    .portal-heading p, .amp-heading p { font-size: 14px !important; }
    .portal-content :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), select, textarea),
    .amp-content :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), select, textarea) { font-size: 16px; }
    .app-shell :is(button, select, input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), summary) { min-height: 44px; }
    .portal-grid { grid-template-columns: minmax(0,1fr) !important; }
    .hermes-account-hero { grid-template-columns: 64px minmax(0,1fr); padding: 16px; gap: 12px; }
    .hermes-account-avatar { width: 60px; height: 60px; }
    .hermes-account-identity h2 { font-size: clamp(22px, 7vw, 28px); }
    .hermes-account-kicker { font-size: 11px; letter-spacing: .025em; }
    .hermes-account-badges { gap: 6px; margin-top: 10px; }
    .hermes-account-badge { padding: 5px 7px; font-size: 11px; }
    .hermes-account-hero::after { display: none; }
    .hermes-account-group > header { display: grid; gap: 8px; padding: 16px; }
    .hermes-account-group > header > span { max-width: none; text-align: left; }
    .hermes-account-fields, .hermes-account-group.game-links .hermes-account-fields { grid-template-columns: minmax(0,1fr); }
    .hermes-account-field { border-right: 0 !important; min-height: 0; }
    .hermes-account-footstrip { grid-template-columns: minmax(0,1fr); }
    .hermes-account-footstat { padding: 12px 16px; }
    .hermes-currency-bundles { grid-template-columns: minmax(0,1fr); }
    .hermes-currency-body { padding: 12px; gap: 12px; }
    .hermes-currency-bundle { padding: 16px; }
    .hermes-currency-store .ui-wallet-strip { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .hermes-currency-store .ui-wallet-strip article { padding: 12px; min-width: 0; }
    .hermes-currency-store .ui-wallet-strip article + article { border-left: 1px solid var(--ui-border); }
    .hermes-currency-admin-product { grid-template-columns: minmax(0,1fr); }
    .hermes-currency-history > div { max-width: 100%; }
    .portal-content table, .amp-content table { display: block; overflow-x: auto; overscroll-behavior-x: contain; }
    .portal-content :is(th,td), .amp-content :is(th,td) { min-width: 80px; padding: 10px 8px; }
    .store-v2-grid { grid-template-columns: minmax(0,1fr); gap: 12px; }
    .store-v2-card { grid-template-rows: 180px minmax(0,1fr); }
    .store-v2-card-footer { grid-template-columns: minmax(0,1fr); gap: 12px; }
    .store-v2-purchase { width: 100%; }
    .store-v2-card-heading { flex-wrap: wrap; }
    .store-v2-controls, .store-v2-wallet, .store-v2-intro { grid-template-columns: minmax(0,1fr); gap: 16px; }
    .store-v2-category-nav { justify-content: flex-start; }
    .store-v2-category-nav button { flex: 1 1 auto; }
    .quest-givers, .quest-layout, .quest-market-layout, .quest-market-grid { grid-template-columns: minmax(0,1fr); }
    .quest-detail { padding: 16px 0; border-left: 0; }
    .dino-builder-control-grid, .dino-builder-color-grid { grid-template-columns: minmax(0,1fr); }
    .dino-builder-main .quest-market-head { flex-direction: column; gap: 8px; }
    .dino-builder-badge { text-align: left; }
    .dino-builder-stat-row { grid-template-columns: minmax(68px,.8fr) minmax(0,1fr) 58px; gap: 8px; }
    .dino-builder-stat-row input[type="range"] { min-height: 44px; touch-action: pan-y; }
    .dino-builder-prediction { grid-column: 2 / -1; }
    .dino-builder-species-list { grid-template-columns: minmax(0,1fr); max-height: 240px; }
    .dino-builder-palette { grid-template-columns: repeat(auto-fill,minmax(40px,1fr)); gap: 6px; }
    .dino-builder-color-choice { min-height: 44px; height: 44px; }
    .dino-builder-actions > button { flex: 1 1 120px; }
    .dino-builder .quest-market-actions { flex-wrap: wrap; }
    .fleet-intro, .hermes-stats-intro { display: grid; gap: 12px; }
    .fleet-community-grid, .hermes-stat-summary, .hermes-leader-controls { grid-template-columns: minmax(0,1fr); }
    .hermes-instance-stat-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .hermes-leader-row { grid-template-columns: 36px minmax(0,1fr) auto; }
    .hermes-leader-identity, .hermes-leader-result { min-width: 0; overflow-wrap: anywhere; }
    .hermes-instance-metric { min-width: 0; padding-left: 12px; }
    .selected-server-heading, .instance-toolbar { flex-wrap: wrap; gap: 12px; }
    .control-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
    .workspace-command { display: flex; }
    .workspace-command input { flex: 1 1 100%; }
    .workspace-tools { gap: 8px; }
    .community-view { grid-template-columns: minmax(0,1fr); }
    .community-channel-rail { display: block; width: 100%; max-height: 180px; overflow: auto; border-right: 0; border-bottom: 1px solid var(--ui-border); }
    .community-stage { min-width: 0; min-height: 0; }
    .community-channel-heading { flex-wrap: wrap; gap: 8px; }
    .community-channel-heading { padding-right: 0; }
    .community-channel-heading p { max-width: 100%; white-space: normal; }
    .community-heading-actions { position: static; display: flex; flex-wrap: wrap; }
    .community-message { padding-right: 0 !important; }
    .community-message-body { grid-template-columns: minmax(0,1fr) auto; }
    .community-message-meta b { white-space: normal; overflow-wrap: anywhere; }
    .community-message-meta span { font-size: 11px !important; color: var(--ui-meta) !important; }
    .community-message-copy { grid-column: 1 / -1; margin-top: 6px !important; font-size: 14px !important; }
    .community-message-tools { position: static !important; opacity: 1; grid-column: 1 / -1; display: flex; flex-wrap: wrap !important; max-width: 100%; justify-content: flex-start; }
    .community-message-tools button { width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; }
    .community-message-tools button:focus-visible { outline: 2px solid var(--accent) !important; }
    .community-compose { min-width: 0; }
    .community-drawer { max-width: 100%; }
    .assistant-view { top: var(--topbar-height); height: calc(100dvh - var(--topbar-height)); padding: 16px 12px max(16px,env(safe-area-inset-bottom)); grid-template-columns: minmax(0,1fr); }
    .conversation-panel { width: 100%; height: 100%; min-height: 0; padding: 0; }
    .transcript-log { min-height: 0; }
    .composer { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; padding-top: 12px; }
    .composer #textInput { grid-column: 1 / -1; width: 100%; font-size: 16px; }
    .composer .hermes-quick-input-shell { grid-column: 1 / -1; min-width: 0; width: 100%; }
    .composer .hermes-quick-input-shell #textInput { min-width: 0; width: 100%; font-size: 16px; }
    .assistant-turn-status { grid-column: 1 / -1; }
    .relay-copy { display: none; }
    body[data-view="assistant"] .ring-dock { opacity: .1; pointer-events: none; z-index: 0; }
    .hermes-repair-overlay { padding: 6px; }
    .hermes-repair-console { height: calc(100dvh - 12px); }
    .hr-controls button { min-height: 44px; }
    .hermes-repair-console .hr-pills { gap: 6px; }
    .hermes-repair-console .hr-pill { max-width: 43vw; white-space: nowrap; }
    .hr-heading #hr-connection { margin-left: 0; display: block; }
    .hermes-service-notice-card { max-height: calc(100dvh - 32px); overflow-y: auto; }
    .cosmetic-background-layer { background-attachment: scroll; background-position: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .cosmetic-particle-layer { display: none; }
}


/* Admin instance artwork: retain the whole image even in short viewports. */
.amp-content > .instance-grid {
    flex: 0 0 auto;
    align-items: flex-start;
    height: auto;
    max-height: none;
    gap: 14px;
    padding: 9px 4px 20px;
}

.instance-grid .instance-card {
    flex: 1 0 150.5px;
    max-width: 206.5px;
    height: auto;
    opacity: 1;
    filter: none;
}

.instance-grid .instance-card-copy { padding-top: 9px; }
.instance-grid .instance-card-copy b { font-size: 17.5px; }
.instance-grid .instance-card-copy small { margin-top: 5px; font-size: 14px; }
.instance-grid .instance-card .instance-status {
    right: 7px;
    bottom: 7px;
    padding: 5px 7px;
    font-size: 12px;
}

.instance-grid .instance-card .instance-card-art-wrap {
    height: auto;
    opacity: 1;
    filter: saturate(.92) brightness(.96);
}

.instance-grid .instance-card-art {
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    object-fit: contain;
}

.instance-grid .instance-card:hover .instance-card-art-wrap {
    opacity: 1;
    filter: saturate(.98) brightness(.99);
}

.instance-grid .instance-card.selected .instance-card-art-wrap {
    opacity: 1;
    filter: none;
}


/* Server Overview: larger square artwork with gentle inactive colours. */
.hermes-fleet-overview { --fleet-art-size: 96px; }

.hermes-fleet-overview .fleet-row {
    min-height: 112px;
    padding-block: 8px;
}

.hermes-fleet-overview .fleet-server {
    min-height: var(--fleet-art-size);
    padding-left: 0;
    gap: 14px;
}

.hermes-fleet-overview .fleet-server-art {
    position: static;
    flex: 0 0 var(--fleet-art-size);
    width: var(--fleet-art-size);
    height: var(--fleet-art-size);
    max-height: none;
    aspect-ratio: 1;
    object-fit: cover;
    object-position: center;
    background: #101315;
    opacity: 1;
    filter: saturate(.92) brightness(.96);
}

.hermes-fleet-overview .fleet-server-copy { flex: 1 1 auto; }

.hermes-fleet-overview .fleet-row:hover .fleet-server-art,
.hermes-fleet-overview .fleet-row:focus-visible .fleet-server-art {
    opacity: 1;
    filter: saturate(.98) brightness(.99);
}

.hermes-fleet-overview .fleet-row[aria-expanded="true"] .fleet-server-art {
    opacity: 1;
    filter: none;
}

@media (max-width: 820px) {
    .hermes-fleet-overview { --fleet-art-size: 90px; }
    .hermes-fleet-overview .fleet-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 26px;
        grid-template-areas:
            "server server chevron"
            "state players chevron"
            "ping uptime chevron"
            "restart restart chevron";
    }
}


/* Admin carousel: constrain the viewport and expose mouse navigation. */
.amp-content { min-width: 0; }
.amp-content > .instance-grid {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    touch-action: auto;
    cursor: grab;
}
.instance-grid .instance-card-art { user-select: none; -webkit-user-drag: none; }
.instance-grid.is-dragging { scroll-snap-type: none; }
.instance-grid.is-dragging, .instance-grid.is-dragging * {
    cursor: grabbing !important;
    user-select: none;
}
.instance-grid:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.amp-content .instance-toolbar { height: auto; flex-wrap: wrap; gap: 12px; }
.instance-carousel-controls { display: inline-flex; flex: 0 0 auto; gap: 6px; margin-left: auto; }
.instance-carousel-controls[hidden] { display: none; }
.instance-carousel-controls button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(var(--accent-rgb), .25);
    background: rgba(var(--accent-rgb), .035);
    color: var(--accent);
    font: 24px/1 "Segoe UI", sans-serif;
    cursor: pointer;
}
.instance-carousel-controls button:hover:not(:disabled),
.instance-carousel-controls button:focus-visible {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), .09);
}
.instance-carousel-controls button:disabled { cursor: default; }
