* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-bg: #f7f5f2;
  --color-card: #fff;
  --color-card-alt: #f0ede8;
  --color-text: #4a4540;
  --color-text-muted: #8a8580;
  --color-border: #e5e0da;
  --color-accent: #a09080;
  --color-work: #c97b6b;
  --color-short-break: #7ba38a;
  --color-long-break: #7a9cb8;
  --color-today: #5b8fb9;
}

[data-theme="dark"] {
  --color-bg: #1a1917;
  --color-card: #262421;
  --color-card-alt: #2e2b28;
  --color-text: #e8e4df;
  --color-text-muted: #9a9590;
  --color-border: #3a3735;
  --color-accent: #b0a090;
}

/* 深色模式下覆寫硬編碼的 hover 背景色 */
[data-theme="dark"] .info-button:hover {
  background-color: #4a4745;
}

[data-theme="dark"] .theme-toggle-button:hover {
  background-color: #4a4745;
}

[data-theme="dark"] button:hover {
  background-color: #a09080;
}

[data-theme="dark"] .date-nav button:hover {
  background-color: #4a4745;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: var(--color-card);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--color-border);
}

.navbar h1 {
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--color-text);
}

.info-button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 50%;
  background-color: var(--color-border);
  color: var(--color-text-muted);
}

.info-button:hover {
  background-color: #d5d0ca;
}

.theme-toggle-button {
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1rem;
  border-radius: 50%;
  background-color: var(--color-border);
  color: var(--color-text-muted);
  margin-left: auto;
}

.theme-toggle-button:hover {
  background-color: #d5d0ca;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: var(--color-card);
  padding: 3rem 3.5rem;
  border-radius: 16px;
  max-width: 560px;
  width: calc(100vw - 2rem);
  position: relative;
}

.modal-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.modal-content h2:not(:first-of-type) {
  margin-top: 2.5rem;
}

.modal-content p {
  color: var(--color-text-muted);
  line-height: 2;
  font-size: 1.2rem;
}

.modal-content ul {
  list-style: none;
  color: var(--color-text);
  font-size: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-content li {
  padding-left: 1.75rem;
  position: relative;
  line-height: 1.7;
}

.modal-content li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 8px;
  height: 8px;
  background-color: var(--color-accent);
  border-radius: 50%;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  background: none;
  color: var(--color-text-muted);
}

.modal-close:hover {
  background: none;
  color: var(--color-text);
}

/* Main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 1rem;
  --section-width: 480px;
}

/* Timer Section */
.timer-section {
  position: relative;
  text-align: center;
  padding: 4rem 3rem;
  background-color: var(--color-card);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  width: var(--section-width);
  max-width: calc(100vw - 2rem);
}

/* Phase Hint */
.phase-hint {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  width: var(--section-width);
  max-width: calc(100vw - 2rem);
}

.timer-content {
  position: relative;
  z-index: 1;
}

/* Progress Ring */
.progress-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 360px;
  height: 360px;
  z-index: 0;
}

.progress-ring-bg {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 6;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--color-work);
  stroke-width: 6;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 1s linear;
}

.timer-section[data-phase="shortBreak"] .progress-ring-fill {
  stroke: var(--color-short-break);
}

.timer-section[data-phase="longBreak"] .progress-ring-fill {
  stroke: var(--color-long-break);
}

[data-testid="phase-display"] {
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.5rem 1.3rem;
  border-radius: 24px;
  display: inline-block;
}

/* Phase Colors - subtle background tint */
.timer-section[data-phase="work"] [data-testid="phase-display"] {
  color: var(--color-work);
  background-color: rgba(201, 123, 107, 0.12);
}

.timer-section[data-phase="shortBreak"] [data-testid="phase-display"] {
  color: var(--color-short-break);
  background-color: rgba(123, 163, 138, 0.12);
}

.timer-section[data-phase="longBreak"] [data-testid="phase-display"] {
  color: var(--color-long-break);
  background-color: rgba(122, 156, 184, 0.12);
}

[data-testid="timer-display"] {
  font-size: 6.5rem;
  font-weight: 300;
  color: var(--color-text);
  margin: 0.75rem 0 1.25rem;
  font-variant-numeric: tabular-nums;
}

.button-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

button {
  padding: 1rem 2.5rem;
  font-size: 1.2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background-color: var(--color-accent);
  color: #fff;
  transition: background-color 0.2s, transform 0.1s;
}

button:hover {
  background-color: #908070;
}

button:active {
  transform: scale(0.98);
}

[data-testid="cancel-button"] {
  background-color: var(--color-text-muted);
}

[data-testid="cancel-button"]:hover {
  background-color: #7a7570;
}

/* Stats Section */
.stats-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background-color: var(--color-card-alt);
  border-radius: 12px;
  width: var(--section-width);
  max-width: calc(100vw - 2rem);
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-nav span {
  white-space: nowrap;
  font-size: 1.05rem;
  color: var(--color-text-muted);
  min-width: 6.5rem;
  text-align: center;
}

.date-nav button {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  background-color: var(--color-border);
  color: var(--color-text-muted);
}

.date-nav button:hover {
  background-color: #d5d0ca;
}

.date-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stats-row {
  display: flex;
  gap: 1.5rem;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 1.05rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.stat-item [data-testid$="-count"] {
  font-weight: 600;
  color: var(--color-text);
}

.hidden {
  display: none;
}

/* Weekly Chart */
.chart-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background-color: var(--color-card-alt);
  border-radius: 12px;
  width: var(--section-width);
  max-width: calc(100vw - 2rem);
}

.chart-section h3 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 100px;
  margin-top: 2rem;
}

.chart-bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chart-bar {
  width: 32px;
  min-height: 4px;
  background-color: var(--color-border);
  border-radius: 3px 3px 0 0;
  position: relative;
}

.chart-bar[data-today="true"] {
  background-color: var(--color-today);
}

.chart-bar::before {
  content: attr(data-value);
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.chart-bar[data-today="true"]::before {
  color: var(--color-today);
}

.chart-label {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

.chart-label[data-today="true"] {
  font-weight: 600;
  color: var(--color-today);
}
