:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  color: #1f2933;
  background: #f7f8fa;
  --green: #176b4d;
  --green-dark: #10523a;
  --green-soft: #e5f2ec;
  --line: #e2e5e9;
  --muted: #69737d;
  --surface: #fff;
  --danger: #c7352c;
  --danger-soft: #fff1f0;
  --rail: 248px;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: #f7f8fa; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(23, 107, 77, .2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Shared LightGate mark */
.brand { display: flex; align-items: center; gap: 12px; height: 65px; padding: 0 20px; color: #202124; text-decoration: none; }
.brand > span:last-child, .brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; line-height: 1.25; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-mark, .mark { position: relative; display: inline-block; width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--green); color: transparent; }
.brand-mark::before, .brand-mark::after, .brand-mark i, .mark::before, .mark::after, .mark i { content: ""; position: absolute; border-radius: 2px; background: #fff; }
.brand-mark::before, .mark::before { top: 9px; left: 9px; width: 3px; height: 17px; }
.brand-mark::after, .mark::after { top: 7px; left: 17px; width: 3px; height: 21px; transform: rotate(24deg); }
.brand-mark i, .mark i { top: 8px; right: 4px; width: 10px; height: 3px; transform: rotate(-18deg); }

/* Account center shell */
.account-app { min-height: 100vh; }
.account-rail { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: var(--rail); flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); }
.rail-nav { padding: 12px 10px; }
.nav-label { margin: 12px 12px 7px; color: #858a8f; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.rail-link { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 9px 12px; border-radius: 7px; color: #303236; text-decoration: none; }
.rail-link.active { color: var(--green-dark); background: var(--green-soft); }
.rail-link > span:nth-child(2), .rail-link strong, .rail-link small { display: block; }
.rail-link strong { font-size: 14px; font-weight: 600; }
.rail-link small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.rail-icon { position: relative; width: 22px; height: 22px; flex: none; }
.shield-icon { border: 2px solid currentColor; border-radius: 9px 9px 11px 11px; clip-path: polygon(50% 0, 100% 18%, 90% 78%, 50% 100%, 10% 78%, 0 18%); }
.shield-icon::after { content: ""; position: absolute; top: 6px; left: 7px; width: 5px; height: 3px; border-bottom: 2px solid currentColor; border-left: 2px solid currentColor; transform: rotate(-45deg); }
.rail-footer { margin-top: auto; padding: 18px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: #2e7d32; box-shadow: 0 0 0 4px #edf7ef; }

.account-stage { min-height: 100vh; margin-left: var(--rail); }
.account-topbar { position: fixed; inset: 0 0 auto var(--rail); z-index: 15; display: flex; height: 65px; align-items: center; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.breadcrumbs { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--muted); font-size: 13px; }
.breadcrumbs i { color: #b5b9bd; font-style: normal; }
.breadcrumbs strong { color: #383a3d; font-weight: 500; }
.breadcrumbs b { color: #202124; font-weight: 600; }
.return-link { margin-left: auto; padding: 8px 11px; border-radius: 6px; color: var(--green-dark); font-size: 13px; font-weight: 600; text-decoration: none; }
.return-link:hover { background: var(--green-soft); }
.topbar-profile { display: flex; align-items: center; gap: 9px; margin-left: 12px; padding-left: 16px; border-left: 1px solid var(--line); }
.topbar-profile > span:last-child, .topbar-profile strong, .topbar-profile small { display: block; }
.topbar-profile strong { max-width: 150px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.topbar-profile small { max-width: 170px; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.mini-avatar { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--green); color: #fff; font-size: 13px; font-weight: 700; }
.icon-button { display: none; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.menu-button span, .menu-button span::before, .menu-button span::after { display: block; width: 18px; height: 2px; border-radius: 2px; background: #46494c; }
.menu-button span { position: relative; }
.menu-button span::before, .menu-button span::after { content: ""; position: absolute; left: 0; }
.menu-button span::before { top: -6px; }
.menu-button span::after { top: 6px; }

.account-content { width: min(1220px, 100%); margin: 0 auto; padding: 101px 32px 56px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow, .section-kicker { margin: 0; color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.page-heading h1 { margin: 3px 0 6px; font-size: clamp(25px, 3vw, 30px); font-weight: 570; letter-spacing: -.02em; }
.page-heading > div > p:last-child, .panel-heading p, .list-heading p, .identity-copy > p:last-child { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.summary-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border: 1px solid #b9d8ca; border-radius: 999px; background: #f1f8f5; color: var(--green-dark); font-size: 12px; font-weight: 650; white-space: nowrap; }
.summary-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2e7d32; }
.notice { margin-bottom: 16px; padding: 13px 15px; border: 1px solid #b8dacb; border-radius: 7px; background: #edf7f2; color: #12563e; font-size: 13px; line-height: 1.5; }
.notice.error { border-color: #efc4c0; background: var(--danger-soft); color: #9e2f28; }

.identity-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 16px; margin-bottom: 20px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 1px 2px rgba(32,33,36,.03); }
.account-avatar { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 50%; background: linear-gradient(145deg, var(--green), #258861); color: #fff; font-size: 18px; font-weight: 700; }
.identity-copy h2 { margin: 3px 0 2px; font-size: 17px; font-weight: 600; }
.identity-stat { min-width: 128px; padding-left: 22px; border-left: 1px solid var(--line); text-align: right; }
.identity-stat strong, .identity-stat small { display: block; }
.identity-stat strong { color: var(--green); font-size: 22px; font-weight: 600; }
.identity-stat small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.credential-manager { display: grid; grid-template-columns: 292px minmax(0,1fr); align-items: start; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 1px 2px rgba(32,33,36,.03); }
.method-sidebar { min-height: 560px; padding: 22px 14px; border-right: 1px solid var(--line); background: #fbfcfd; }
.sidebar-heading { padding: 0 8px 15px; }
.sidebar-heading h2 { margin: 5px 0 0; font-size: 14px; font-weight: 600; }
.method-tab { display: grid; width: 100%; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 11px; min-height: 68px; margin: 4px 0; padding: 10px 12px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #303236; text-align: left; cursor: pointer; }
.method-tab:hover { border-color: #d6ddd9; background: #fff; }
.method-tab.active { border-color: #bed8cc; background: var(--green-soft); color: var(--green-dark); }
.method-tab > span:nth-child(2), .method-tab strong, .method-tab small { display: block; }
.method-tab strong { font-size: 14px; font-weight: 600; }
.method-tab small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.method-tab b { display: grid; min-width: 24px; height: 24px; place-items: center; border: 1px solid #d9dee2; border-radius: 12px; background: #fff; color: var(--muted); font-size: 11px; }
.method-tab.active b { border-color: #a8ccbc; color: var(--green-dark); }
.method-icon { position: relative; display: block; width: 32px; height: 32px; border: 1px solid #d9dee2; border-radius: 7px; background: #fff; }
.provider-icon::before { content: ""; position: absolute; inset: 8px; border: 2px solid currentColor; border-radius: 4px; }
.provider-icon::after { content: ""; position: absolute; top: 13px; left: 6px; width: 18px; border-top: 2px solid currentColor; }
.key-icon::before { content: ""; position: absolute; top: 8px; left: 7px; width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50%; }
.key-icon::after { content: ""; position: absolute; top: 18px; left: 16px; width: 10px; height: 2px; background: currentColor; box-shadow: 5px 3px 0 -1px currentColor; transform: rotate(42deg); transform-origin: left center; }
.sidebar-tip { display: flex; gap: 9px; margin: 22px 7px 0; padding: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.sidebar-tip > span { display: grid; width: 18px; height: 18px; flex: none; place-items: center; border: 1px solid #adb4ba; border-radius: 50%; font-size: 10px; font-weight: 800; }
.sidebar-tip p { margin: 0; font-size: 11px; line-height: 1.55; }

.method-content { min-width: 0; }
.method-panel { min-height: 560px; padding: 28px 30px 34px; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 21px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 4px 0 5px; font-size: 20px; font-weight: 600; }
.login-method-list { display: grid; gap: 10px; margin-top: 20px; }
.method-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 14px; min-height: 74px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.method-row:hover { border-color: #cbd3d8; }
.method-logo { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 9px; background: #eef3ff; color: #245bdb; font-size: 18px; font-weight: 750; }
.method-logo.passkey-logo { background: var(--green-soft); color: var(--green-dark); }
.method-copy, .method-copy strong, .method-copy small { display: block; min-width: 0; }
.method-copy strong { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.method-copy small { margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.method-state { display: inline-flex; align-items: center; gap: 6px; margin-left: 7px; color: #277450; font-size: 11px; font-weight: 600; }
.method-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #31a16d; }
.method-actions { display: flex; gap: 8px; }
.primary, .secondary, .danger { min-height: 36px; padding: 0 13px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.primary { border: 1px solid var(--green); background: var(--green); color: #fff; }
.primary:hover { border-color: var(--green-dark); background: var(--green-dark); }
.secondary { border: 1px solid #cfd5d9; background: #fff; color: #3f4245; }
.secondary:hover { background: #f5f7f8; }
.danger { border: 1px solid #e0bab7; background: #fff; color: var(--danger); }
.danger:hover { background: var(--danger-soft); }
.danger.solid { border-color: var(--danger); background: var(--danger); color: #fff; }
.primary:disabled, .secondary:disabled, .danger:disabled { cursor: wait; opacity: .55; }
.empty-state { display: grid; min-height: 160px; place-items: center; padding: 24px; border: 1px dashed #ccd3d8; border-radius: 7px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: #34373a; font-size: 14px; }
.empty-state p { margin: 0; font-size: 12px; line-height: 1.6; }

.add-passkey-card { margin-top: 20px; padding: 18px; border: 1px solid #bfd9cd; border-radius: 8px; background: #f5faf8; }
.add-passkey-copy { display: flex; gap: 13px; align-items: flex-start; }
.add-passkey-copy strong { display: block; font-size: 14px; }
.add-passkey-copy p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.large-key-icon { position: relative; width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--green-soft); color: var(--green-dark); }
.large-key-icon::before { content: ""; position: absolute; top: 8px; left: 7px; width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50%; }
.large-key-icon::after { content: ""; position: absolute; top: 19px; left: 16px; width: 11px; height: 2px; background: currentColor; box-shadow: 5px 3px 0 -1px currentColor; transform: rotate(42deg); transform-origin: left center; }
.add-row { margin-top: 16px; padding-top: 15px; border-top: 1px solid #d6e6df; }
.add-row label { display: block; margin-bottom: 7px; color: #4b504d; font-size: 11px; font-weight: 650; }
.add-row > div { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px; }
input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid #cbd3d0; border-radius: 6px; background: #fff; color: #202124; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,77,.12); }
.list-heading { margin: 28px 0 0; }
.list-heading h3 { margin: 0 0 4px; font-size: 14px; }
.loading-row { display: flex; align-items: center; gap: 14px; min-height: 74px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; }
.loading-row > span { width: 42px; height: 42px; border-radius: 9px; background: #eef1f3; animation: pulse 1.25s ease-in-out infinite; }
.loading-row > div { flex: 1; }
.loading-row b, .loading-row i { display: block; height: 10px; border-radius: 4px; background: #eef1f3; animation: pulse 1.25s ease-in-out infinite; }
.loading-row b { width: 34%; }.loading-row i { width: 54%; height: 8px; margin-top: 9px; }

.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px; background: rgba(27,31,29,.38); backdrop-filter: blur(2px); }
.confirm-dialog { width: min(430px, 100%); padding: 25px; border: 1px solid #e2e5e7; border-radius: 10px; background: #fff; box-shadow: 0 20px 60px rgba(24,29,26,.2); }
.warning-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: var(--danger-soft); color: var(--danger); font-weight: 800; }
.confirm-dialog h2 { margin: 15px 0 7px; font-size: 19px; }
.confirm-dialog > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }

/* Passkey login ceremony */
body[data-passkey-mode="login"] { display: grid; place-items: center; padding: 24px; background: #f7f8fa; }
.auth-card { width: min(400px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.auth-card .mark { margin-bottom: 20px; }
.auth-card .eyebrow { margin-bottom: 7px; }
.auth-card h1 { margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.auth-card .lead { margin: 0 0 25px; color: var(--muted); line-height: 1.65; }
.auth-card .primary { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 0 16px; }
.status { min-height: 22px; margin: 13px 0 0; color: var(--green); font-size: 12px; }
.status.error { color: var(--danger); }
.auth-card > small { display: block; margin-top: 19px; color: #858d89; text-align: center; }

@keyframes pulse { 50% { opacity: .52; } }

@media (max-width: 899px) {
  :root { --rail: 0px; }
  .account-rail { width: 248px; transform: translateX(-101%); transition: transform .2s ease; box-shadow: 12px 0 40px rgba(32,33,36,.13); }
  body.rail-open .account-rail { transform: translateX(0); }
  body.rail-open::after { content: ""; position: fixed; inset: 0; z-index: 19; background: rgba(32,33,36,.28); }
  .account-stage { margin-left: 0; }
  .account-topbar { left: 0; padding: 0 14px; }
  .icon-button { display: grid; margin-right: 7px; }
  .account-content { padding: 89px 14px 36px; }
  .credential-manager { grid-template-columns: 1fr; }
  .method-sidebar { display: grid; min-height: auto; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-heading, .sidebar-tip { display: none; }
  .method-tab { margin: 0; }
  .method-panel { min-height: 460px; padding: 24px 20px 28px; }
}

@media (max-width: 620px) {
  .breadcrumbs span, .breadcrumbs i:first-of-type, .breadcrumbs strong { display: none; }
  .return-link { display: none; }
  .topbar-profile { margin-left: auto; border: 0; padding: 0; }
  .topbar-profile > span:last-child { display: none; }
  .page-heading { display: block; }
  .summary-chip { margin-top: 14px; }
  .identity-card { grid-template-columns: auto minmax(0,1fr); }
  .identity-stat { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 7px; padding: 12px 0 0; border-top: 1px solid var(--line); border-left: 0; text-align: left; }
  .identity-stat small { margin: 0; }
  .method-sidebar { overflow-x: auto; grid-template-columns: minmax(210px,1fr) minmax(210px,1fr); }
  .method-panel { padding: 22px 15px 26px; }
  .method-row { grid-template-columns: auto minmax(0,1fr); }
  .method-actions { grid-column: 1 / -1; }
  .method-actions button { flex: 1; }
  .add-row > div { grid-template-columns: 1fr; }
  .add-row .primary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
