* {
  box-sizing: border-box;
}

:root {
  font-family: "Segoe UI", "Roboto", "Open Sans", system-ui, -apple-system,
    sans-serif;
  --radius: 18px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Светлая тема (по умолчанию) */
:root,
:root[data-theme="light"] {
  --bg: #f5f5f7;
  --text: #1f2a37;
  --muted: #6b7280;
  --work: #1f8a70;
  --break: #f08a24;
  --surface: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 20px 60px rgba(31, 42, 55, 0.08);
}

/* Тёмная тема */
:root[data-theme="dark"] {
  --bg: #0f172a;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --work: #34d399;
  --break: #fb923c;
  --surface: #1e293b;
  --border: #334155;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* Тёплая тема */
:root[data-theme="warm"] {
  --bg: #faf8f3;
  --text: #3c2e26;
  --muted: #8b7355;
  --work: #8b6f47;
  --break: #c49a6c;
  --surface: #fff8f0;
  --border: #e8ddd4;
  --shadow: 0 20px 60px rgba(60, 46, 38, 0.1);
}

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  padding: 0 1rem 2rem;
  position: relative;
}

.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 4px;
  background: var(--work);
  z-index: 1000;
  transition: width 0.2s linear, background 0.3s ease;
  display: none;
}


main {
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.site-header {
  width: min(960px, 100%);
  margin: 2rem auto;
  text-align: center;
}

.site-header h1 {
  margin: 0.4rem 0 0.6rem;
  font-size: clamp(2rem, 4vw, 3rem);
}

.tagline {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.subtitle {
  margin: 0 auto;
  max-width: 36rem;
  color: var(--muted);
}

.timer-panel {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: center;
  transition: border 0.3s ease, box-shadow 0.3s ease;
  border: 2px solid transparent;
}

.timer-panel.work-mode {
  border-color: rgba(31, 138, 112, 0.3);
}

.timer-panel.break-mode {
  border-color: rgba(240, 138, 36, 0.3);
}

.mode-indicator {
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.timer-visualization {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-display-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.timer-display {
  font-size: clamp(3rem, 14vw, 6rem);
  font-weight: 700;
  margin: 0;
}

.circular-progress {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
}

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

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

.progress-ring-circle {
  fill: none;
  stroke: var(--work);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 565.48;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.3s ease;
}

.timer-panel.break-mode .progress-ring-circle {
  stroke: var(--break);
}

.circular-timer {
  position: absolute;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
}

.segments-progress {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
}

.segments-svg {
  width: 200px;
  height: 200px;
}

.segments-timer {
  position: absolute;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
}

.analog-clock {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
}

.clock-face {
  width: 200px;
  height: 200px;
}

.clock-circle {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}

#clockHand {
  transition: transform 0.2s linear, stroke 0.3s ease;
  transform-origin: 100 100;
}

.analog-timer {
  position: absolute;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
}

.progress-track {
  width: 100%;
  height: 12px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  position: absolute;
  inset: 0;
  width: 100%;
  transform-origin: left center;
  background: var(--work);
  transition: width 0.2s linear, background 0.3s ease;
}

.timer-panel.break-mode .progress-bar {
  background: var(--break);
}

.timer-panel.minimal-mode .timer-display {
  font-size: clamp(2rem, 10vw, 4rem);
}

.timer-panel.minimal-mode .progress-track {
  height: 4px;
  max-width: 300px;
  margin: 0 auto;
}

.timer-panel.minimal-mode .mode-indicator {
  font-size: 0.75rem;
}

.timer-panel.minimal-mode .status-message {
  font-size: 0.85rem;
}

.status-message {
  margin: 0;
  min-height: 1.5em;
  color: var(--muted);
}

.current-task {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 10px;
  border-left: 3px solid var(--work);
  color: var(--text);
  font-size: 0.95rem;
}

.current-task strong {
  color: var(--work);
}

.tasks-section {
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tasks-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.add-task-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
}

.add-task-btn:hover {
  background: var(--work);
  color: #fff;
  border-color: var(--work);
  transform: scale(1.1);
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.task-item:hover {
  border-color: var(--work);
  background: rgba(31, 138, 112, 0.05);
}

.task-item.active {
  border-color: var(--work);
  border-width: 2px;
  background: rgba(31, 138, 112, 0.1);
}

.task-item.completed {
  opacity: 0.6;
}

.task-item input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  cursor: pointer;
  accent-color: var(--work);
}

.task-item label {
  flex: 1;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
  user-select: none;
}

.task-item.completed label {
  text-decoration: line-through;
}

.delete-task-btn {
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
  border-radius: 4px;
}

.delete-task-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.tasks-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem;
  font-style: italic;
}

.add-task-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

#newTaskInput {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

#newTaskInput:focus {
  outline: 2px solid rgba(31, 138, 112, 0.4);
  border-color: transparent;
}

.add-task-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.save-task-btn,
.cancel-task-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.save-task-btn {
  background: var(--work);
  color: #fff;
  border-color: var(--work);
}

.save-task-btn:hover {
  background: var(--break);
  border-color: var(--break);
  transform: translateY(-1px);
}

.cancel-task-btn {
  background: var(--bg);
  color: var(--text);
}

.cancel-task-btn:hover {
  background: var(--muted);
  color: #fff;
}

.notes-section {
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.notes-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  margin: 0;
}

.copy-notes-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.copy-notes-btn:hover {
  background: var(--work);
  color: #fff;
  border-color: var(--work);
  transform: translateY(-1px);
}

.copy-notes-btn.copied {
  background: var(--work);
  color: #fff;
  border-color: var(--work);
}

.notes-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  min-height: 1.2em;
}

