:root {
  color-scheme: dark;
  --bg: #101214;
  --surface: #171a1d;
  --surface-high: #1d2125;
  --border: #343a40;
  --text: #f6f1e8;
  --muted: #999e9f;
  --green: #5dea72;
  --green-deep: #223d29;
  --amber: #ffb44c;
  --off-pad: #2b2f32;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1180px, calc(100% - 48px));
  flex: 1;
  margin: 0 auto;
  padding: 64px 0 32px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  align-items: center;
  gap: clamp(56px, 8vw, 120px);
}

.source-footer {
  padding: 0 24px 28px;
  text-align: center;
}

.source-footer a {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
}

.source-footer a:hover,
.source-footer a:focus-visible {
  color: var(--text);
}

h1 {
  margin: 0 0 38px;
  color: var(--text);
  font-size: clamp(2.5rem, 5.5vw, 4.8rem);
  font-weight: 850;
  line-height: 0.92;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.time {
  margin-left: -0.045em;
  font-variant-numeric: tabular-nums lining-nums;
  font-size: clamp(7.5rem, 16vw, 13.5rem);
  font-weight: 760;
  line-height: 0.74;
  letter-spacing: -0.075em;
  white-space: nowrap;
}

.phase {
  margin-top: 42px;
  color: var(--green);
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

body.break-mode .phase {
  color: var(--amber);
}

.timer-actions {
  margin-top: 52px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.timer-actions button {
  height: 80px;
  padding: 0 34px;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.timer-actions button:hover,
.connect-action:hover {
  transform: translateY(-2px);
}

.timer-actions button:active,
.connect-action:active {
  transform: translateY(0);
}

.timer-actions svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.primary-action {
  min-width: 250px;
  background: var(--green);
  color: #0a1b0f;
}

body.break-mode .primary-action {
  background: var(--amber);
  color: #251506;
}

body.is-waiting .primary-action {
  animation: waiting-glow 1.35s ease-in-out infinite;
}

body.break-mode.is-waiting .primary-action {
  animation-name: waiting-glow-break;
}

@keyframes waiting-glow {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(93, 234, 114, 0);
    filter: brightness(0.78);
  }

  50% {
    box-shadow: 0 0 32px rgba(93, 234, 114, 0.9);
    filter: brightness(1.08);
  }
}

@keyframes waiting-glow-break {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(255, 180, 76, 0);
    filter: brightness(0.78);
  }

  50% {
    box-shadow: 0 0 32px rgba(255, 180, 76, 0.9);
    filter: brightness(1.08);
  }
}

.secondary-action {
  min-width: 154px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.sound-action[aria-pressed="true"] {
  border-color: rgba(93, 234, 114, 0.55);
  color: var(--green);
}

.duration-settings {
  margin-top: 38px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.duration-settings label {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.number-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 600;
}

.number-wrap input {
  width: 76px;
  height: 52px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 700;
  text-align: center;
}

.number-wrap input:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(93, 234, 114, 0.45);
  outline-offset: 3px;
}

.divider {
  width: 1px;
  height: 52px;
  background: var(--border);
}

.launchpad-panel {
  align-self: center;
}

.device-status {
  min-height: 24px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 600;
}

.status-light {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #50565a;
  box-shadow: 0 0 0 5px rgba(80, 86, 90, 0.12);
}

.device-status.connected {
  color: var(--text);
}

.device-status.connected .status-light {
  background: var(--green);
  box-shadow: 0 0 18px rgba(93, 234, 114, 0.58);
}

.model-picker {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.model-picker select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.model-picker select:focus-visible {
  outline: 3px solid rgba(93, 234, 114, 0.45);
  outline-offset: 3px;
}

.launchpad-frame {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #0b0d0e;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.launchpad-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}

.pad {
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--off-pad);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.04);
  transition: background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.pad.on {
  background: var(--green);
  box-shadow: 0 0 12px rgba(93, 234, 114, 0.42), inset 0 0 8px rgba(255, 255, 255, 0.28);
}

.pad.on.current {
  animation: current-pad-pulse 1.8s ease-in-out infinite;
}

body.break-mode .pad.on {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(255, 180, 76, 0.42), inset 0 0 8px rgba(255, 255, 255, 0.22);
}

@keyframes current-pad-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.94);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.hardware-hints {
  margin: 24px 0 0;
  display: grid;
  gap: 8px;
}

.hardware-hints p {
  margin: 0;
  color: #c6c1b9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-align: center;
  text-transform: uppercase;
}

.hardware-hints strong {
  color: var(--text);
  font-weight: 750;
}

.hardware-hints span {
  padding: 0 6px;
  color: var(--green);
}

.hardware-hints p:nth-child(2) span {
  color: #ff5a54;
}

.connect-action {
  width: 100%;
  height: 50px;
  margin-top: 30px;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: var(--green-deep);
  color: var(--green);
  font-size: 0.92rem;
  font-weight: 750;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.connect-action[hidden] {
  display: none;
}

.midi-help {
  min-height: 34px;
  margin: 12px 6px 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: center;
}

@media (max-width: 850px) {
  .app-shell {
    width: min(620px, calc(100% - 36px));
    padding: 44px 0 60px;
    grid-template-columns: 1fr;
    gap: 60px;
  }

  h1 {
    margin-bottom: 30px;
  }

  .time {
    font-size: clamp(6rem, 27vw, 10rem);
  }

  .launchpad-panel {
    width: min(420px, 100%);
  }
}

@media (max-width: 500px) {
  .app-shell {
    width: min(100% - 28px, 430px);
    padding-top: 32px;
  }

  h1 {
    font-size: 2.15rem;
  }

  .phase {
    margin-top: 30px;
    font-size: 1.15rem;
  }

  .timer-actions {
    margin-top: 38px;
  }

  .timer-actions button {
    width: 100%;
    height: 64px;
  }

  .duration-settings {
    align-items: flex-start;
    gap: 18px;
  }

  .duration-settings label {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .divider {
    margin-top: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .pad.on.current {
    animation: none;
  }
}
