:root {
  color-scheme: light;
  --background: #f5f7f4;
  --surface: #ffffff;
  --surface-raised: #f0f4f1;
  --text: #17211a;
  --muted: #536159;
  --muted-strong: #344239;
  --border: #d6ddd8;
  --border-strong: #bdc8c0;
  --accent: #176848;
  --accent-hover: #125b3e;
  --accent-ink: #ffffff;
  --focus-ring: rgb(23 104 72 / 14%);
  --danger-soft: #fff5f3;
  --danger-text: #8d2925;
  --success-soft: #eff8f3;
  --shadow: 0 12px 35px rgb(31 49 39 / 8%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
  letter-spacing: 0;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #111310;
  --surface: #171916;
  --surface-raised: #1e211d;
  --text: #f4f6f1;
  --muted: #a8afa2;
  --muted-strong: #c7cdc2;
  --border: #353a32;
  --border-strong: #52594d;
  --accent: #c6f34a;
  --accent-hover: #d5ff61;
  --accent-ink: #151b08;
  --focus-ring: rgb(198 243 74 / 22%);
  --danger-soft: #321c1b;
  --danger-text: #ff9b8d;
  --success-soft: #1d2b20;
  --shadow: 0 12px 35px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  border-left: 8px solid var(--accent);
  background: var(--background);
}

button, input { font: inherit; letter-spacing: 0; }

.auth-layout {
  width: min(100% - 40px, 540px);
  margin: 0 auto;
  padding: 56px 0;
}

.auth-legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; padding-top: 26px; color: var(--muted); font-size: 13px; }
.auth-legal a { color: inherit; }
.auth-legal a:hover, .auth-legal a:focus-visible { color: var(--text); }

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 21px;
  font-weight: 750;
  text-decoration: none;
}

.brand img { width: 42px; height: 42px; object-fit: contain; }

.theme-toggle {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

.auth-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.auth-tabs:has(#register-tab[hidden]) { display: none; }
.auth-tabs button[hidden] { display: none; }

.auth-tabs button {
  min-height: 52px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: var(--surface-raised);
  color: var(--muted);
  font-weight: 680;
  cursor: pointer;
}

.auth-tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  background: var(--surface);
  color: var(--text);
}

form { display: grid; gap: 18px; padding: 34px; }
form[hidden] { display: none; }
header { margin-bottom: 2px; }
h1 { margin: 0; font-size: 26px; line-height: 1.2; }

label { display: grid; gap: 7px; color: var(--muted-strong); font-size: 14px; font-weight: 650; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
small { color: var(--muted); font-weight: 450; }

.form-guidance {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.primary-action {
  min-height: 46px;
  border: 1px solid var(--accent-hover);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 720;
  cursor: pointer;
}

.primary-action:hover { background: var(--accent-hover); }
.primary-action:disabled { cursor: wait; opacity: .66; }

.form-error {
  margin: 0;
  border-left: 3px solid #b33a34;
  padding: 8px 10px;
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: 14px;
}

.form-status {
  margin: 0;
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  background: var(--success-soft);
  color: var(--accent-hover);
  font-size: 14px;
}

@media (max-width: 560px) {
  .auth-layout { width: min(100% - 28px, 540px); padding: 28px 0; }
  form { padding: 26px 22px; }
  .field-row { grid-template-columns: 1fr; }
}