.notes-hint.success {
  color: var(--work);
  font-weight: 600;
  font-style: normal;
}

.notes-hint.error {
  color: #dc2626;
  font-weight: 600;
  font-style: normal;
}

.notes-textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.2s ease, outline 0.2s ease;
}

.notes-textarea:focus {
  outline: 2px solid rgba(31, 138, 112, 0.4);
  border-color: transparent;
}

.notes-textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

:root[data-theme="dark"] .notes-textarea:focus {
  outline-color: rgba(52, 211, 153, 0.4);
}

:root[data-theme="warm"] .notes-textarea:focus {
  outline-color: rgba(139, 111, 71, 0.4);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

#startButton {
  background: var(--work);
  color: #fff;
  box-shadow: 0 10px 30px rgba(31, 138, 112, 0.3);
}

.timer-panel.break-mode #startButton {
  background: var(--break);
  box-shadow: 0 10px 30px rgba(240, 138, 36, 0.3);
}

button.secondary {
  background: rgba(31, 42, 55, 0.08);
  color: var(--text);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

button:not(:disabled):hover {
  transform: translateY(-2px);
}

.stats-panel,
.settings-panel,
.info-panel,
.ideas-panel {
  background: var(--surface);
  padding: 1.75rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats-panel h2,
.settings-panel h2,
.info-panel h2,
.ideas-panel h2 {
  margin-top: 0;
}

.ideas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.ideas-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.idea-nav,
.idea-toggle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.idea-nav:hover,
.idea-toggle:hover {
  background: var(--work);
  color: #fff;
  border-color: var(--work);
  transform: scale(1.05);
}

.idea-nav:active,
.idea-toggle:active {
  transform: scale(0.95);
}

.idea-content {
  min-height: 80px;
  padding: 1.25rem;
  background: var(--bg);
  border-radius: 12px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.idea-content:hover {
  border-color: var(--work);
  background: rgba(31, 138, 112, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(31, 138, 112, 0.15);
}

.idea-content.copied {
  border-color: var(--work);
  background: rgba(31, 138, 112, 0.1);
}

.idea-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.6;
}

.idea-hint {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  text-align: center;
  padding: 1rem;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--work);
  margin-bottom: 0.4rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.stats-message {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 10px;
  border-left: 3px solid var(--work);
  color: var(--text);
  font-size: 0.95rem;
  text-align: center;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

label {
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

input[type="number"] {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 600;
}

input[type="number"]:focus {
  outline: 2px solid rgba(31, 138, 112, 0.4);
  border-color: transparent;
}

.settings-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.toggle-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.toggle-control {
  font-weight: 500;
  gap: 0.5rem;
  flex-direction: row;
  align-items: center;
  display: inline-flex;
}

#applyButton {
  background: #111827;
  color: #fff;
}

.field-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.field-hint.error {
  color: #dc2626;
}

.signal-sound-controls {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.signal-sound-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.signal-sound-header label {
  font-weight: 600;
  margin: 0;
  min-width: 100px;
}

#signalSoundSelect {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 180px;
  transition: border-color 0.2s ease, outline 0.2s ease;
}

#signalSoundSelect:focus {
  outline: 2px solid rgba(31, 138, 112, 0.4);
  border-color: transparent;
}

.preview-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.preview-btn:hover {
  background: var(--work);
  color: #fff;
  border-color: var(--work);
  transform: translateY(-1px);
}

.preview-btn:active {
  transform: translateY(0);
}

.ambient-sound-controls {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.ambient-sound-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.ambient-sound-header .toggle-control {
  margin: 0;
}

#ambientSoundSelect {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 150px;
  transition: border-color 0.2s ease, outline 0.2s ease;
}

#ambientSoundSelect:focus {
  outline: 2px solid rgba(31, 138, 112, 0.4);
  border-color: transparent;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.volume-control label {
  font-weight: 600;
  margin: 0;
  min-width: 80px;
}

#ambientVolume {
  flex: 1;
  min-width: 150px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#ambientVolume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--work);
  cursor: pointer;
  transition: background 0.2s ease;
}

#ambientVolume::-webkit-slider-thumb:hover {
  background: var(--break);
}

#ambientVolume::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--work);
  cursor: pointer;
  border: none;
  transition: background 0.2s ease;
}

