:root {
  color-scheme: light;
  --paper: #f8f8f4;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --ink: #1d2420;
  --muted: #65706b;
  --line: #d8ddd6;
  --accent: #1d7a68;
  --accent-strong: #115a4e;
  --accent-soft: #cfe8df;
  --coral: #ca5d4f;
  --gold: #d69b24;
  --blue: #2f6f9f;
  --shadow: 0 18px 45px rgba(24, 32, 29, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(47, 111, 159, 0.12), transparent 35%),
    linear-gradient(290deg, rgba(202, 93, 79, 0.11), transparent 42%),
    var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
a.button {
  font: inherit;
}

button,
a.button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  min-width: 0;
}

.topbar,
.timer-layout,
.lower-layout,
.panel-heading,
.controls,
.actions,
.mode-tabs {
  display: flex;
}

.topbar {
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 2.5rem;
  line-height: 1.05;
}

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

.date-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  white-space: nowrap;
}

.date-pill span:last-child {
  color: var(--ink);
  font-weight: 700;
}

.timer-layout {
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}

.timer-panel,
.stats-panel,
.settings-panel,
.log-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.timer-panel {
  flex: 1 1 640px;
  padding: 24px;
}

.stats-panel {
  flex: 0 1 380px;
  padding: 22px;
}

.mode-tabs {
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mode-tab {
  min-width: 78px;
  min-height: 36px;
  padding: 7px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 6px 18px rgba(29, 122, 104, 0.14);
}

.dial-wrap {
  display: grid;
  place-items: center;
  padding: 28px 0 24px;
}

.timer-dial {
  --progress: 0deg;
  width: min(430px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 62%, transparent 63%),
    conic-gradient(var(--accent) var(--progress), #e3e7dd 0);
  box-shadow: inset 0 0 0 1px var(--line), 0 20px 60px rgba(29, 36, 32, 0.10);
  text-align: center;
}

.timer-dial.is-break {
  --accent: var(--blue);
}

.timer-dial.is-done {
  --accent: var(--gold);
}

.mode-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 800;
}

#timerHeading {
  font-size: 5.4rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.task-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.task-input:focus,
.number-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.controls {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.button:hover {
  border-color: #b9c2b8;
  transform: translateY(-1px);
}

.button.primary {
  min-width: 104px;
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #ffffff;
}

.button.primary.small {
  min-width: 0;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.9rem;
}

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

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

.quiet {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

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

.stat-tile {
  min-height: 94px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f3f7f4);
}

.stat-value {
  display: block;
  min-height: 38px;
  color: var(--ink);
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1.1;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.goal-meter {
  height: 12px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 8px;
  background: #e4e8df;
}

#goalMeterFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 180ms ease;
}

.lower-layout {
  align-items: flex-start;
  gap: 16px;
  margin-top: 16px;
  min-width: 0;
}

.settings-panel {
  flex: 0 1 430px;
  padding: 22px;
}

.log-panel {
  flex: 1 1 560px;
  padding: 22px;
}

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

.settings-grid label,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.number-input {
  width: 86px;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: right;
  outline: none;
}

.secret-field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 800;
}

.secret-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.secret-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toggle-row {
  min-height: 34px;
  margin-top: 14px;
  justify-content: flex-start;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.session-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.save-status {
  min-height: 22px;
  margin: -6px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.save-status.success {
  color: var(--accent-strong);
}

.save-status.error {
  color: var(--coral);
}

.save-layout {
  display: flex;
  align-items: stretch;
  gap: 16px;
  min-width: 0;
}

.save-panel {
  box-shadow: var(--shadow);
}

.save-list-panel {
  margin-top: 16px;
}

.save-day-status.success {
  color: var(--accent-strong);
}

.save-day-status.error {
  color: var(--coral);
}

.session-item {
  display: grid;
  grid-template-columns: minmax(70px, auto) 1fr minmax(70px, auto);
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
}

.session-item.break {
  border-left-color: var(--blue);
}

.session-time,
.session-duration {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.session-task {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.empty-state {
  min-height: 54px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .timer-layout,
  .lower-layout,
  .save-layout {
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 2rem;
  }

  .date-pill {
    width: 100%;
    justify-content: space-between;
    white-space: normal;
  }

  #timerHeading {
    font-size: 4rem;
  }

  .timer-panel,
  .stats-panel,
  .settings-panel,
  .log-panel,
  .save-panel {
    width: 100%;
    flex-basis: auto;
  }
}

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

  .timer-panel,
  .stats-panel,
  .settings-panel,
  .log-panel {
    padding: 16px;
  }

  .mode-tabs,
  .controls {
    width: 100%;
  }

  .mode-tabs,
  .controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-tab,
  .button,
  .button.primary {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .settings-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .session-item {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 4px;
  }

  #timerHeading {
    font-size: 3.15rem;
  }
}
