:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1f6feb;
  --danger: #d1242f;
  --ok: #1a7f37;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --card: #161b22;
    --ink: #e6edf3;
    --muted: #8b949e;
    --line: #30363d;
    --accent: #4493f8;
    --danger: #f85149;
    --ok: #3fb950;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: max(12px, env(safe-area-inset-top)) 12px
           max(12px, env(safe-area-inset-bottom));
}
main, section#login, #topbar { max-width: 640px; margin: 0 auto; }

h1 { font-size: 22px; margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 13px; }
.ok { color: var(--ok); font-size: 13px; }

#login-sent {
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #0b7a33;
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #login-sent { color: #6ee7a0; }
}
:root[data-theme="dark"] #login-sent { color: #6ee7a0; }

.hero {
  text-align: center;
  padding: 28px 8px 6px;
}
.hero h1 {
  font-size: 24px;
  line-height: 1.25;
  margin: 0 auto 8px;
  max-width: 30ch;
}
.hero > p {
  color: var(--muted);
  max-width: 40ch;
  margin: 0 auto 16px;
}
.hero-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 420px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hero-list li {
  position: relative;
  padding-left: 24px;
  font-size: 14px;
}
.hero-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 6px;
}
#topbar .brand { font-weight: 700; font-size: 16px; }
#topbar .spacer { flex: 1; }
#topbar #who {
  max-width: 45vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lang {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}
#lang:focus { outline: 2px solid var(--accent); }

#footer {
  max-width: 640px;
  margin: 20px auto 10px;
  padding: 0 2px;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
#footer a { color: var(--accent); text-decoration: none; }
#footer a:hover { text-decoration: underline; }

.linkbtn {
  flex: 0 0 auto;
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }

#about {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  max-width: 340px;
  width: calc(100vw - 32px);
  color: var(--ink);
  background: var(--card);
}
#about::backdrop { background: rgba(0, 0, 0, .4); }
#about h2 { margin: 0 0 8px; font-size: 18px; }
#about h2 .brand { font-size: 18px; }
#about p { margin: 8px 0; }
#about #about-price { font-size: 13px; color: var(--muted); }
#about a { color: var(--accent); }
#about #invoice-link { font-weight: 600; }
#about form { margin-top: 14px; }
#about form button { width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 10px 0;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.grid label.wide { grid-column: 1 / -1; }
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
input {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
button {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  flex: 1 1 auto;
  min-height: 42px;
}
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger { color: var(--danger); border-color: var(--line); }
button.link {
  background: none; border: none; color: var(--accent);
  padding: 4px 6px; flex: 0 0 auto; min-height: 0;
}
button:disabled { opacity: .4; cursor: default; }

#login-form,
#license-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.hp {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden;
  opacity: 0;
}

#license-gate h2 { font-size: 18px; margin: 0 0 4px; }
#license-code { letter-spacing: .04em; }

label.check {
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}
label.check input { width: auto; margin-top: 2px; flex: 0 0 auto; }
label.check a { color: var(--accent); }

.banner {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0 0;
  font-size: 13px;
  background: var(--card);
}
.banner.warn { border-left-color: var(--danger); }
.banner a { color: var(--accent); }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 6px;
}
.list li:last-child { border-bottom: none; }
.list li.sel { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.list .main { font-weight: 600; }
.list .sub { font-size: 12px; color: var(--muted); }

.total {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 2px solid var(--line);
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 20;
  max-width: 90vw;
}
