:root {
  --bg: #e9eef2;
  --surface: #f4f7f9;
  --surface-strong: #ffffff;
  --surface-soft: #e1e7eb;
  --text: #172027;
  --muted: #64717b;
  --line: rgb(23 32 39 / 13%);
  --accent: #476d85;
  --accent-strong: #31566d;
  --accent-soft: rgb(105 157 188 / 15%);
  --glow: rgb(202 156 83 / 20%);
  --shadow: 0 24px 70px rgb(42 61 72 / 12%);
  --radius-shell: 28px;
  --radius-card: 20px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10171b;
    --surface: #182126;
    --surface-strong: #202a30;
    --surface-soft: #202a30;
    --text: #edf3f5;
    --muted: #a2afb6;
    --line: rgb(237 243 245 / 13%);
    --accent: #8fc1db;
    --accent-strong: #b3d9eb;
    --accent-soft: rgb(112 177 211 / 14%);
    --glow: rgb(210 164 91 / 15%);
    --shadow: 0 24px 70px rgb(0 0 0 / 30%);
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  background: var(--bg);
  color: var(--text);
}

a,
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgb(71 109 133 / 18%);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1,
h2 {
  text-wrap: balance;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--surface);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  position: relative;
  isolation: isolate;
  width: min(1120px, 100%);
  min-height: calc(100vh - 40px);
  min-height: calc(100dvh - 40px);
  margin: 0 auto;
  padding: 30px clamp(22px, 5vw, 58px) 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-shell);
  background:
    radial-gradient(circle at 88% 6%, var(--glow), transparent 25rem),
    linear-gradient(145deg, var(--accent-soft), var(--surface) 44%);
  box-shadow: var(--shadow);
}

.shell::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  opacity: .22;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 60%);
}

.topbar,
.wordmark,
.account,
.app-meta,
.app-action,
.admin-entry,
.guide-meta {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  gap: 10px;
  min-width: 0;
  min-height: 44px;
  color: inherit;
  letter-spacing: -.04em;
  text-decoration: none;
}

.wordmark strong {
  transition: color 160ms ease;
}

.wordmark:hover strong {
  color: var(--accent-strong);
}

.wordmark strong {
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 650;
}

.wordmark span,
.kicker,
.app-code,
.guide-code,
.privacy-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.wordmark span {
  color: var(--muted);
  letter-spacing: .04em;
}

.header-action,
.member-entry,
.logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.header-action:hover,
.member-entry:hover,
.logout:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.account {
  gap: 10px;
  min-width: 0;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
}

.avatar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.identity {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.identity-label {
  color: var(--muted);
  font-size: 12px;
}

.identity-name {
  max-width: 180px;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 16px;
  padding-top: 28px;
  text-align: center;
}

.filing-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  transition: color 160ms ease;
}

.filing-link:hover {
  color: var(--text);
}

/* Public landing */
.public-shell {
  display: flex;
  flex-direction: column;
}

.privacy-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .1em;
}

.public-content {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(310px, .85fr);
  align-items: center;
  gap: clamp(34px, 7vw, 78px);
  margin: auto 0;
  padding: clamp(44px, 7vw, 80px) 0;
}

.public-hero h1 {
  max-width: 660px;
  margin: 0;
  font-size: clamp(42px, 6vw, 66px);
  font-weight: 650;
  letter-spacing: -.055em;
  line-height: 1.08;
}

.public-lead {
  max-width: 610px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 18px);
  line-height: 1.75;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 34px;
  min-height: 52px;
  margin-top: 28px;
  padding: 0 18px;
  border-radius: 13px;
  background: var(--text);
  color: var(--surface);
  font-weight: 650;
  text-decoration: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.primary-action:hover {
  opacity: .9;
  transform: translateY(-2px);
}

.access-panel {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--surface-strong) 78%, transparent);
}

.access-panel h2 {
  margin: 0 0 8px;
  font-size: 21px;
  font-weight: 650;
}

.access-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.fact-list {
  display: grid;
  gap: 0;
  margin: 22px 0 0;
  padding: 0;
  border-bottom: 1px solid var(--line);
  list-style: none;
}

.fact-list li {
  position: relative;
  padding: 15px 0 15px 22px;
  border-top: 1px solid var(--line);
}

.fact-list li::before {
  position: absolute;
  top: 23px;
  left: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.fact-list strong,
.fact-list span {
  display: block;
}

.fact-list strong {
  margin-bottom: 4px;
  font-size: 15px;
}

.fact-list span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

/* Authenticated portal */
.portal-intro,
.admin-intro {
  padding: clamp(38px, 6vw, 62px) 0 26px;
}

.portal-intro h1,
.admin-intro h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 650;
  letter-spacing: -.045em;
  line-height: 1.12;
}

