/* ===== CSS Custom Properties ===== */
:root {
  --bg: #f5f0eb;
  --card-bg: #fff;
  --text: #2c2c2c;
  --text-secondary: #999;
  --primary: #e0694a;
  --primary-hover: #d15c3e;
  --tab-bg: #f0ebe3;
  --ring-bg: #f0ebe3;
  --ring-stroke: #e0694a;
  --btn-secondary-bg: #f0ebe3;
  --btn-secondary-text: #e0694a;
  --btn-secondary-hover: #e8dfd5;
  --shadow: 0 2px 24px rgba(0, 0, 0, 0.06);
  --overlay-bg: rgba(0, 0, 0, 0.3);
  --input-bg: #f5f0eb;
  --input-border: transparent;
  --input-focus-border: #e0694a;
  --transition-speed: 0.2s;
}

body.dark {
  --bg: #1a1a2e;
  --card-bg: #252540;
  --text: #e0e0e0;
  --text-secondary: #777;
  --tab-bg: #2a2a45;
  --ring-bg: #2a2a45;
  --btn-secondary-bg: #2a2a45;
  --btn-secondary-hover: #32325a;
  --shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
  --overlay-bg: rgba(0, 0, 0, 0.55);
  --input-bg: #1e1e38;
}

body.break {
  --primary: #4a9e69;
  --primary-hover: #3d8a58;
  --ring-stroke: #4a9e69;
  --btn-secondary-text: #4a9e69;
  --input-focus-border: #4a9e69;
}

body.dark.break {
  --primary: #5cba7a;
  --primary-hover: #4a9e69;
  --ring-stroke: #5cba7a;
  --btn-secondary-text: #5cba7a;
  --input-focus-border: #5cba7a;
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ===== Container ===== */
.container {
  text-align: center;
  padding: 36px 32px;
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: var(--shadow);
  width: 380px;
  max-width: calc(100vw - 32px);
  transition: background var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
  position: relative;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}

.header-toggles {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-speed) ease;
  color: var(--text);
  line-height: 1;
}

.icon-btn:hover {
  background: var(--tab-bg);
}

/* ===== Task Input ===== */
.task-input {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 20px;
  border: 2px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  outline: none;
  transition: border-color var(--transition-speed) ease, background var(--transition-speed) ease;
}

.task-input::placeholder {
  color: var(--text-secondary);
}

.task-input:focus {
  border-color: var(--input-focus-border);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 28px;
  background: var(--tab-bg);
  border-radius: 12px;
  padding: 4px;
  transition: background var(--transition-speed) ease;
}

.tab {
  flex: 1;
  padding: 9px 0;
  font-size: 13px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
  white-space: nowrap;
}

.tab.active {
  background: var(--card-bg);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.tab:hover:not(.active) {
  color: var(--text);
}

/* ===== Timer Ring ===== */
.timer-ring {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 28px;
}

.timer-ring svg {
  transform: rotate(-90deg);
  width: 200px;
  height: 200px;
}

.bg-ring {
  fill: none;
  stroke: var(--ring-bg);
  stroke-width: 6;
  transition: stroke var(--transition-speed) ease;
}

.progress-ring {
  fill: none;
  stroke: var(--ring-stroke);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 565.48;
  stroke-dashoffset: 0;
  transition: stroke var(--transition-speed) ease, stroke-dashoffset 0.5s linear;
}

.timer-ring.running .progress-ring {
  filter: drop-shadow(0 0 6px var(--ring-stroke));
}

.timer-ring.running svg {
  animation: pulse-ring 2s ease-in-out infinite;
}

.timer-ring.completed .progress-ring {
  stroke: #f6c343;
  filter: drop-shadow(0 0 12px #f6c343);
}

@keyframes pulse-ring {
  0%, 100% { transform: rotate(-90deg) scale(1); }
  50% { transform: rotate(-90deg) scale(1.03); }
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 44px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 2px;
  transition: color var(--transition-speed) ease;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.btn {
  padding: 10px 24px;
  font-size: 14px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.12s ease;
  outline: none;
}

.btn:active {
  transform: scale(0.95);
}

.btn-start {
  background: var(--primary);
  color: #fff;
}

.btn-start:hover {
  background: var(--primary-hover);
}

.btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-pause {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
}

.btn-pause:hover {
  background: var(--btn-secondary-hover);
}

.btn-reset {
  background: transparent;
  color: var(--text-secondary);
}

.btn-reset:hover {
  color: var(--text);
  background: var(--btn-secondary-bg);
}

/* ===== Stats ===== */
.stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 18px;
}

.stat {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat strong {
  color: var(--text);
  font-weight: 700;
}

/* ===== Keyboard Hints ===== */
.kbd-hints {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.6;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 10px;
  background: var(--tab-bg);
  border-radius: 4px;
  border: 1px solid var(--text-secondary);
  opacity: 0.6;
  vertical-align: 1px;
}

/* ===== Settings Modal ===== */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px 24px;
  width: 320px;
  max-width: calc(100vw - 48px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

.settings-panel h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.settings-header h2 {
  margin-bottom: 0;
}

.settings-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
}

.settings-close:hover {
  background: var(--tab-bg);
  color: var(--text);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.setting-row label {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.setting-row input[type="number"] {
  width: 72px;
  padding: 8px 10px;
  border: 2px solid var(--tab-bg);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  outline: none;
  transition: border-color var(--transition-speed) ease;
}

.setting-row input[type="number"]:focus {
  border-color: var(--primary);
}

.setting-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Responsive ===== */
@media (max-width: 420px) {
  .container {
    padding: 28px 20px;
    border-radius: 20px;
  }

  .title {
    font-size: 20px;
  }

  .timer-ring {
    width: 170px;
    height: 170px;
  }

  .timer-ring svg {
    width: 170px;
    height: 170px;
  }

  .timer-text {
    font-size: 36px;
  }

  .tab {
    font-size: 12px;
    padding: 7px 0;
  }

  .btn {
    padding: 9px 18px;
    font-size: 13px;
  }
}
