:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d1f23;
  --muted: #6b7280;
  --border: #e3e5e8;
  --accent: #2f6fed;
  --warn: #d97706;
  --danger: #d93a3a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1f2226;
    --text: #eceef1;
    --muted: #9aa1ab;
    --border: #30343a;
    --accent: #6b9bff;
    --warn: #fbbf24;
    --danger: #ff6b6b;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 440px;
  margin: 0 auto;
  padding: 40px 16px 48px;
}

h1 {
  font-size: 22px;
  margin: 0 0 16px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  margin: 0;
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

label {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--muted);
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  font: inherit;
  cursor: pointer;
}

button.primary {
  width: 100%;
  padding: 11px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
}

button.primary:disabled {
  opacity: 0.6;
  cursor: default;
}

button.link {
  padding: 0;
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: 0;
}

button.link:hover {
  text-decoration: underline;
}

button.danger {
  color: var(--danger);
}

.hint {
  font-size: 14px;
  color: var(--muted);
}

.error {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--danger);
}

#codes {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.name {
  font-weight: 600;
}

.code {
  padding: 6px 0;
  font: 600 38px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 2px;
  color: var(--accent);
  background: none;
  border: 0;
}

.seconds {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.timer {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  background: var(--border);
  border-radius: 2px;
}

.bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s linear;
}

.expiring .code,
.expiring .seconds {
  color: var(--warn);
}

.expiring .bar {
  background: var(--warn);
}

.copied .code {
  color: var(--muted);
}

details summary {
  font-weight: 600;
  cursor: pointer;
}

details[open] summary {
  margin-bottom: 14px;
}

.offscreen {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}
