:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(29, 29, 31, 0.12);
  --line-strong: rgba(29, 29, 31, 0.22);
  --page: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: #ffffff;
  --field: #fbfbfd;
  --accent: #1c64d8;
  --accent-strong: #0b4eb7;
  --green: #2f8f5b;
  --yellow: #d4a72c;
  --red: #d14b43;
  --orange: #c46b2d;
  --blue: #5468d4;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 14% 12%, rgba(28, 100, 216, 0.13), transparent 34%),
    radial-gradient(circle at 88% 6%, rgba(196, 107, 45, 0.12), transparent 26%),
    linear-gradient(155deg, #fbfbfd 0%, #f5f5f7 52%, #f1eee9 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  line-height: 1.35;
}

button,
input {
  font: inherit;
}

input[type="checkbox"],
input[type="range"] {
  accent-color: var(--accent);
}

button {
  border: 0;
  border-radius: 8px;
  color: white;
  background: linear-gradient(180deg, #2d75df, var(--accent));
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.26) inset, 0 8px 18px rgba(28, 100, 216, 0.2);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

button.secondary,
.file-button {
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.06);
}

button.warning,
button.setback {
  background: linear-gradient(180deg, #d8905b, var(--orange));
}

button.recovery {
  background: linear-gradient(180deg, #54a36f, var(--green));
}

button.danger,
.danger {
  background: linear-gradient(180deg, #c95f5a, #af4545);
  color: white;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.topbar,
.date-bar,
.summary-panel,
.settings-form header,
.settings-row,
.data-actions,
.sync-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  min-height: 62px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1.9rem, 4vw, 3rem);
  letter-spacing: 0;
  line-height: 1;
  font-weight: 760;
}

h2 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.12rem;
  font-weight: 720;
}

h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.topbar p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.date-bar {
  justify-content: flex-start;
  margin: 14px 0;
}

input[type="date"],
input[type="text"],
input[type="time"],
input[type="number"],
input[type="password"] {
  border: 1px solid var(--line);
  background: var(--field);
  border-radius: 8px;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
}

input[type="date"]:focus,
input[type="text"]:focus,
input[type="time"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
  border-color: rgba(28, 100, 216, 0.58);
  box-shadow: 0 0 0 3px rgba(28, 100, 216, 0.13);
  outline: none;
}

input[type="number"] {
  appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.88fr) minmax(320px, 1.12fr);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  backdrop-filter: blur(18px) saturate(1.08);
  box-shadow: var(--shadow);
}

.daily-panel,
.task-panel {
  min-height: 430px;
}

.daily-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rung-stack {
  display: grid;
  gap: 6px;
  height: 225px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(29, 29, 31, 0.08);
}

.rung {
  border-radius: 7px;
  background: rgba(60, 60, 67, 0.14);
}

.rung.filled {
  background: var(--yellow);
}

.rung.filled.full {
  background: var(--green);
}

.rung.filled.low {
  background: var(--red);
}

.rung.filled.bonus {
  background: var(--blue);
}

.success {
  color: var(--green);
  font-weight: 700;
}

.button-pair {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.task-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  width: 100%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border: 1px solid rgba(29, 29, 31, 0.08);
  text-align: left;
  min-height: 50px;
  box-shadow: none;
}

.task-row:not(:disabled):active {
  transform: translateY(1px);
}

.task-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(28, 100, 216, 0.35);
  color: var(--green);
  font-weight: 900;
  flex: 0 0 auto;
}

.bonus-entry,
.new-task,
.sync-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.divider {
  height: 1px;
  background: var(--line);
}

.bonus-list {
  display: grid;
  gap: 6px;
  max-height: 118px;
  overflow: auto;
}

.bonus-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92rem;
}

.bonus-row time,
.empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.reservoir-panel {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.reservoir-track {
  position: relative;
  height: 56px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
  border: 1px solid rgba(29, 29, 31, 0.08);
}

.reservoir-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 2%;
  border-radius: 8px;
  background: linear-gradient(90deg, #1c64d8, #6252d6);
}

.reservoir-markers {
  position: absolute;
  inset: 0;
}

.marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(60, 60, 67, 0.42);
}

.marker.earned {
  background: var(--green);
}

.tier-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.tier-list li {
  display: grid;
  gap: 2px;
  color: var(--muted);
  min-width: 0;
}

.tier-list strong,
.bank-text {
  color: var(--ink);
}

.tier-list span {
  font-size: 0.75rem;
  line-height: 1.2;
}

.tier-list .current strong {
  color: var(--green);
}

.summary-panel {
  justify-content: space-between;
  margin-top: 16px;
}

.summary-panel div {
  display: grid;
  gap: 4px;
}

.summary-panel span {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-panel strong {
  font-size: 1.35rem;
}

.leak-banner {
  position: fixed;
  left: 50%;
  top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 800;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
}

.settings-dialog {
  width: min(900px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(880px, calc(100dvh - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--panel-strong);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.settings-dialog::backdrop {
  background: rgba(29, 29, 31, 0.5);
  backdrop-filter: blur(8px);
}

.settings-form {
  display: grid;
  gap: 18px;
  padding: 18px;
  max-height: inherit;
  overflow: auto;
}

.settings-form header {
  justify-content: space-between;
  position: sticky;
  top: -18px;
  z-index: 2;
  padding-block: 2px 12px;
  background: linear-gradient(180deg, var(--panel-strong) 70%, rgba(255, 254, 250, 0));
}

.settings-form section {
  min-width: 0;
}

.settings-task-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.settings-task {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto 42px 42px 42px;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.settings-task > * {
  min-width: 0;
}

.settings-task button {
  min-width: 42px;
  padding: 0;
}

.range-label {
  display: grid;
  gap: 8px;
}

.tier-settings {
  display: grid;
  gap: 12px;
}

.tier-setting {
  display: grid;
  grid-template-columns: minmax(112px, 0.32fr) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  min-width: 0;
}

.tier-setting label,
.settings-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 0;
}

.settings-row {
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
}

.sync-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(245, 245, 247, 0.62);
}

.sync-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 0;
}

.sync-actions {
  flex-wrap: wrap;
}

#syncStatus {
  color: var(--muted);
  font-size: 0.86rem;
}

.settings-row .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.settings-row .checkbox-label input {
  width: 18px;
  height: 18px;
}

.file-button {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.file-button input {
  display: none;
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 12px;
  }

  .dashboard-grid,
  .tier-list,
  .summary-panel,
  .settings-task,
  .tier-setting,
  .settings-row,
  .data-actions,
  .sync-grid,
  .sync-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    display: grid;
  }

  .summary-panel,
  .settings-row,
  .data-actions,
  .sync-actions {
    display: grid;
    align-items: stretch;
  }

  .daily-panel,
  .task-panel {
    min-height: auto;
  }

  .settings-dialog {
    width: calc(100vw - 18px);
    max-width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
  }

  .settings-form {
    padding: 14px;
  }

  .settings-form header {
    top: -14px;
  }
}
