:root {
  color-scheme: light;
  --bg: #f7faf8;
  --surface: #ffffff;
  --surface-muted: #edf4f1;
  --text: #13201c;
  --muted: #64736e;
  --border: #d8e2de;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #f59e0b;
  --rose: #be123c;
  --shadow: 0 18px 45px rgba(19, 32, 28, 0.1);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.1), rgba(247, 250, 248, 0) 280px),
    var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sync-status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  margin: 10px 0 0;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 850;
}

.sync-status[data-state="local"] {
  background: rgba(245, 158, 11, 0.14);
  color: #92400e;
}

.sync-status[data-state="syncing"] {
  background: var(--surface-muted);
  color: var(--muted);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 10vw, 3rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(154px, 0.85fr) 1fr;
  align-items: center;
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.progress-ring {
  display: grid;
  width: 100%;
  max-width: 210px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0deg, var(--surface-muted) 0deg);
  transition: background 220ms ease;
}

.progress-ring__inner {
  display: grid;
  width: 72%;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  text-align: center;
}

.progress-ring strong {
  font-size: clamp(2rem, 11vw, 3.8rem);
  line-height: 0.92;
}

.progress-ring span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.progress-copy {
  min-width: 0;
}

.hours-readout {
  margin: 8px 0 4px;
  font-size: 1.55rem;
  font-weight: 850;
}

.remaining-readout {
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 650;
}

.primary-button,
.secondary-button,
.text-button,
.quick-buttons button,
.history-actions button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  padding: 0 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.text-button {
  min-height: 36px;
  padding: 0 10px;
  background: transparent;
  color: var(--rose);
}

.milestone-section,
.quick-entry,
.summary-grid,
.history-section {
  margin-top: 16px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.milestone-track {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.milestone {
  position: relative;
  display: grid;
  min-height: 72px;
  place-items: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
}

.milestone::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 3px solid currentColor;
  border-radius: 50%;
  background: var(--surface);
}

.milestone span {
  font-size: 0.78rem;
  font-weight: 850;
}

.milestone.is-done {
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary);
}

.milestone.is-next {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  color: var(--text);
}

.quick-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.quick-buttons button {
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.quick-buttons button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-tile {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.summary-tile strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 1.08rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-heading {
  align-items: center;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-empty,
.history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.history-empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 650;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
}

.history-main {
  min-width: 0;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 5px;
}

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
}

.history-note {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.92rem;
}

.history-actions {
  display: grid;
  grid-auto-flow: column;
  gap: 6px;
  align-self: start;
}

.history-actions button {
  width: 38px;
  min-height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.history-actions button:last-child {
  color: var(--rose);
}

.entry-dialog {
  width: min(100% - 24px, 480px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

.entry-dialog::backdrop {
  background: rgba(19, 32, 28, 0.46);
}

.entry-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.entry-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.duration-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.entry-form input,
.entry-form select,
.entry-form textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #ffffff;
  color: var(--text);
  font-weight: 650;
}

.entry-form textarea {
  min-height: 86px;
  resize: vertical;
}

.form-error {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--rose);
  font-size: 0.88rem;
  font-weight: 800;
}

.dialog-actions {
  justify-content: end;
}

.dialog-actions .primary-button {
  width: auto;
}

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

  .progress-layout {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .progress-ring {
    justify-self: center;
    max-width: 235px;
  }

  .quick-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .milestone-track {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-actions {
    grid-auto-flow: column;
    justify-content: start;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111917;
    --surface: #182320;
    --surface-muted: #20312d;
    --text: #edf7f3;
    --muted: #9db0aa;
    --border: #30433e;
    --primary: #2dd4bf;
    --primary-dark: #14b8a6;
    --accent: #fbbf24;
    --rose: #fb7185;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  }

  .entry-form input,
  .entry-form select,
  .entry-form textarea {
    background: #101816;
  }
}