.portal-intro p:last-child,
.admin-intro p:last-child {
  max-width: 620px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.app-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 220px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
  color: inherit;
  text-decoration: none;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.app-card:hover {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-strong));
  transform: translateY(-3px);
}

.app-meta,
.app-action,
.guide-meta {
  justify-content: space-between;
  gap: 14px;
}

.app-code,
.guide-code {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .06em;
}

.access-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.access-state::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.app-copy {
  align-self: end;
  margin: 30px 0 24px;
}

.app-copy h2 {
  margin: 0 0 7px;
  font-size: clamp(25px, 4vw, 34px);
  font-weight: 650;
  letter-spacing: -.035em;
}

.app-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.app-action {
  font-weight: 650;
}

.app-arrow {
  font-size: 25px;
  transition: transform 180ms ease;
}

.app-card:hover .app-arrow {
  transform: translateX(4px);
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--surface-strong) 58%, transparent);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 21px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.admin-entry {
  justify-content: space-between;
  gap: 18px;
  min-height: 66px;
  margin-top: 16px;
  padding: 15px 4px 0;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: color 160ms ease;
}

.admin-entry:hover {
  color: var(--accent-strong);
}

.admin-entry-copy {
  display: grid;
  gap: 3px;
}

.admin-entry-copy small {
  color: var(--muted);
}

.admin-entry-action {
  flex: 0 0 auto;
  font-weight: 650;
}

/* Admin guide */
.admin-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  align-items: end;
  gap: 26px;
}

.admin-intro p:last-child {
  margin: 0 0 4px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.guide-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 210px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
}

.guide-copy {
  align-self: end;
  margin: 28px 0 18px;
}

.guide-copy h2 {
  margin: 0 0 7px;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -.025em;
}

.guide-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

code {
  display: block;
  padding: 12px 13px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: normal;
}

.guide-note {
  margin: 16px 0 0;
  padding: 16px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 840px) {
  .public-content,
  .app-grid,
  .guide-grid,
  .admin-intro {
    grid-template-columns: 1fr;
  }

  .public-content,
  .admin-intro {
    align-items: start;
  }
}

@media (max-width: 720px) {
  body {
    padding: 0;
  }

  .shell {
    min-height: 100vh;
    min-height: 100dvh;
    padding:
      max(18px, env(safe-area-inset-top))
      max(18px, env(safe-area-inset-right))
      max(22px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    min-height: 54px;
    padding-bottom: 18px;
  }

  .wordmark span,
  .identity-label,
  .privacy-label {
    display: none;
  }

  .identity-name {
    max-width: 82px;
  }

  .logout,
  .header-action,
  .member-entry {
    min-height: 44px;
    padding: 0 13px;
  }

  .avatar {
    width: 38px;
    height: 38px;
  }

  .public-content {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 30px;
    margin: 0;
    padding: 38px 0 30px;
  }

  .public-hero h1 {
    font-size: clamp(38px, 11vw, 48px);
  }

  .public-lead {
    margin-top: 18px;
    line-height: 1.65;
  }

  .primary-action {
    width: 100%;
    margin-top: 22px;
  }

  .access-panel {
    padding: 21px;
  }

  .portal-intro,
  .admin-intro {
    padding: 34px 0 22px;
  }

  .portal-intro h1,
  .admin-intro h1 {
    font-size: clamp(32px, 10vw, 42px);
  }

  .app-grid,
  .guide-grid,
  .admin-intro {
    grid-template-columns: 1fr;
  }

  .app-card {
    min-height: 156px;
    padding: 20px;
  }

  .app-copy {
    margin: 22px 0 18px;
  }

  .app-copy h2 {
    font-size: 26px;
  }

  .admin-entry {
    align-items: flex-end;
  }

  .admin-intro {
    align-items: start;
  }

  .admin-intro p:last-child {
    margin: 0;
  }

  .guide-card {
    min-height: 190px;
    padding: 20px;
  }
}

@media (max-width: 360px) {
  .topbar {
    gap: 10px;
  }

  .account {
    justify-content: flex-end;
    gap: 6px;
  }

  .account .avatar {
    display: none;
  }

  .identity-name {
    max-width: 72px;
  }

  .logout,
  .header-action,
  .member-entry {
    flex: 0 0 auto;
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skip-link,
  .wordmark strong,
  .header-action,
  .member-entry,
  .logout,
  .primary-action,
  .filing-link,
  .app-card,
  .app-arrow,
  .admin-entry {
    transition: none;
  }

  .primary-action:hover,
  .app-card:hover {
    transform: none;
  }
}
