:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dfe7f1;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #22c55e;
  --red: #ef4444;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 0%, rgba(37, 99, 235, 0.08), transparent 36%),
    linear-gradient(180deg, #f7faff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 16px;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 72px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 16px;
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.10);
}

.topnav,
.task-actions,
.subtask-actions,
.form-actions,
.share-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form { display: inline; margin: 0; }

.pill-link,
.pill-button,
.primary-button,
.small-blue-button,
.mini-button {
  border: 1px solid #d8e2ef;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.pill-link,
.pill-button {
  padding: 12px 16px;
  font-weight: 700;
}

.pill-link:hover,
.pill-button:hover,
.primary-button:hover,
.small-blue-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.primary-button,
.small-blue-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.primary-button { padding: 14px 20px; border-radius: 999px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.small-blue-button { padding: 9px 14px; border-radius: 999px; }

.ghost { background: #f8fafc; }
.danger-outline { color: #b91c1c; border-color: #fecaca; background: #fff; }
.wide { width: 100%; }

.flash-wrap { display: grid; gap: 8px; margin: 0 0 16px; }
.flash {
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}
.flash.success { border-color: #bbf7d0; background: #f0fdf4; }
.flash.error { border-color: #fecaca; background: #fff1f2; }

.admin-hero,
.public-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
}

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(26px, 4vw, 38px); line-height: 1.15; }
h2 { margin-bottom: 0; font-size: 22px; }
h3 { margin-bottom: 0; font-size: 22px; line-height: 1.25; }
h4 { margin-bottom: 0; font-size: 15px; }
.muted { color: var(--muted); margin-bottom: 0; }

.config-card,
.task-panel,
.form-card,
.login-card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.config-card {
  padding: 24px;
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 22px;
  align-items: end;
  margin-bottom: 22px;
}

.config-form { display: grid; gap: 10px; }
.token-form { justify-self: end; }

.share-url-box {
  margin-top: 14px;
}
.share-url-box input {
  flex: 1 1 340px;
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 14px;
  color: var(--blue-dark);
  background: #f8fbff;
}

.task-panel { padding: 24px 26px; }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
}
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 10px 14px;
  border: 1px solid #d8e2ef;
  border-radius: 999px;
  color: #334155;
  background: #fff;
  font-weight: 800;
}

.task-list { display: grid; gap: 0; }
.task-card {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}
.task-card:first-child { border-top: 0; }
.task-card.is-completed { opacity: .78; }

.task-row {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}
.public-task-row { grid-template-columns: 66px minmax(0, 1fr); }

.task-icon {
  width: 56px;
  height: 56px;
  border: 1px solid #dce7f4;
  border-radius: 18px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
  font-weight: 900;
  color: #ff2cb7;
}
.task-icon span {
  font-size: 22px;
  line-height: 1;
  text-align: center;
}
.task-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-title-line,
.subtask-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.task-label {
  color: var(--blue);
  font-size: 15px;
  text-decoration: none;
}
a.task-label:hover { text-decoration: underline; }
.status-badge,
.heavy-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}
.status-badge { background: #dcfce7; color: #166534; }
.heavy-badge { background: #fee2e2; color: #b91c1c; }
.task-detail {
  margin: 6px 0 10px;
  color: var(--muted);
  line-height: 1.65;
}

.progress-form,
.progress-readonly {
  display: grid;
  grid-template-columns: minmax(160px, 520px) 52px auto;
  gap: 12px;
  align-items: center;
}
.progress-readonly { grid-template-columns: minmax(160px, 520px) 52px; }

input[type="range"] {
  width: 100%;
  min-width: 160px;
  accent-color: var(--blue);
}
.range-main { accent-color: var(--blue); }
.range-sub { accent-color: var(--bar-color, var(--green)); }
.pct-text {
  color: var(--blue);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.02em;
}
.pct-text.small { font-size: 16px; color: #334155; }

.bar-bg {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e8edf6;
  border: 1px solid #cbd5e1;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  min-width: 1%;
}
.main-fill { background: var(--blue); }

.task-actions {
  justify-content: flex-end;
  max-width: 520px;
}
.task-actions form,
.subtask-actions form { margin: 0; }

.subtask-block {
  margin: 16px 0 0 82px;
  padding: 14px;
  border-radius: 20px;
  background: #f8fbff;
  border: 1px solid #e1eaf5;
}
.subtask-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.mini-link { color: var(--blue); font-weight: 800; text-decoration: none; }
.mini-link:hover { text-decoration: underline; }
.subtask-list { display: grid; gap: 10px; }
.subtask-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
}
.public-subtask-row { grid-template-columns: minmax(0, 1fr); }
.subtask-info p {
  color: var(--muted);
  line-height: 1.6;
  margin: 6px 0 8px;
}
.sub-progress-form { grid-template-columns: minmax(150px, 430px) 48px auto; }
.subtask-actions { align-items: flex-start; justify-content: flex-end; }
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.as-link { color: var(--text); }
.no-subtasks { padding: 6px 0 0; }

.public-panel { margin-top: 20px; }
.public-subtasks { margin-top: 14px; }
.completion-note {
  margin: 12px 0 0 82px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-weight: 700;
}

.login-card,
.form-card {
  width: min(760px, 100%);
  margin: 42px auto 0;
  padding: 30px;
}
.login-card { width: min(480px, 100%); }
.form-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.stack-form { display: grid; gap: 16px; }
.stack-form label { display: grid; gap: 7px; font-weight: 800; }
.stack-form label span { color: #334155; font-size: 14px; }
input[type="text"],
input[type="password"],
input[type="url"],
input[type="color"],
textarea,
select {
  width: 100%;
  border: 1px solid #d8e2ef;
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
}
input[type="color"] { min-height: 46px; padding: 5px; }
textarea { resize: vertical; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-range-line {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 56px;
  gap: 12px;
  align-items: center;
}
.check-line {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 10px !important;
  font-weight: 700 !important;
}
.check-line input { width: auto; }
.hint-box {
  padding: 12px 14px;
  border-radius: 16px;
  background: #f8fbff;
  border: 1px solid #dbeafe;
  color: #475569;
  line-height: 1.6;
}
.empty-state {
  padding: 36px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #cbd5e1;
  border-radius: 20px;
  background: #f8fafc;
}

@media (max-width: 980px) {
  .config-card { grid-template-columns: 1fr; align-items: stretch; }
  .token-form { justify-self: start; }
  .task-row { grid-template-columns: 56px minmax(0, 1fr); }
  .task-actions { grid-column: 2; justify-content: flex-start; }
  .subtask-block,
  .completion-note { margin-left: 72px; }
}

@media (max-width: 720px) {
  .page-shell { width: min(100% - 20px, 1220px); padding-top: 14px; }
  .topbar, .admin-hero, .public-hero, .form-heading { align-items: stretch; flex-direction: column; }
  .task-panel { padding: 16px; }
  .task-row, .public-task-row { grid-template-columns: 1fr; }
  .task-icon { width: 52px; height: 52px; }
  .task-actions { grid-column: auto; justify-content: flex-start; }
  .progress-form,
  .progress-readonly,
  .sub-progress-form { grid-template-columns: 1fr 48px; }
  .progress-form .small-blue-button,
  .sub-progress-form .small-blue-button { grid-column: 1 / -1; }
  .subtask-block,
  .completion-note { margin-left: 0; }
  .subtask-row { grid-template-columns: 1fr; }
  .subtask-actions { justify-content: flex-start; }
  .grid-2 { grid-template-columns: 1fr; }
  h3 { font-size: 19px; }
}