#ambientVolume::-moz-range-thumb:hover {
  background: var(--break);
}

#volumeValue {
  font-weight: 600;
  color: var(--text);
  min-width: 45px;
  text-align: right;
}

.theme-selector {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-selector label {
  font-weight: 600;
  margin: 0;
}

#themeSelect {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.7rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 200px;
  transition: border-color 0.2s ease, outline 0.2s ease;
}

#themeSelect:focus {
  outline: 2px solid rgba(31, 138, 112, 0.4);
  border-color: transparent;
}

:root[data-theme="dark"] #themeSelect:focus {
  outline-color: rgba(52, 211, 153, 0.4);
}

:root[data-theme="warm"] #themeSelect:focus {
  outline-color: rgba(139, 111, 71, 0.4);
}

.visualization-selector {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.visualization-selector label {
  font-weight: 600;
  margin: 0;
}

#visualizationSelect {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 0.7rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 200px;
  transition: border-color 0.2s ease, outline 0.2s ease;
}

#visualizationSelect:focus {
  outline: 2px solid rgba(31, 138, 112, 0.4);
  border-color: transparent;
}

:root[data-theme="dark"] #visualizationSelect:focus {
  outline-color: rgba(52, 211, 153, 0.4);
}

:root[data-theme="warm"] #visualizationSelect:focus {
  outline-color: rgba(139, 111, 71, 0.4);
}

.info-panel p {
  margin-top: 0.6rem;
  color: var(--text);
}

footer {
  width: min(960px, 100%);
  margin: 2rem auto 0;
  padding: 1.5rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

footer a {
  text-decoration: none;
  color: var(--work);
  font-weight: 600;
  margin-left: 0.2rem;
}

@media (max-width: 640px) {
  .timer-panel {
    padding: 1.5rem;
  }

  .settings-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .toggle-group {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}

