:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --page: #0a101b;
  --surface: #121b2a;
  --input: #0e1726;
  --line: #2b384e;
  --text: #f1f5ff;
  --muted: #aab8cd;
  --accent: #a4b9ff;
  --feature: #142746;
  --feature-edge: #101e34;
  --feature-grid: #a1baff17;
  --mark-bg: #192e50;
  --mark-line: #3a5076;
  --shadow: #04070d55;
  --error: #ffc8cf;
  --error-bg: #3a2230;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #eef2f7;
  --surface: #fff;
  --input: #fafbfd;
  --line: #d5ddea;
  --text: #15243c;
  --muted: #4e607a;
  --accent: #264ca7;
  --feature: #e5ecf8;
  --feature-edge: #f1f5fb;
  --feature-grid: #3c62a61c;
  --mark-bg: #f7faff;
  --mark-line: #b9c9e5;
  --shadow: #20385813;
  --error: #90283a;
  --error-bg: #fff0f1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-width: 0;
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: clamp(16px, 5vw, 64px);
  background: var(--page);
  color: var(--text);
}

.login-layout {
  width: min(100%, 1060px);
  display: grid;
  grid-template-columns: 1.04fr 1fr;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 22px 66px var(--shadow);
}

.login-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px clamp(17px, 3.2vw, 33px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: clamp(1rem, 3vw, 1.22rem);
  font-weight: 750;
  letter-spacing: -.037em;
}

.wordmark img { display: block; flex: none; }
.wordmark strong { color: var(--accent); font-weight: 750; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login-tools { display: flex; gap: 8px; align-items: center; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .8rem;
  font-weight: 650;
}

.theme-icon::before { content: "☀"; font-size: 1rem; }
[data-theme="light"] .theme-icon::before { content: "◐"; }
.theme-toggle:hover, .access-card input:hover { border-color: var(--accent); }
.install-app,.install-dialog button {
  min-height: 42px; padding-inline: 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text); font-size: .8rem; font-weight: 680;
}
.install-app:hover,.install-dialog button:hover { border-color: var(--accent); }
.install-dialog {
  max-width: min(455px, calc(100% - 24px)); padding: 20px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.install-dialog::backdrop { background: #030812a8; }
.install-dialog h2 { margin: 0 0 12px; }
.install-dialog p { line-height: 1.55; }
.install-dialog form { text-align: right; }

.brand-panel {
  min-height: 477px;
  min-width: 0;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 26px;
  padding: 42px clamp(24px, 5vw, 59px);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: linear-gradient(150deg, var(--feature), var(--feature-edge) 84%);
}

.brand-panel::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--feature-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--feature-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(140deg, transparent 5%, #000 55%, transparent 100%);
}

.brand-emblem {
  width: 98px;
  height: 98px;
  border: 1px solid var(--mark-line);
  border-radius: 17px;
  background: var(--mark-bg);
}

.brand-title {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2.15rem, 4.3vw, 3.45rem);
  line-height: 1.075;
  font-weight: 700;
  letter-spacing: -.055em;
  text-wrap: balance;
}

.brand-description {
  max-width: 34ch;
  margin: 15px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: .96rem;
}

.access-panel { display: grid; place-items: center; padding: 39px clamp(24px, 5vw, 66px); }
.access-card { width: min(100%, 355px); }
.access-card h1 { margin: 0; font-weight: 750; font-size: clamp(1.95rem, 3vw, 2.5rem); line-height: 1.12; letter-spacing: -.045em; }
.login-intro { margin: 9px 0 27px; color: var(--muted); font-size: .91rem; line-height: 1.5; }
.access-card form { display: grid; gap: 8px; }
.access-card label { font-size: .84rem; font-weight: 680; }

.access-card input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  font-size: 1rem;
}

.access-card label[for="password"] { margin-top: 8px; }
.password-input { position: relative; }
.password-input input { padding-right: 53px; }
#password-toggle {
  width: 44px;
  height: 44px;
  position: absolute;
  inset: 2px 4px auto auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

#password-toggle:hover { color: var(--accent); }
#password-toggle span {
  width: 16px;
  height: 12px;
  position: relative;
  border: 1.5px solid currentColor;
  border-radius: 65% 37%;
  transform: rotate(45deg);
}

#password-toggle span::after {
  content: "";
  position: absolute;
  inset: 2px 4px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

#password-toggle[aria-pressed="true"] span { border-style: dashed; }

.sign-in {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding: 0 14px;
  border: 1px solid #6489ea;
  border-radius: 8px;
  background: #2854ba;
  color: #fff;
  font-size: .91rem;
  font-weight: 720;
}

.sign-in:hover { background: #234aa9; }
.sign-in:disabled { cursor: wait; opacity: .78; }
.arrow { font-size: 1.22rem; line-height: 1; }
.login-error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error);
  font-size: .85rem;
}

.access-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 23px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
}

.access-note span {
  position: relative;
  width: 10px;
  height: 8px;
  margin-top: 3px;
  border: 1px solid currentColor;
  border-radius: 2px;
}

.access-note span::before {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  top: -5px;
  left: 1px;
  border: 1px solid currentColor;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}

@media (max-width: 730px) {
  body { padding: 0; place-items: start center; }
  .login-layout { min-height: 100svh; max-width: 500px; grid-template-columns: minmax(0,1fr); grid-template-rows: auto 1fr; border: 0; border-radius: 0; }
  .login-header {
    min-height: calc(156px + env(safe-area-inset-top,0px)); align-items: flex-start;
    padding: calc(18px + env(safe-area-inset-top,0px)) 19px 32px;
    color: #f1f5ff; border: 0;
    background: repeating-linear-gradient(132deg, transparent 0 28px,#7b9dfa1a 28px 29px),
      linear-gradient(142deg,#091833 30%,#16396f);
  }
  .login-header .wordmark { min-height: 44px; }
  .login-header .wordmark strong { color: #afc3ff; }
  .login-header .theme-toggle { background: #142b4f; color: #f1f5ff; border-color: #476694; min-width: 44px; min-height: 44px; }
  .login-header .theme-title { display: none; }
  .login-header .install-app { display: none; }
  .brand-panel { display: none; }
  .access-panel {
    position: relative; align-items: start; margin-top: -28px; border-radius: 28px 28px 0 0;
    padding: 26px clamp(20px, 7vw, 38px) calc(28px + env(safe-area-inset-bottom,0px));
    background: var(--surface); box-shadow: 0 -9px 22px #060d2752;
  }
  .access-card { width: 100%; }
  .access-card h1 { font-size: clamp(2rem, 9vw, 2.7rem); }
  .access-card input,.sign-in { height: 52px; }
  #password-toggle { inset-block-start: 4px; }
}
