:root {
  color-scheme: light;
  --page: #eceeef;
  --surface: #fbfbfc;
  --surface-soft: #f2f3f4;
  --line: #e1e3e5;
  --text: #202327;
  --muted: #7c838b;
  --navy: #222529;
  --blue: #485972;
  --green: #54806e;
  --amber: #987c48;
  --red: #a45f60;
  --orange: #e7a62f;
  --shadow: 0 10px 28px rgb(34 39 44 / 5%);
  font-family: 'SF Mono', 'SFMono-Regular', 'Menlo', 'Monaco', ui-monospace, monospace;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/SFMono-Regular.otf') format('opentype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/SFMono-Medium.otf') format('opentype');
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/SFMono-Semibold.otf') format('opentype');
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/SFMono-Bold.otf') format('opentype');
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--page); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }

.page-shell { width: min(1000px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 36px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 22px; line-height: 1.2; }
h2 { margin-bottom: 14px; font-size: 15px; line-height: 1.3; }
.muted { margin-bottom: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.card { border: 1px solid rgb(223 228 234 / 90%); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow); }

.button {
  min-height: 39px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  transition: background .15s ease, transform .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgb(54 95 219 / 23%);
  outline-offset: 2px;
}
.button-primary { color: #fff; background: var(--navy); box-shadow: 0 3px 8px rgb(34 37 41 / 12%); }
.button-primary:hover:not(:disabled), .button-dark:hover:not(:disabled) { background: #34383d; }
.button-dark { color: #fff; background: var(--navy); }
.button-quiet { min-height: 35px; border-color: #dce2e8; color: #667383; background: transparent; }
.button-quiet:hover:not(:disabled) { background: rgb(255 255 255 / 70%); }
.button-wide { width: 100%; }

.control-card {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 15px 18px;
}
.control-copy { display: flex; align-items: center; gap: 15px; }
.status-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 600; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #adb6c1; }
.status-label.is-on { color: var(--green); }
.status-label.is-on .status-dot { box-shadow: 0 0 0 3px #e2f3ed; background: var(--green); }
.status-label.is-partial { color: var(--amber); }
.status-label.is-partial .status-dot { box-shadow: 0 0 0 3px #f8f0df; background: var(--amber); }
.control-action { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.control-action .button-primary, .control-action .button-dark { min-width: 174px; }
.logout-button { margin-left: 3px; }

.spawner-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; padding: 12px 18px; }
.spawner-total { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.spawner-total strong { color: #34445a; font-size: 18px; font-weight: 700; }
.spawner-total span { color: var(--muted); font-size: 10px; }

.content-grid { display: grid; grid-template-columns: minmax(240px, .72fr) minmax(0, 1.7fr); gap: 18px; align-items: start; }
.add-card { padding: 18px; }
.add-card h2 { margin-bottom: 11px; }
label { display: block; margin: 0 0 7px; color: #3b4653; font-size: 10px; font-weight: 700; }
input, select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid #e0e2e4;
  border-radius: 7px;
  background: #f3f4f5;
  color: var(--text);
  padding: 0 10px;
  font-size: 11px;
}
input::placeholder { color: #a3acb7; }
#add-form .button { margin-top: 11px; }
.form-error { margin: 9px 0 0; color: var(--red); font-size: 11px; line-height: 1.4; }

.accounts-section { min-width: 0; }
.list-heading { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.list-heading h2 { margin: 0 0 2px; font-size: 15px; }
.list-heading .muted { font-size: 10px; }
.account-list { display: grid; gap: 8px; }
.account-card { min-width: 0; padding: 12px 14px; }
.account-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-identity { display: flex; align-items: center; min-width: 0; gap: 11px; }
.account-avatar {
  width: 42px;
  height: 42px;
  display: block;
  flex: 0 0 42px;
  overflow: hidden;
  border: 1px solid #e1e3e7;
  border-radius: 11px;
  background: linear-gradient(145deg, #eef0f3, #e2e5e9);
  image-rendering: pixelated;
  object-fit: cover;
}
.account-name { overflow: hidden; margin: 0 0 3px; color: #263243; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.account-stars { overflow: hidden; margin: 0; color: #8195a8; font-size: 9px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.account-spawners { overflow: hidden; margin: 2px 0 0; color: #7a8590; font-size: 9px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.account-proxy { overflow: hidden; margin: 2px 0 0; color: #687b8d; font-size: 9px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.account-tools { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; background: #f2f4f6; padding: 6px 8px; color: #687584; font-size: 9px; font-weight: 600; white-space: nowrap; }
.status-badge::before { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 50%; background: #a6afba; content: ''; }
.status-badge.connected { color: #267658; background: #eaf6f0; }
.status-badge.connected::before { background: #2b9a6f; }
.status-badge.authenticated { color: #55705f; background: #f0f3f0; }
.status-badge.authenticated::before { background: #7d9b86; }
.status-badge.authenticating, .status-badge.connecting, .status-badge.joining,
.status-badge.waiting, .status-badge.reconnecting { color: #92702e; background: #fbf5e7; }
.status-badge.authenticating::before, .status-badge.connecting::before, .status-badge.joining::before,
.status-badge.waiting::before, .status-badge.reconnecting::before { background: #c39437; }
.status-badge.maintenance { color: #92702e; background: #fbf0dc; }
.status-badge.maintenance::before { background: #c39437; }
.status-badge.auth_required, .status-badge.error { color: #a34d4d; background: #fbefef; }
.status-badge.auth_required::before, .status-badge.error::before { background: #c76060; }
.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #98a2ad;
  background: transparent;
  font-size: 17px;
}
.icon-button:hover { border-color: #f0dddd; color: var(--red); background: #fff8f8; }
.icon-button:focus-visible, .account-toggle:focus-visible { outline: 3px solid rgb(54 95 219 / 23%); outline-offset: 2px; }
.account-toggle { min-width: 61px; min-height: 34px; border: 1px solid transparent; border-radius: 8px; padding: 0 7px; font-size: 10px; font-weight: 700; }
.account-start { border-color: #d4e8da; color: #2f7651; background: #eaf5ed; }
.account-start:hover:not(:disabled) { border-color: #bddbc6; background: #ddf0e2; }
.account-stop { border-color: var(--red); color: #fff; background: var(--red); box-shadow: 0 2px 6px rgb(164 95 96 / 18%); }
.account-stop:hover:not(:disabled) { border-color: #87494a; background: #87494a; }
.account-detail { display: flex; flex-wrap: wrap; gap: 7px 12px; margin: 6px 0 0 53px; color: #87919b; font-size: 9px; line-height: 1.4; }
.afk-return-button { min-height: 26px; padding: 0 9px; font-size: 9px; }
.account-notice { color: #677485; }
.account-error { color: var(--red); }
.device-code { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 10px 0 0 53px; border: 1px solid #e2e4e7; border-radius: 9px; background: #f4f5f6; padding: 9px 10px; }
.device-code-copy { color: #758198; font-size: 9px; }
.device-code-value { color: #35445d; font-size: 14px; font-weight: 700; letter-spacing: .12em; }
.device-code a { margin-left: auto; color: var(--blue); font-size: 9px; font-weight: 700; text-decoration: none; }
.device-code a:hover { text-decoration: underline; }
.retry-button { min-height: 31px; margin: 9px 0 0 53px; padding: 0 10px; font-size: 10px; }
.empty-state { display: grid; place-items: center; padding: 22px 16px; text-align: center; box-shadow: none; }
.empty-icon { width: 32px; height: 32px; display: grid; place-items: center; margin-bottom: 8px; border-radius: 9px; color: var(--blue); background: #edf0f5; font-size: 19px; }
.empty-state strong { font-size: 11px; }

.pickup-card { margin-top: 18px; padding: 16px 18px; }
.pickup-card h2 { margin-bottom: 10px; }
.pickup-line { display: grid; grid-template-columns: auto minmax(160px, 1fr) minmax(150px, .8fr) auto; align-items: center; gap: 8px; }
.pickup-command { color: #76818d; font-size: 11px; white-space: nowrap; }
.pickup-line input, .pickup-line select { min-height: 41px; background: #f2f3f4; }
.pickup-button { min-width: 108px; border-color: #e2a02b; color: #292722; background: var(--orange); box-shadow: 0 3px 7px rgb(204 143 32 / 16%); }
.pickup-button:hover:not(:disabled) { background: #f0b449; }

.login-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.login-card { width: min(100%, 390px); padding: 26px; }
.login-card h1 { margin-bottom: 8px; font-size: 23px; }
.login-card > .muted { margin-bottom: 16px; }
.login-card > .login-session-note { margin-top: 12px; margin-bottom: 0; font-size: 9px; }
.access-code-command { display: block; overflow-wrap: anywhere; margin: -7px 0 15px; border: 1px solid #e5e6e8; border-radius: 7px; background: #f3f4f5; padding: 9px; color: #424951; font-size: 9px; }
.login-card .button { margin-top: 14px; }
.toast { position: fixed; right: 18px; bottom: 16px; z-index: 5; max-width: min(420px, calc(100% - 28px)); border: 1px solid #dbe4ee; border-radius: 10px; background: #fff; padding: 11px 13px; box-shadow: 0 12px 35px rgb(30 44 62 / 14%); color: #364455; font-size: 11px; opacity: 0; transform: translateX(calc(100% + 24px)); transition: transform .24s ease-out, opacity .24s ease-out; }
.toast.toast-visible { opacity: 1; transform: translateX(0); }
.toast.toast-error { border-color: #b64b50; color: #fff; background: #b64b50; box-shadow: 0 10px 28px rgb(130 37 42 / 24%); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 28px, 620px); padding: 14px 0 22px; }
  .control-card { align-items: flex-start; flex-direction: column; gap: 11px; padding: 14px; }
  .spawner-summary { margin-bottom: 14px; padding: 11px 14px; }
  .control-copy { width: 100%; justify-content: space-between; }
  .control-action { width: 100%; display: grid; grid-template-columns: 1fr 1fr auto; gap: 7px; }
  .control-action .button-primary, .control-action .button-dark { min-width: 0; }
  .content-grid { grid-template-columns: 1fr; gap: 14px; }
  .add-card { padding: 15px; }
  .list-heading { min-height: 32px; }
  .pickup-card { margin-top: 14px; padding: 14px; }
}

@media (max-width: 480px) {
  .page-shell { width: calc(100% - 20px); padding-top: 10px; }
  .control-card { padding: 12px; }
  .control-action { grid-template-columns: 1fr 1fr; }
  .logout-button { grid-column: 1 / 3; min-height: 32px; margin-left: 0; }
  .account-card { padding: 10px; }
  .account-top { gap: 7px; }
  .account-identity { gap: 8px; }
  .account-avatar { width: 38px; height: 38px; flex-basis: 38px; border-radius: 9px; }
  .account-name { max-width: 130px; font-size: 11px; }
  .account-stars { max-width: 130px; font-size: 8px; }
  .account-spawners { max-width: 140px; font-size: 8px; }
  .account-proxy { max-width: 180px; font-size: 8px; }
  .account-tools { gap: 3px; }
  .status-badge { gap: 4px; padding: 5px 6px; font-size: 8px; }
  .icon-button { width: 30px; height: 32px; }
  .account-toggle { min-width: 51px; min-height: 33px; padding: 0 5px; font-size: 9px; }
  .account-detail, .device-code, .retry-button { margin-left: 46px; }
  .pickup-line { grid-template-columns: auto minmax(0, 1fr); gap: 7px; }
  .pickup-line select { grid-column: 1; }
  .pickup-button { grid-column: 2; min-width: 0; padding: 0 8px; }
}
