/* Catppuccin Mocha — https://github.com/catppuccin/catppuccin */
:root {
  --ctp-crust: #11111b;
  --ctp-mantle: #181825;
  --ctp-base: #1e1e2e;
  --ctp-surface0: #313244;
  --ctp-surface1: #45475a;
  --ctp-surface2: #585b70;
  --ctp-overlay1: #7f849c;
  --ctp-overlay2: #9399b2;
  --ctp-subtext0: #a6adc8;
  --ctp-subtext1: #bac2de;
  --ctp-text: #cdd6f4;
  --ctp-red: #f38ba8;
  --ctp-green: #a6e3a1;
  --ctp-blue: #89b4fa;

  /* Акцент меняется по режиму таймера */
  --accent: var(--ctp-red);
  --ring-size: clamp(220px, 60vmin, 300px);
  color-scheme: dark;
}

html[data-mode='short'] {
  --accent: var(--ctp-green);
}

html[data-mode='long'] {
  --accent: var(--ctp-blue);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: var(--ctp-text);
  background:
    radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 62%),
    linear-gradient(180deg, var(--ctp-base) 0%, var(--ctp-mantle) 62%, var(--ctp-crust) 100%);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background 400ms ease;
  scrollbar-width: thin;
  scrollbar-color: var(--ctp-surface2) transparent;
}

.app {
  width: min(440px, 100%);
  display: grid;
  gap: clamp(16px, 3.5vh, 26px);
}

/* ---------- header ---------- */

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ctp-subtext1);
}

.brand__logo {
  width: 24px;
  height: 24px;
  color: var(--accent);
  transition: color 300ms ease;
  pointer-events: none;
}

.brand__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.app__header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--ctp-subtext0);
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

/* ---------- режимы ---------- */

.modes {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--ctp-mantle);
  border: 1px solid var(--ctp-surface0);
  border-radius: 999px;
}

.mode {
  padding: 9px 8px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ctp-subtext0);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.mode:hover {
  color: var(--ctp-text);
}

.mode[aria-checked='true'] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--ctp-base));
}

/* ---------- таймер ---------- */

.app__main {
  display: grid;
  gap: clamp(14px, 3vh, 24px);
  justify-items: center;
}

.timer {
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
  display: grid;
  place-items: center;
}

.timer__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
  pointer-events: none;
}

.ring__track {
  fill: none;
  stroke: var(--ctp-surface0);
  stroke-width: 8;
}

.ring__value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 45%, transparent));
  transition: stroke 300ms ease, filter 300ms ease;
}

.timer__content {
  position: relative;
  text-align: center;
}

.timer__time {
  font-size: clamp(44px, 13vmin, 64px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ---------- кнопки ---------- */

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 4vw, 20px);
  width: 100%;
}

.btn-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 54px;
  height: 54px;
  padding: 0;
  color: var(--ctp-subtext1);
  background: var(--ctp-surface0);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 100ms ease;
}

.btn-icon:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface1);
}

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

.btn-icon svg {
  width: 21px;
  height: 21px;
}

.btn-icon--primary {
  width: 76px;
  height: 76px;
  color: var(--ctp-crust);
  background: var(--accent);
  box-shadow: 0 12px 32px -14px color-mix(in srgb, var(--accent) 85%, transparent);
}

.btn-icon--primary:hover {
  color: var(--ctp-crust);
  background: color-mix(in srgb, var(--accent) 82%, white);
}

.btn-icon--primary svg {
  width: 27px;
  height: 27px;
}

.btn {
  padding: 12px 20px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ctp-text);
  background: var(--ctp-surface0);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease, color 150ms ease;
}

.btn:hover {
  background: var(--ctp-surface1);
}

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

.btn--wide {
  width: 100%;
}

.btn--quiet {
  color: var(--ctp-subtext0);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--ctp-surface1);
}

.btn--quiet:hover {
  color: var(--ctp-text);
  background: var(--ctp-surface0);
}

.stats {
  margin: 0;
  font-size: 13.5px;
  color: var(--ctp-subtext0);
  text-align: center;
}

