:root {
  --bg: #111113;
  --bg-elevated: #18181b;
  --card: #1c1c20;
  --card-hover: #222226;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eeeae3;
  --muted: #8d8a84;
  --accent: #d4c4a8;
  --accent-text: #1a1916;
  --success: #8fad8f;
  --warning: #c4a574;
  --danger: #c47878;
  --info: #8fa3b8;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --nav-height: 68px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Instrument Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: #efe4d0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.public-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px 48px;
}
.public-wrap { width: min(920px, 100%); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.brand-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--bg);
}
.hero { padding: 48px 0 24px; }
.hero h1 {
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  letter-spacing: -0.04em;
  margin: 12px 0 16px;
  font-weight: 600;
}
.lede {
  color: var(--muted);
  font-size: 1.08rem;
  max-width: 42rem;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 40px;
}
.card, .panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card h3, .panel h2, .panel h3 { margin: 0 0 8px; letter-spacing: -0.02em; }
.card p, .muted, .panel p { color: var(--muted); }
.auth-card { width: min(440px, 100%); }
.auth-card h1 { margin-top: 0; letter-spacing: -0.03em; }

.btn, button.btn, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger { background: #3a2222; color: #f0c9c9; }
.btn-wide { width: 100%; }
.btn-surprise {
  width: 100%;
  padding: 16px 20px;
  letter-spacing: 0.04em;
}

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { color: var(--muted); font-size: 0.92rem; }
.field small { color: var(--muted); }
.field .error, .error { color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  background: #121214;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
}
textarea { min-height: 110px; resize: vertical; }
.checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  margin: 16px 0;
}
.checkbox input { margin-top: 4px; }

.app-shell { min-height: 100vh; padding-bottom: calc(var(--nav-height) + 16px); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg), rgba(17,17,19,0.88));
  backdrop-filter: blur(12px);
  z-index: 5;
}
.topbar-circle, .circle-switch select {
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.circle-switch select {
  background: transparent;
  border: 0;
  max-width: 180px;
}
.app-main { width: min(880px, calc(100% - 32px)); margin: 0 auto; padding: 12px 0 32px; }
.app-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-height);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #161618;
  border-top: 1px solid var(--border);
  padding: 0 6px env(safe-area-inset-bottom);
}
.app-nav a {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.app-nav a.is-active { color: var(--text); }

.subnav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.subnav a {
  white-space: nowrap;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.subnav a.is-active {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-elevated);
}

.page-title { margin: 8px 0 18px; letter-spacing: -0.03em; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.kpi {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.kpi strong { font-size: 1.6rem; letter-spacing: -0.04em; }
.list { display: grid; gap: 10px; }
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #232326;
  color: var(--muted);
}
.badge-pause { background: #3a2a22; color: #e6c7a8; }
.badge-yes { color: var(--success); }
.badge-no, .badge-hard_limit { color: var(--danger); }
.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 12px 14px;
  border-radius: 12px;
  background: #232326;
}
.flash-error { background: #3a2222; }
.flash-success { background: #223226; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}
.status-dot.status-limited { background: var(--warning); }
.status-dot.status-paused { background: var(--danger); }
.intensity { display: inline-flex; gap: 4px; }
.intensity i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  display: inline-block;
}
.intensity i.is-on { background: var(--accent); }
.steps { color: var(--muted); font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; }
.done { color: var(--success); }
.challenge-result { text-align: center; padding: 28px 12px; }
.challenge-result h2 { margin: 8px 0 16px; letter-spacing: -0.03em; }
.meta { color: var(--muted); font-size: 0.92rem; }
.role-grid, .choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.choice {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 840px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    padding-bottom: 32px;
  }
  .topbar { order: 1; position: static; }
  .app-nav {
    order: 2;
    position: sticky;
    top: 0;
    height: auto;
    grid-template-columns: repeat(5, max-content);
    justify-content: center;
    gap: 28px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
    background: rgba(17, 17, 19, 0.9);
    padding: 10px 0;
  }
  .app-nav.nav-switch { grid-template-columns: repeat(6, max-content); }
  .app-main { order: 3; }
  .app-nav a { font-size: 0.95rem; }
  .split { grid-template-columns: 1.1fr 0.9fr; }
}

@media (max-width: 720px) {
  .card-grid { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: 1fr; }
}

.app-nav a {
  position: relative;
  min-height: 48px;
  padding: 6px 2px;
  text-align: center;
}
.app-nav.nav-switch { grid-template-columns: repeat(6, 1fr); }
.app-nav.nav-switch a { font-size: 0.72rem; }
.nav-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.68rem;
  line-height: 16px;
}
.member-card {
  display: block;
  color: inherit;
}
.member-card:hover { background: var(--card-hover); }
.sheet-list { display: grid; gap: 10px; }
.sheet-item {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
.sheet-item:hover { background: var(--card-hover); color: var(--text); }
.list-form { margin: 0; }
.list-button {
  width: 100%;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 14px 0;
  min-height: 52px;
}
.tap-target {
  min-height: 44px;
  min-width: 44px;
}
.page-title { word-break: break-word; }

@media (max-width: 430px) {
  .app-main { width: calc(100% - 24px); }
  .panel, .card { padding: 18px; }
  .btn, button.btn { padding: 12px 16px; }
}
