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

html { background: #121212; font-size: 16px; }
@media (min-width: 700px) { html { font-size: 20px; } }

:root {
  --accent: #5B8DEF;
  --bg: #121212;
  --surface: #1A1A1A;
  --surface2: #212121;
  --border: rgba(255, 255, 255, 0.08);
  --text: #999999;
  --text-em: #F0F0F0;
  --muted: #7A7A7A;
  --dim: #555555;
  --live: #E5173A;
  --success: #22C55E;
}

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.container { max-width: 860px; margin: 0 auto; padding: 1.5rem 1rem; }
.hidden { display: none !important; }

h1, h2 { font-family: 'JetBrains Mono', monospace; color: var(--text-em); font-weight: 700; }
h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1.1rem; border-radius: 8px;
  font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 0.85rem;
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface); border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #121212; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); opacity: 0.9; }
.btn-danger { color: var(--live); }
.btn-danger:hover { border-color: var(--live); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.15rem 1.4rem; margin-bottom: 0.75rem;
  transition: border-color 0.15s;
}
.card:hover { border-color: rgba(255, 255, 255, 0.16); }

.routine-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.routine-card__info h3 { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--text-em); font-size: 1rem; }
.routine-card__info p { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
.routine-card__actions { display: flex; gap: 0.5rem; }

.input {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 0.5rem 0.85rem; color: var(--text-em); font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem; transition: border-color 0.15s; outline: none; width: 100%;
}
.input:focus { border-color: var(--accent); }

.field { margin-bottom: 1rem; }
.field label {
  display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.05em;
}

.block-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; padding: 0.25rem; border-radius: 8px; transition: opacity 0.15s, background 0.15s; }
.block-row .input { width: auto; flex: 1; min-width: 6rem; }
.block-row input[type="color"] { width: 2.5rem; height: 2.5rem; border: none; border-radius: 8px; background: none; padding: 0; cursor: pointer; }
.block-row input[type="number"] { width: 3.5rem; flex: none; }
.block-row .unit { font-size: 0.75rem; color: var(--muted); }
.drag-handle { cursor: grab; color: var(--dim); font-size: 1.2rem; padding: 0 0.25rem; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.block-row.dragging { opacity: 0.4; }
.block-row.drag-over { background: var(--surface2); box-shadow: inset 0 2px 0 var(--accent); }

.preview-stats { display: flex; gap: 1.5rem; padding: 1rem; background: var(--surface2); border-radius: 10px; margin: 1rem 0; font-size: 0.85rem; }
.preview-stats strong { color: var(--text-em); display: block; font-size: 1.1rem; }

.exec-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: clamp(1.5rem, 4vw, 2.5rem); padding: 1.5rem; transition: background 0.4s;
}
.exec-cycle { font-size: clamp(0.9rem, 2vw, 1.15rem); color: #121212; opacity: 0.75; letter-spacing: 0.05em; text-transform: uppercase; }

.exec-name-viewport {
  max-width: 100%; overflow: hidden; padding-left: 1.25rem;
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 1.25rem);
  mask-image: linear-gradient(to right, transparent 0, black 1.25rem);
}
.exec-name-track { display: flex; align-items: flex-end; gap: clamp(1.5rem, 5vw, 3rem); }
.exec-name-slot { font-family: 'JetBrains Mono', monospace; font-weight: 700; white-space: nowrap; color: #121212; transform-origin: left bottom; }
.exec-name-slot--current { font-size: clamp(1.6rem, 5vw, 2.6rem); letter-spacing: 0.12em; }
.exec-name-slot--next { font-size: clamp(1.1rem, 3.2vw, 1.7rem); letter-spacing: 0.1em; opacity: 0.4; transition: opacity 0.15s; }
.exec-name-slot--next.is-empty { opacity: 0; }

.flip-clock-frame {
  background: #000; border-radius: clamp(1rem, 3vw, 1.75rem);
  padding: clamp(1rem, 4vw, 2rem) clamp(1.25rem, 5vw, 2.5rem);
}
.flip-clock { display: flex; align-items: center; gap: clamp(0.4rem, 1.5vw, 0.75rem); }

.flip-gap { width: clamp(1rem, 4vw, 2.5rem); }

.flip-unit {
  --fs: clamp(6.5rem, 28vw, 16rem);
  position: relative; width: calc(var(--fs) * 0.72); height: var(--fs);
  font-size: var(--fs); perspective: 6em;
  border-radius: 0.1em; background: #1E1E1E;
  box-shadow: 0 0.18em 0.5em rgba(0, 0, 0, 0.45);
}
.flip-unit::after {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px;
  background: rgba(0, 0, 0, 0.75); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.09);
  z-index: 20;
}
.flip-unit__half, .flip-unit__flap {
  position: absolute; left: 0; right: 0; height: 50%; overflow: hidden; background: #1E1E1E;
}
.flip-unit__half .digit, .flip-unit__flap .digit {
  position: absolute; left: 0; right: 0; height: 200%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Helvetica Neue', Arial, sans-serif; font-weight: 700;
  color: #F5F5F5; line-height: 1; font-variant-numeric: tabular-nums;
}
.flip-unit__top, .flip-unit__flap--front { top: 0; border-radius: 0.1em 0.1em 0 0; }
.flip-unit__top .digit, .flip-unit__flap--front .digit { top: 0; }
.flip-unit__bottom, .flip-unit__flap--back { bottom: 0; border-radius: 0 0 0.1em 0.1em; }
.flip-unit__bottom .digit, .flip-unit__flap--back .digit { top: -100%; }

.flip-unit__flap {
  z-index: 10; backface-visibility: hidden; will-change: transform, filter;
}
.flip-unit__flap--front { transform-origin: bottom; background: linear-gradient(to bottom, #2A2A2A, #141414); }
.flip-unit__flap--back {
  transform-origin: top; background: linear-gradient(to top, #2A2A2A, #141414);
  transform: rotateX(90deg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.exec-progress-group { width: 100%; max-width: 640px; display: flex; flex-direction: column; gap: 1.25rem; }
.exec-progress-label { font-size: clamp(0.75rem, 1.6vw, 0.9rem); text-transform: uppercase; letter-spacing: 0.08em; color: #121212; opacity: 0.7; margin-bottom: 0.4rem; }
.exec-progress-bar { height: 10px; border-radius: 100px; background: rgba(18, 18, 18, 0.25); overflow: hidden; }
.exec-progress-fill { height: 100%; background: #121212; transition: width 0.3s linear; }
.exec-progress-text { display: flex; justify-content: space-between; font-size: clamp(0.85rem, 1.8vw, 1rem); color: #121212; margin-top: 0.4rem; opacity: 0.8; }

.exec-finish { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: clamp(1.8rem, 5vw, 2.6rem); color: var(--success); }
