:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --admin: #b91c1c;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

/* Header bar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
}
.topbar .inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { font-weight: 700; letter-spacing: -0.01em; }
.topbar a { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.topbar a:hover { text-decoration: underline; }

/* Admin banner */
.admin-banner {
  background: var(--admin);
  color: #fff;
  text-align: center;
  font-weight: 600;
  padding: 8px;
  letter-spacing: 0.02em;
}

/* Layout */
.wrap { max-width: 620px; margin: 24px auto; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 18px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.02em; }
.subtitle { color: var(--muted); margin: 0 0 18px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

/* Ranking list */
.options { list-style: none; margin: 0; padding: 0; }
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.option + .option { margin-top: 10px; }

.badge {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.option .label { flex: 1 1 auto; font-weight: 500; }

.arrows { display: flex; flex-direction: column; gap: 4px; }
.arrows button {
  width: 30px;
  height: 22px;
  border: 1px solid var(--line);
  background: #f9fafb;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--ink);
}
.arrows button:hover:not(:disabled) { background: #eef2ff; border-color: var(--accent); }
.arrows button:disabled { opacity: 0.35; cursor: default; }

.helper { color: var(--muted); font-size: 0.85rem; margin: 14px 0 8px; text-align: center; }

label.field-label { display: block; font-weight: 600; margin: 18px 0 6px; }
textarea, input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea { min-height: 160px; resize: vertical; }

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  margin-top: 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.secondary { background: #eef2ff; color: var(--accent); }

/* Results */
.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.result-row:last-child { border-bottom: none; }
.rank-num { width: 28px; font-weight: 700; color: var(--accent); }
.result-row .label { flex: 1 1 auto; font-weight: 500; }
.result-meta { color: var(--muted); font-size: 0.85rem; text-align: right; white-space: nowrap; }
.bar {
  height: 6px;
  background: var(--accent);
  border-radius: 4px;
  margin-top: 4px;
}
.suggestion {
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
}
.suggestion + .suggestion { margin-top: 8px; }

.note { color: var(--muted); font-size: 0.9rem; }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 0.92rem; }
.msg.ok { background: #ecfdf5; color: #065f46; }
.msg.err { background: #fef2f2; color: #991b1b; }
.hidden { display: none; }
