:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1c1f24;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --error: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --member-colors: #2563eb, #16a34a, #d97706, #db2777, #7c3aed, #64748b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 40px;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 {
  font-size: 17px;
  margin: 0;
  text-align: center;
}

.banner {
  margin: 12px 16px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
}
.banner--warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  overflow-x: auto;
}
.tab-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.tab-btn.is-active {
  background: var(--card-bg);
  color: var(--accent);
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.summary-head {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  display: flex;
  justify-content: center;
}
.summary-total {
  text-align: center;
}
.summary-total__label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.summary-total__value {
  display: block;
  font-size: 32px;
  font-weight: 700;
}

.member-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.member-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.member-card__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.member-card__name {
  font-weight: 600;
  font-size: 15px;
}
.member-card__stats {
  font-size: 13px;
  color: var(--text-muted);
}
.member-card__stats strong {
  color: var(--text);
  font-size: 16px;
}
.bar-track {
  height: 8px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.member-card.is-other .bar-fill { background: var(--text-muted); }

.section-title {
  font-size: 14px;
  color: var(--text-muted);
  margin: 20px 0 8px;
}

.chart-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px;
}
.chart-wrap svg { width: 100%; height: auto; display: block; }

.range-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.range-form label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--text-muted);
  gap: 4px;
  flex: 1;
  min-width: 130px;
}
.range-form input[type="date"] {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.range-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.settings-readonly {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 4px;
  list-style: none;
}
.settings-readonly li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.settings-readonly li:last-child { border-bottom: none; }
.settings-readonly .alias-note {
  color: var(--text-muted);
  font-size: 12px;
}

.admin-gate {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  text-align: center;
}
.admin-gate input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 10px 0;
  font-size: 14px;
}
.admin-gate button, .settings-edit button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.error-text { color: var(--error); font-size: 13px; }
.success-text { color: var(--success); font-size: 13px; }

.settings-edit {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.member-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.member-row input {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.member-row input.member-name { flex: 1; min-width: 70px; }
.member-row input.member-aliases { flex: 2; min-width: 100px; }
.member-row button {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
}
#member-add {
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--accent);
  width: 100%;
  margin-bottom: 8px;
}
.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 6px;
}
#keywords-input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  margin-bottom: 12px;
}
#settings-save { width: 100%; margin-top: 4px; }
