:root {
  color-scheme: dark;
  --page: #101113;
  --surface: #191b1f;
  --surface-raised: #22252a;
  --border: #383d45;
  --text: #f4f1e8;
  --muted: #a8adb5;
  --red: #b4232f;
  --red-hover: #d13442;
  --gold: #d6a84a;
  --green: #3fa56b;
  --focus: #f0c96b;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

/* Preset themes change the visual language only; tenant content and behavior stay identical. */
body.template-tech {
  --page: #071522;
  --surface: #0d2234;
  --surface-raised: #14334a;
  --border: #25506a;
  --text: #e6f4ff;
  --muted: #91b1c5;
  --red: #147eae;
  --red-hover: #1b9acb;
  --gold: #63d4ff;
  --green: #55c7a0;
  --focus: #66d8ff;
}
body.template-royal {
  --page: #180d12;
  --surface: #271318;
  --surface-raised: #381a21;
  --border: #6a3131;
  --text: #fff3dc;
  --muted: #c8a9a1;
  --red: #c53645;
  --red-hover: #e3525f;
  --gold: #efb94b;
  --green: #68c38d;
  --focus: #ffd66d;
}
body.template-portal {
  --page: #101820;
  --surface: #18232d;
  --surface-raised: #22313d;
  --border: #3b5665;
  --text: #f3f7f8;
  --muted: #a9bbc3;
  --red: #bf5b35;
  --red-hover: #d8754b;
  --gold: #f0c46a;
  --green: #62bd92;
  --focus: #f3d18b;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--text); }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(240, 201, 107, .32); outline-offset: 2px; }

.topbar { height: 72px; border-bottom: 1px solid #4a3a24; background: #151619; }
.topbar-inner { width: min(1180px, calc(100% - 32px)); height: 100%; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; color: var(--text); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; overflow: hidden; border: 1px solid #6d542a; border-radius: 6px; background: #202226; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; }
.member-actions, .member-profile { display: flex; align-items: center; gap: 10px; }
.member-profile { min-width: 0; }
.member-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.member-level { padding: 4px 8px; border: 1px solid #6f572c; border-radius: 999px; color: #f1ca72; font-size: 12px; white-space: nowrap; }

.button { min-height: 40px; padding: 0 17px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-raised); color: var(--text); cursor: pointer; transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
.button:hover { border-color: #69717c; background: #2a2e34; }
.button-primary { border-color: #d04b56; background: var(--red); color: #fff; font-weight: 700; }
.button-primary:hover { border-color: #e06a74; background: var(--red-hover); }
.button-quiet { background: transparent; }
.button-wide { width: 100%; margin-top: 4px; }
.button:disabled { border-color: #4d5259; background: #303238; color: #c2c4c8; cursor: wait; }

.ticker { width: min(1180px, calc(100% - 32px)); height: 48px; margin: 24px auto 0; display: flex; align-items: stretch; overflow: hidden; border: 1px solid #51442e; border-radius: 6px; background: #1a1b1e; }
.ticker-label { width: 74px; flex: 0 0 74px; display: grid; place-items: center; background: #5f1c24; color: #fff; font-weight: 800; }
.ticker-window { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.ticker-track { width: max-content; min-width: 100%; height: 100%; display: flex; align-items: center; gap: 54px; padding-left: 28px; color: #e7d8b8; white-space: nowrap; animation: ticker-move 30s linear infinite; }
.ticker-track a { color: inherit; text-decoration: none; }
.ticker-track a:hover { color: #fff; }
@keyframes ticker-move { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.page-content { width: min(1180px, calc(100% - 32px)); min-height: calc(100vh - 248px); margin: 36px auto 52px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 15px; border-bottom: 1px solid #34373d; }
.section-heading h1 { margin: 3px 0 0; font-size: 28px; line-height: 1.2; }
.section-kicker, .dialog-eyebrow { margin: 0; color: var(--gold); font: 700 12px/1.4 "Segoe UI", sans-serif; }
.server-count { color: var(--muted); font-size: 14px; white-space: nowrap; }

.server-grid { display: grid; grid-template-columns: repeat(auto-fill, 320px); justify-content: center; gap: 22px; }
.server-card { width: 320px; height: 410px; display: grid; grid-template-rows: 180px 1fr; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 14px 35px rgba(0, 0, 0, .18); }
.server-cover { position: relative; overflow: hidden; border-bottom: 1px solid var(--border); background: #26292e; }
.server-cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
.server-cover::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: var(--red); }
.server-body { min-height: 0; display: flex; flex-direction: column; padding: 18px; }
.server-title-row { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.server-title { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; }
.server-status { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; color: #9ce2b7; font-size: 12px; }
.server-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(63, 165, 107, .16); }
.server-subtitle { min-height: 22px; margin: 7px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d6bd88; font-size: 14px; }
.server-description { height: 44px; margin: 10px 0 0; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 22px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.server-tags { min-height: 28px; display: flex; align-items: center; gap: 6px; margin-top: 10px; overflow: hidden; }
.server-tag { flex: 0 0 auto; padding: 3px 7px; border: 1px solid #51452f; border-radius: 4px; color: #d9c28f; font-size: 11px; }
.server-link { min-height: 40px; margin-top: auto; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d04b56; border-radius: 6px; background: var(--red); color: #fff; text-decoration: none; font-weight: 800; transition: background-color .16s ease; }
.server-link:hover { background: var(--red-hover); }
.server-link.disabled { border-color: #4d5259; background: #303238; color: #c2c4c8; pointer-events: none; }

.empty-state { min-height: 260px; display: grid; place-content: center; justify-items: center; gap: 7px; border: 1px dashed #4a4e55; border-radius: 8px; color: var(--muted); }
.empty-state strong { color: var(--text); font-size: 18px; }
.site-footer { min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 18px; border-top: 1px solid #303238; color: #7f858e; font-size: 13px; }

.auth-dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid #52565e; border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .48); }
.auth-dialog::backdrop { background: rgba(0, 0, 0, .72); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 24px 24px 18px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 4px 0 0; font-size: 24px; }
.icon-button { width: 40px; height: 40px; flex: 0 0 40px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: #25282d; color: #d7d9dc; cursor: pointer; font-size: 26px; line-height: 1; }
.icon-button:hover { border-color: #d04b56; background: #4a1d22; color: #fff; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 18px 24px 0; }
.auth-tab { height: 40px; border: 1px solid var(--border); background: #1b1d21; color: var(--muted); cursor: pointer; }
.auth-tab:first-child { border-radius: 6px 0 0 6px; }
.auth-tab:last-child { border-radius: 0 6px 6px 0; }
.auth-tab.active { border-color: #b88f40; background: #3f3422; color: #f2d691; font-weight: 700; }
.auth-form { display: grid; gap: 15px; padding: 22px 24px 26px; }
.auth-form label { display: grid; gap: 7px; color: #d9dadd; font-size: 13px; }
.auth-form input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #4b5058; border-radius: 6px; background: #111215; color: #fff; }
.auth-form input::placeholder { color: #7e838c; }
.auth-form input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(240, 201, 107, .16); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; max-width: calc(100vw - 32px); transform: translateX(-50%); padding: 12px 18px; border: 1px solid #656a72; border-radius: 6px; background: #25282d; color: #fff; box-shadow: 0 12px 32px rgba(0, 0, 0, .34); }
.toast.error { border-color: #bf4550; background: #4a1d22; }

.portal-hero { display: none; position: relative; width: min(1180px, calc(100% - 32px)); min-height: 360px; margin: 30px auto 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: 0 18px 42px rgba(0, 0, 0, .24); }
.portal-hero-media, .portal-hero-media img { position: absolute; inset: 0; width: 100%; height: 100%; }
.portal-hero-media img { display: block; object-fit: cover; }
.portal-hero-media::after { content: ""; position: absolute; inset: 0; background: rgba(7, 13, 18, .48); }
.portal-hero-content { position: relative; z-index: 1; width: min(600px, 100%); min-height: 360px; display: flex; flex-direction: column; justify-content: center; padding: 44px 52px; background: rgba(12, 20, 26, .72); }
.portal-hero-kicker { margin: 0 0 10px; color: var(--gold); font: 700 12px/1.4 "Segoe UI", sans-serif; letter-spacing: 1.4px; }
.portal-hero-content h1 { margin: 0; color: #fff; font-size: 44px; line-height: 1.15; }
.portal-hero-content p:not(.portal-hero-kicker) { max-width: 480px; margin: 14px 0 24px; color: #d7e1e5; font-size: 17px; line-height: 1.6; }
.portal-hero-action { width: fit-content; min-height: 42px; display: inline-flex; align-items: center; padding: 0 20px; border: 1px solid var(--gold); border-radius: 6px; background: var(--red); color: #fff; text-decoration: none; font-weight: 800; }
.portal-hero-action:hover { background: var(--red-hover); }
.template-portal .portal-hero { display: block; }
.template-portal .topbar { border-color: #3f5662; background: #111c24; }
.template-portal .brand-mark { border-color: #536e7a; background: #263640; }
.template-portal .ticker { border-color: #53616a; background: #1b2831; }
.template-portal .ticker-label { background: #8f4e32; }
.template-portal .ticker-track { color: #f1d69c; }
.template-portal .section-heading { border-color: #435762; }
.template-portal .server-grid { grid-template-columns: repeat(auto-fill, 320px); justify-content: center; }
.template-portal .server-card { width: 320px; height: 400px; }
.template-portal .server-cover::after { background: var(--gold); }
.template-portal .server-link { border-color: #d07049; background: var(--red); }
.template-portal .server-link:hover { background: var(--red-hover); }

@media (max-width: 620px) {
  .topbar { height: 64px; }
  .topbar-inner, .ticker, .page-content { width: calc(100% - 24px); }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .brand strong { max-width: 128px; font-size: 16px; }
  .member-level { display: none; }
  .member-name { max-width: 92px; }
  .button { padding: 0 13px; }
  .ticker { margin-top: 16px; }
  .ticker-label { width: 58px; flex-basis: 58px; }
  .portal-hero { width: calc(100% - 24px); min-height: 300px; margin-top: 20px; }
  .portal-hero-content { min-height: 300px; padding: 30px 24px; }
  .portal-hero-content h1 { font-size: 32px; }
  .portal-hero-content p:not(.portal-hero-kicker) { font-size: 15px; }
  .page-content { margin-top: 28px; }
  .section-heading h1 { font-size: 24px; }
  .server-grid { grid-template-columns: minmax(0, 320px); }
  .server-card { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

.template-tech .topbar { border-color: #1c4961; background: #081b2b; }
.template-tech .brand-mark { border-color: #27627d; background: #0f2b40; }
.template-tech .ticker { border-color: #25506a; background: #0b1d2d; }
.template-tech .ticker-label { background: #126a8d; }
.template-tech .ticker-track { color: #b8eaff; }
.template-tech .section-heading { border-color: #20445a; }
.template-tech .server-cover { background: #102f46; }
.template-tech .server-cover::after { background: #35c6ef; }
.template-tech .server-link { border-color: #1995c5; background: #147eae; }
.template-tech .server-link:hover { background: #1b9acb; }
.template-tech .server-tag { border-color: #2b5c75; color: #9bdcf4; }
.template-tech .auth-dialog { border-color: #2c607a; }
.template-tech .auth-dialog::backdrop { background: rgba(1, 12, 22, .78); }
.template-tech .auth-tab.active { border-color: #2f9bc4; background: #123d56; color: #a9eaff; }
.template-tech .auth-form input { border-color: #2a5b73; background: #071522; }
.template-tech .icon-button { background: #123148; }

.template-royal .topbar { border-color: #6e3430; background: #211015; }
.template-royal .brand-mark { border-color: #865037; background: #351920; }
.template-royal .ticker { border-color: #713733; background: #2a151a; }
.template-royal .ticker-label { background: #8f2935; }
.template-royal .ticker-track { color: #f6dca4; }
.template-royal .section-heading { border-color: #55282a; }
.template-royal .server-cover { background: #3c1b20; }
.template-royal .server-cover::after { background: #e0a735; }
.template-royal .server-link { border-color: #e3525f; background: #c53645; }
.template-royal .server-link:hover { background: #e3525f; }
.template-royal .server-tag { border-color: #70432e; color: #f0cb82; }
.template-royal .auth-dialog { border-color: #7a3b37; }
.template-royal .auth-dialog::backdrop { background: rgba(25, 5, 10, .8); }
.template-royal .auth-tab.active { border-color: #c68d38; background: #53301e; color: #ffdc8a; }
.template-royal .auth-form input { border-color: #713a38; background: #180d12; }
.template-royal .icon-button { background: #432027; }
