:root {
  color-scheme: light;
  --bg: #f5f7ff;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #6b7488;
  --line: #dfe5f2;
  --brand: #6d5dfc;
  --brand-dark: #4c3fe0;
  --good: #16a875;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 18px 50px rgba(62, 72, 112, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(109, 93, 252, 0.2), transparent 36rem),
    linear-gradient(180deg, #f8faff 0%, #eef3ff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 32px;
}

.topbar,
.panel-head,
.dialog-head,
.task-head,
.task-meta,
.top-actions,
menu,
.admin-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.25rem;
}

.eyebrow {
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  font-size: 0.9rem;
}

.top-actions {
  gap: 8px;
}

.icon-button,
.pill-button,
.primary-button,
.ghost-button,
.danger-button,
.tab {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
}

.icon-button {
  width: 44px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 1.2rem;
}

.pill-button,
.ghost-button {
  background: #e8ecff;
  color: var(--brand-dark);
  padding: 0 16px;
}

.primary-button {
  background: var(--brand);
  color: white;
  padding: 0 18px;
  box-shadow: 0 12px 28px rgba(109, 93, 252, 0.28);
}

.danger-button {
  background: #fee2e2;
  color: #b91c1c;
  padding: 0 18px;
  margin-right: auto;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, #ffffff 0%, #eef0ff 100%);
  box-shadow: var(--shadow);
}

.welcome {
  font-size: 1.35rem;
  font-weight: 900;
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: conic-gradient(var(--brand) var(--progress, 0%), #dde3f6 0);
  position: relative;
  font-weight: 900;
}

.progress-ring::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: inherit;
  background: white;
}

.progress-ring span {
  position: relative;
  z-index: 1;
}

.admin-actions {
  gap: 10px;
  margin-top: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0 14px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(223, 229, 242, 0.9);
}

.tab {
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
}

.tab.active {
  background: var(--ink);
  color: white;
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 26px rgba(62, 72, 112, 0.08);
}

.task-card.done {
  border-color: rgba(22, 168, 117, 0.35);
  background: #f0fdf8;
}

.task-head {
  justify-content: space-between;
  gap: 12px;
}

.task-title {
  font-size: 1.1rem;
  font-weight: 900;
}

.task-description {
  margin-top: 6px;
  color: var(--muted);
}

.task-meta {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf1ff;
  color: #404b69;
  font-size: 0.82rem;
  font-weight: 800;
}

.chip.good {
  background: #dcfce7;
  color: #166534;
}

.chip.warn {
  background: #fef3c7;
  color: #92400e;
}

.task-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.task-actions.single {
  grid-template-columns: 1fr;
}

.task-actions button {
  min-height: 46px;
}

.activity-panel {
  width: min(760px, calc(100% - 32px));
  margin: -16px auto 28px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(223, 229, 242, 0.95);
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.badge {
  min-width: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  text-align: center;
  color: white;
  background: var(--brand);
  font-weight: 900;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  padding: 12px;
  border-radius: 14px;
  background: white;
  border: 1px solid var(--line);
}

.activity-item p {
  color: var(--muted);
  margin-top: 4px;
}

.activity-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.dialog {
  width: min(520px, calc(100% - 28px));
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(20, 26, 44, 0.48);
  backdrop-filter: blur(6px);
}

.dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-head {
  justify-content: space-between;
}

label {
  display: grid;
  gap: 6px;
  color: #3d465c;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8faff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(109, 93, 252, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.switch-row input {
  width: 22px;
  height: 22px;
}

menu {
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  margin: 8px 0 0;
}

.empty-state {
  padding: 30px 18px;
  text-align: center;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
  color: var(--muted);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #dcfce7;
  color: #166534;
  font-size: 1.8rem;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

.app-shell { min-height: auto; }
body { background: #f5f7ff; }
h1 { font-size: 2rem; line-height: 1.2; }
.eyebrow { letter-spacing: 0; }
.hero-panel { background: transparent; box-shadow: none; padding: 20px 0; }
.task-card, .dialog, .empty-state, .activity-item { border-radius: 8px; }
.activity-panel { width: 100%; margin: 28px 0; padding: 0; border: 0; background: transparent; }
.activity-item { border-radius: 8px; }
.history { margin-top: 28px; }
.history p { padding: 10px 0; border-bottom: 1px solid var(--line); }
.reward { margin: 12px 0 6px; color: #226c55; font-weight: 650; }
.access-form { display: grid; gap: 16px; margin: 24px 0 36px; max-width: 450px; }
#message:not(:empty) { padding: 12px; margin-bottom: 16px; background: #fff; border-radius: 8px; }
#message.error { color: #b91c1c; border: 1px solid #fca5a5; }
.dialog-error { color: #b91c1c; }
.task-title, .task-description, .hint, .activity-item, .history p { overflow-wrap: anywhere; }
button:disabled { opacity: .55; cursor: wait; }
button:focus-visible { outline: 3px solid #226c55; outline-offset: 3px; }
.admin-actions, .activity-actions, menu { flex-wrap: wrap; }
.progress-ring { background: #e7e3ff; }
.progress-ring::after { background: #f5f7ff; }
dialog { max-height: 90dvh; overflow-y: auto; }

@media (max-width: 560px) {
  .hero-panel {
    border-radius: 18px;
    padding: 16px;
  }

  .progress-ring {
    width: 72px;
    height: 72px;
  }

  .tabs {
    gap: 4px;
  }

  .tab {
    font-size: 0.82rem;
  }

  .field-grid,
  .task-actions {
    grid-template-columns: 1fr;
  }
}