.stats strong {
  color: var(--ctp-subtext1);
  font-variant-numeric: tabular-nums;
}

/* ---------- footer ---------- */

.app__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
  font-size: 12.5px;
  color: var(--ctp-overlay1);
}

.link-btn {
  padding: 4px 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--ctp-overlay1);
  background: none;
  border: 0;
  cursor: pointer;
  text-align: right;
}

.link-btn:hover {
  color: var(--ctp-subtext0);
  text-decoration: underline;
}

.link-btn[data-state='on'] {
  color: var(--ctp-green);
}

/* ---------- диалог настроек ---------- */

.sheet {
  width: min(460px, 100%);
  max-height: 90vh;
  max-height: min(92dvh, 880px);
  margin: auto;
  padding: 0;
  color: var(--ctp-text);
  background: transparent;
  border: 0;
}

.sheet::backdrop {
  background: color-mix(in srgb, var(--ctp-crust) 74%, transparent);
  backdrop-filter: blur(6px);
}

.sheet__inner {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: inherit;
  background: var(--ctp-mantle);
  border: 1px solid var(--ctp-surface0);
  border-radius: 20px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 12px 20px;
  border-bottom: 1px solid var(--ctp-surface0);
}

.sheet__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.sheet__body {
  display: grid;
  gap: 15px;
  padding: 14px 20px 20px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--ctp-surface2) transparent;
}

.sheet__body::-webkit-scrollbar {
  width: 10px;
}

.sheet__body::-webkit-scrollbar-thumb {
  background: var(--ctp-surface1);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.sheet__body::-webkit-scrollbar-track {
  background: transparent;
}

.group {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
}

.group__title {
  padding: 0 0 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ctp-overlay1);
}

.group__actions {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0;
  font-size: 15px;
  color: var(--ctp-subtext1);
}

.field input {
  width: 82px;
  flex: none;
  padding: 8px 6px;
  font: inherit;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ctp-text);
  background: var(--ctp-surface0);
  border: 1px solid transparent;
  border-radius: 10px;
  appearance: textfield;
  -moz-appearance: textfield;
}

.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.field input:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.field select {
  min-width: 172px;
  padding: 8px 32px 8px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ctp-text);
  background-color: var(--ctp-surface0);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a6adc8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  appearance: none;
}

.field select:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0;
  font-size: 15px;
  color: var(--ctp-subtext1);
  cursor: pointer;
}

.switch input {
  position: relative;
  flex: none;
  width: 46px;
  height: 27px;
  margin: 0;
  background: var(--ctp-surface1);
  border-radius: 999px;
  cursor: pointer;
  appearance: none;
  transition: background 200ms ease;
}

.switch input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  background: var(--ctp-subtext0);
  border-radius: 50%;
  transition: transform 200ms ease, background 200ms ease;
}

.switch input:checked {
  background: var(--accent);
}

.switch input:checked::after {
  background: var(--ctp-crust);
  transform: translateX(19px);
}

.note {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ctp-overlay1);
}

/* ---------- тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(90vw, 380px);
  padding: 11px 18px;
  font-size: 13.5px;
  color: var(--ctp-text);
  background: var(--ctp-surface0);
  border: 1px solid var(--ctp-surface1);
  border-radius: 999px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  text-align: center;
  color: var(--ctp-red);
}

/* ---------- доступность ---------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- установленное приложение ---------- */

@media (display-mode: window-controls-overlay) {
  body {
    padding-top: calc(env(titlebar-area-height, 0px) + 10px);
  }

  .app__header {
    position: fixed;
    top: env(titlebar-area-y, 0px);
    left: env(titlebar-area-x, 0px);
    width: env(titlebar-area-width, 100%);
    height: env(titlebar-area-height, 44px);
    padding-inline: 8px;
    app-region: drag;
    -webkit-app-region: drag;
  }

  .app__header-actions,
  .app__header button {
    app-region: no-drag;
    -webkit-app-region: no-drag;
  }
}

@media (display-mode: standalone) {
  .icon-btn#installBtn {
    display: none;
  }
}

body.is-window #installBtn {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}
