:root {
  --bg: #fff7f1;
  --surface: #ffffff;
  --surface-soft: #fff1e8;
  --text: #302521;
  --muted: #786a62;
  --line: #ecd9cc;
  --focus: #e84d3d;
  --focus-strong: #c9362c;
  --short: #138a7a;
  --long: #5967c8;
  --accent: var(--focus);
  --accent-strong: var(--focus-strong);
  --shadow: 0 18px 55px rgba(84, 46, 33, 0.14);
  --radius: 8px;
  --radius-large: 22px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 10%, rgba(232, 77, 61, 0.12), transparent 30%),
    linear-gradient(145deg, #fff9f4 0%, var(--bg) 55%, #f4fbf8 100%);
  color: var(--text);
  font-family: var(--font);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.app-shell[data-mode="short"] {
  --accent: var(--short);
  --accent-strong: #0b6e62;
  --surface-soft: #eaf8f4;
}

.app-shell[data-mode="long"] {
  --accent: var(--long);
  --accent-strong: #4350a8;
  --surface-soft: #eef0ff;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--focus);
  color: #fff8f4;
  box-shadow: 0 10px 28px rgba(232, 77, 61, 0.28);
}

.brand h1,
.section-heading h2,
.settings-head h2 {
  margin: 0;
}

.brand h1 {
  font-size: 26px;
  line-height: 1.1;
}

.brand p,
.settings-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(82, 52, 35, 0.08);
}

.mobile-settings-button {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
}

.timer-panel,
.side-panel,
.settings-panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(236, 217, 204, 0.88);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
}

.timer-panel {
  overflow: hidden;
}

.visual-strip {
  height: 154px;
  overflow: hidden;
  background: var(--surface-soft);
}

.visual-strip img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 56%;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 18px 22px 0;
}

.mode-button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf7;
  color: var(--text);
  padding: 10px 14px;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.mode-button span,
.stat-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.mode-button strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.mode-button.active {
  border-color: color-mix(in srgb, var(--accent) 50%, white);
  background: color-mix(in srgb, var(--accent) 12%, white);
  color: var(--accent-strong);
}

.mode-button:active,
.primary-action:active,
.secondary-action:active,
.task-editor button:active {
  transform: translateY(1px);
}

.timer-core {
  text-align: center;
  padding: 36px 24px 24px;
}

.status-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-weight: 700;
}

.time-display {
  margin: 0;
  font-size: clamp(76px, 12vw, 154px);
  line-height: 0.95;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress-ring {
  width: min(420px, 100%);
  height: 10px;
  margin: 26px auto 0;
  overflow: hidden;
  border-radius: 999px;
  background: #f3ded2;
}

.progress-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 220ms linear, background 180ms ease;
}

.state-message {
  min-height: 25px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 0 24px 28px;
}

.primary-action,
.secondary-action,
.task-editor button,
.text-button {
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 22px;
  font-weight: 700;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-action {
  background: var(--accent);
  color: white;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 28%, transparent);
}

.primary-action:hover,
.primary-action:focus-visible {
  background: var(--accent-strong);
}

.secondary-action,
.task-editor button {
  background: #fffaf7;
  border-color: var(--line);
  color: var(--text);
}

.secondary-action:hover,
.secondary-action:focus-visible,
.task-editor button:hover,
.task-editor button:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  color: var(--accent-strong);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.task-section,
.stats-section {
  min-width: 0;
}

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

.section-heading h2 {
  font-size: 18px;
}

#saveStatus {
  min-height: 18px;
  color: var(--short);
  font-size: 13px;
}

.task-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.task-editor input,
.settings-form input[type="number"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf7;
  color: var(--text);
  padding: 0 15px;
  outline: none;
}

.task-editor input:focus,
.settings-form input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.task-current,
.recommendation {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.stat-item {
  min-width: 0;
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 14px;
}

.stat-item.wide {
  grid-column: 1 / -1;
}

.stat-item strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 700;
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--accent-strong);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(48, 37, 33, 0.28);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.settings-panel {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  padding: 22px;
}

.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.settings-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.settings-form label span {
  display: block;
  margin: 0 0 7px 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf7;
  padding: 13px 14px;
}

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

.toggle-row span {
  margin: 0;
  color: var(--text);
}

.form-error {
  grid-column: 1 / -1;
  min-height: 22px;
  margin: 0;
  color: var(--focus-strong);
  font-weight: 700;
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 36%, transparent);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 20px);
    max-width: 520px;
    padding: 14px 0 24px;
  }

  .workspace,
  .timer-panel,
  .side-panel {
    width: 100%;
  }

  .brand h1 {
    font-size: 23px;
  }

  .brand p {
    display: none;
  }

  .topbar .icon-button {
    display: none;
  }

  .brand .mobile-settings-button {
    display: grid;
    width: 40px;
    height: 40px;
    margin-left: 4px;
  }

  .visual-strip {
    height: 118px;
  }

  .mode-switch {
    grid-template-columns: 1fr;
    padding: 14px 14px 0;
  }

  .mode-button {
    display: block;
    text-align: left;
  }

  .timer-core {
    padding: 28px 16px 20px;
  }

  .time-display {
    font-size: clamp(58px, 18vw, 76px);
  }

  .actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 0 16px 20px;
  }

  .side-panel {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .task-editor {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .modal-backdrop {
    padding: 0;
  }

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

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