:root {
  --bg: #f7f8fb;
  --ink: #17212b;
  --muted: #627080;
  --line: #dfe5ec;
  --surface: #ffffff;
  --teal: #136f63;
  --teal-dark: #0d5149;
  --blue: #2d5bff;
  --amber: #f2b705;
  --coral: #df5c43;
  --soft-teal: #e5f4ef;
  --soft-amber: #fff5cf;
  --soft-coral: #fdebe7;
  --shadow: 0 14px 35px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body {
  min-height: 100%;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(45, 91, 255, 0.28);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 96px;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  border-bottom: 1px solid rgba(223, 229, 236, 0.8);
  background: rgba(247, 248, 251, 0.92);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--amber);
  color: var(--ink);
}

.app-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.app-nav button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.app-nav button.active {
  background: var(--ink);
  color: #fff;
}

.content {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 36px);
}

.today-hero,
.page-title {
  display: grid;
  gap: 22px;
  margin-bottom: 18px;
}

.today-hero {
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  align-items: end;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.today-hero p:not(.eyebrow),
.page-title p:not(.eyebrow),
.support-text,
.empty {
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-card,
.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 118px;
  padding: 16px;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 2.1rem;
  line-height: 1;
}

.surface {
  margin-top: 16px;
  padding: 18px;
}

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

.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.button-card {
  display: flex;
  min-height: 132px;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 0 0 1px var(--line);
}

.button-card:hover {
  border-color: rgba(19, 111, 99, 0.35);
}

.button-card:active {
  transform: translateY(1px);
}

.button-card-top,
.history-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.button-name {
  display: block;
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.2;
}

.button-type,
.button-meta,
.history-item span,
.setup-row span,
.setup-row small,
.mini-list small {
  color: var(--muted);
  font-size: 0.9rem;
}

.button-stars,
.history-stars {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--soft-amber);
  color: #694a00;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.button-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf1f6;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.pill-good {
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.pill-muted {
  background: var(--soft-coral);
  color: #8a2e1d;
}

.primary-action,
.secondary-action,
.ghost-action,
.file-action {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 850;
  text-decoration: none;
}

.primary-action {
  border: 1px solid var(--teal-dark);
  background: var(--teal);
  color: #fff;
}

.secondary-action,
.file-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-action {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.danger {
  color: var(--coral);
}

.commitment-list,
.history-list,
.setup-list,
.mini-list,
.bar-list {
  display: grid;
  gap: 10px;
}

.commitment-row,
.history-item,
.setup-row,
.mini-list > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.commitment-row {
  display: grid;
  gap: 10px;
}

.commitment-row > div:first-child,
.setup-row,
.mini-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.commitment-row span,
.history-item p,
.note {
  color: var(--muted);
}

.progress-track,
.bar-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e8edf3;
}

.progress-track span,
.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar-track span.negative {
  background: var(--coral);
}

.history-item {
  display: grid;
  gap: 10px;
}

.history-item.adjustment .history-stars {
  background: var(--soft-coral);
  color: #8a2e1d;
}

.history-item.neutral .history-stars {
  background: #edf1f6;
  color: var(--muted);
}

.history-actions,
.row-actions,
.form-actions,
.backup-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.setup-form {
  display: grid;
  gap: 16px;
}

.quick-win-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(90px, 120px) minmax(150px, 180px) auto;
  align-items: end;
  gap: 12px;
}

.quick-win-description {
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.span-2 {
  grid-column: span 2;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.file-action {
  position: relative;
  overflow: hidden;
}

.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.quiet-danger {
  box-shadow: none;
}

.clear-history-form {
  display: grid;
  max-width: 480px;
  gap: 12px;
  margin-top: 14px;
}

.danger-action {
  border-color: #9f3422;
  background: var(--coral);
}

.danger-text {
  color: var(--coral);
}

.version-pill {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(120px, 1.4fr) 52px;
  align-items: center;
  gap: 10px;
}

.bar-row > span {
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-row strong {
  text-align: right;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 43, 0.42);
}

.modal {
  width: min(520px, 100%);
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 33, 43, 0.24);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.timer-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.timer-choice {
  display: grid;
  min-height: 74px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 900;
}

.timer-choice span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.timer-choice.active {
  border-color: var(--teal);
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.timer-face {
  display: grid;
  min-height: 210px;
  place-items: center;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fbff, #eaf6f3);
}

.timer-face span {
  align-self: end;
  color: var(--muted);
  font-weight: 800;
}

.timer-face strong {
  align-self: start;
  font-size: clamp(3rem, 14vw, 5.4rem);
  line-height: 1;
}

.timer-face.stopped {
  background: linear-gradient(135deg, #fff, var(--soft-amber));
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid rgba(13, 81, 73, 0.2);
  border-radius: 8px;
  background: var(--teal-dark);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.app-footer {
  width: min(1120px, 100%);
  margin: auto auto 0;
  padding: 8px clamp(16px, 4vw, 36px) 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

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

  .top-bar {
    align-items: center;
  }

  .brand span:last-child {
    display: none;
  }

  .app-nav {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 8;
    justify-content: space-between;
    box-shadow: var(--shadow);
  }

  .app-nav button {
    flex: 1;
    min-height: 52px;
    padding: 0 8px;
  }

  .today-hero,
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

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

  .button-card {
    min-height: 118px;
  }

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

  .quick-win-form {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .setup-row,
  .commitment-row > div:first-child,
  .mini-list > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions,
  .history-actions,
  .backup-actions,
  .modal-actions {
    width: 100%;
  }

  .row-actions > *,
  .history-actions > *,
  .backup-actions > *,
  .modal-actions > * {
    flex: 1;
  }

  .quick-win-form > * {
    width: 100%;
  }

  .modal-actions.three {
    display: grid;
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr 1fr 44px;
  }

  .timer-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toast {
    right: 10px;
    bottom: 76px;
    left: 10px;
  }

  .app-footer {
    text-align: left;
  }
}
