:root {
  --ink: #0E1815;
  --surface: #14211D;
  --surface-2: #1B2C26;
  --line: rgba(241, 237, 225, 0.12);
  --text: #F1EDE1;
  --text-dim: rgba(241, 237, 225, 0.62);
  --gold: #E3A33B;
  --teal: #4FA37A;
  --clay: #C4573F;
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  direction: rtl;
}

body {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen { padding: 22px 18px 90px; flex: 1; }
.screen.hidden { display: none; }

h1, h2, h3 { margin: 0 0 4px; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
p { color: var(--text-dim); margin: 0 0 18px; line-height: 1.8; font-size: 14px; }

.brand {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 26px;
}
.brand .mark { color: var(--gold); font-size: 22px; font-weight: 800; }
.brand .date { color: var(--text-dim); font-size: 13px; margin-inline-start: auto; }

label { display: block; font-size: 13px; color: var(--text-dim); margin: 14px 0 6px; }
input, select {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 15px;
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.btn {
  width: 100%; padding: 14px; border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  margin-top: 18px; transition: transform .12s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--gold); color: #171008; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px dashed var(--line); }
.btn-danger { background: transparent; color: var(--clay); border: 1px solid rgba(196,87,63,0.4); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 0; }

.error { color: var(--clay); font-size: 13px; margin-top: 10px; min-height: 16px; }
.link-btn { background: none; border: none; color: var(--gold); font-family: inherit; font-size: 13px; cursor: pointer; padding: 0; }

.tabs {
  display: flex; margin-top: 22px; gap: 6px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 4px;
}
.tabs button {
  flex: 1; padding: 8px 4px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim); font-family: inherit; font-size: 12px; cursor: pointer;
}
.tabs button.active { background: var(--surface-2); color: var(--gold); font-weight: 700; }

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

.habit-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.habit-row:last-child { border-bottom: none; }
.habit-info { flex: 1; min-width: 0; }
.habit-title { font-weight: 700; font-size: 15px; }
.habit-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.kind-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 700;
}
.kind-build { background: rgba(79,163,122,0.18); color: var(--teal); }
.kind-break { background: rgba(196,87,63,0.18); color: var(--clay); }
.streak { color: var(--gold); font-size: 12px; font-weight: 700; }

.check-buttons { display: flex; gap: 6px; flex-shrink: 0; }
.check-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text-dim); font-size: 18px; cursor: pointer;
}
.check-btn.on-yes.selected { background: var(--teal); color: #0E1815; border-color: var(--teal); }
.check-btn.on-no.selected { background: var(--clay); color: #241209; border-color: var(--clay); }

.empty-state { text-align: center; padding: 40px 10px; color: var(--text-dim); }
.empty-state .big { font-size: 34px; margin-bottom: 10px; }

.leader-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line);
}
.leader-row:last-child { border-bottom: none; }
.rank { width: 26px; text-align: center; font-weight: 800; color: var(--text-dim); }
.leader-row.me .rank { color: var(--gold); }
.leader-name { flex: 1; font-weight: 600; }
.leader-row.me .leader-name { color: var(--gold); }
.leader-points { font-weight: 800; font-variant-numeric: tabular-nums; }

.invite-box {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px dashed var(--gold);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 18px;
}
.invite-code { font-size: 20px; font-weight: 800; letter-spacing: 3px; color: var(--gold); direction: ltr; }

.todo-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.todo-row:last-child { border-bottom: none; }
.todo-row.done .todo-title { text-decoration: line-through; color: var(--text-dim); }
.todo-title { flex: 1; font-size: 14px; }
.todo-check {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; flex-shrink: 0; color: var(--teal); font-size: 14px;
}
.todo-row.done .todo-check { background: var(--teal); color: #0E1815; border-color: var(--teal); }
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; padding: 4px 8px; }

.bottom-nav {
  position: sticky; bottom: 0; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav button {
  flex: 1; background: none; border: none; color: var(--text-dim); font-family: inherit;
  font-size: 11px; padding: 6px 2px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.bottom-nav button .ic { font-size: 19px; }
.bottom-nav button.active { color: var(--gold); }

.spinner { text-align: center; padding: 40px; color: var(--text-dim); }
.fieldset { border: none; padding: 0; margin: 0; }
