* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #1a1a2e;
  --panel: #16213e;
  --accent: #e8c547;
  --accent-dim: #c4a035;
  --sand: #d4a853;
  --sand-light: #e8c878;
  --glass: rgba(200, 220, 255, 0.12);
  --glass-border: rgba(200, 220, 255, 0.35);
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --track: #2a2a4a;
  --thumb: #e8c547;
  --accent-rgb: 232, 197, 71;
  --on-thumb: #1a1a2e;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(var(--accent-rgb), 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(100, 120, 200, 0.08) 0%, transparent 50%);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.app {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  height: 100%;
  padding:
    max(16px, env(safe-area-inset-top) + 8px)
    max(16px, env(safe-area-inset-right) + 8px)
    max(18px, env(safe-area-inset-bottom) + 10px)
    max(16px, env(safe-area-inset-left) + 8px);
}

body.is-demo .app {
  padding-bottom: max(88px, env(safe-area-inset-bottom) + 72px);
}

.stage {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  flex: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  gap: 12px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  height: auto;
  padding: 0 0 8px;
  justify-content: stretch;
  gap: 24px;
}

.left,
.right {
  width: 52px;
}

.slider-track {
  position: relative;
  width: 8px;
  flex: 1;
  min-height: 0;
  background: var(--track);
  border-radius: 4px;
  cursor: default;
}

.linear-time-track {
  cursor: default;
}

.linear-time-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--accent-dim), var(--accent));
  border-radius: 4px;
  transition: height 0.05s linear;
  pointer-events: none;
}

.linear-time-thumb {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 20px;
  height: 20px;
  background: var(--thumb);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: bottom 0.05s linear;
}

.speed-badge {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  line-height: 1.3;
  color: var(--on-thumb);
  background: var(--thumb);
  border: 0;
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
  appearance: none;
}

.speed-badge:hover,
.speed-badge:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.menu-btn {
  position: relative;
  top: auto;
  right: auto;
  left: auto;
  z-index: 30;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(232, 232, 240, 0.12);
  border-radius: 10px;
  background: rgba(22, 33, 62, 0.72);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.menu-btn:hover {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.menu-btn.reset-btn {
  right: auto;
  left: auto;
  margin-top: -6px;
}

.corner-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: max-content;
  align-self: flex-start;
  margin-top: -6px;
  margin-left: calc(6px - 48px);
  z-index: 30;
}

.menu-btn.shake-btn.is-shaking {
  color: var(--accent);
  animation: shake-wiggle 0.42s ease;
}

@keyframes shake-wiggle {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-2px) rotate(-7deg); }
  40% { transform: translateX(2px) rotate(7deg); }
  60% { transform: translateX(-1.5px) rotate(-4deg); }
  80% { transform: translateX(1.5px) rotate(4deg); }
}

body.is-native .shake-btn {
  display: none;
}

body.is-native .corner-actions {
  margin-left: 0;
  align-self: center;
}

.menu-btn.is-open {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.menu-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-btn svg path,
.menu-btn svg rect {
  fill: none;
}

.skin-panel {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  z-index: 29;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100vh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  padding: 12px;
  background: rgba(16, 18, 36, 0.86);
  border: 1px solid rgba(232, 232, 240, 0.12);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.skin-panel.hidden {
  display: none;
}

.skin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.skin-panel-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
}

.skin-back,
.skin-close {
  width: 28px;
  height: 28px;
  flex: none;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.skin-back {
  font-size: 18px;
}

.skin-back:hover,
.skin-close:hover {
  color: var(--text);
}

.skin-title-icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent);
  pointer-events: none;
}

.skin-lead {
  font-size: 11px;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.skin-section-title {
  margin: 14px 0 8px;
  padding-bottom: 5px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.28);
}

.skin-section-title:first-of-type {
  margin-top: 0;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.skin-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 9px;
  border: 1px solid var(--track);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.skin-card:hover {
  border-color: rgba(var(--accent-rgb), 0.35);
}

.skin-card.is-active,
.skin-card.is-preview {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

.skin-card.is-locked {
  opacity: 0.72;
}

.skin-card.is-locked:hover {
  border-color: rgba(var(--accent-rgb), 0.35);
}

.skin-card.is-demo {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.skin-swatches {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 2px;
}

.skin-swatches span {
  flex: 1;
}

.skin-card strong {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.skin-card em {
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.skin-lock-note {
  font-size: 9px;
  color: var(--accent-dim);
  line-height: 1.2;
}

.skin-lock-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px dashed rgba(var(--accent-rgb), 0.28);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
  background: rgba(var(--accent-rgb), 0.05);
}

.name-field-label {
  display: block;
  margin: 10px 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.name-field {
  width: 100%;
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid var(--track);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  resize: none;
}

.name-field:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.45);
}

.name-reset-btn {
  width: 100%;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--track);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.name-reset-btn:hover {
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.settings-hub-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.settings-hub-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--track);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.settings-hub-item:hover {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.06);
}

.settings-hub-icon {
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent);
}

.settings-hub-label {
  font-size: 14px;
  font-weight: 600;
}

.settings-hub-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.contact-lead {
  margin: 8px 0 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim);
}

.contact-mail-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  border-radius: 10px;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.contact-mail-btn:hover {
  background: rgba(var(--accent-rgb), 0.2);
}

.contact-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.contact-version {
  margin: 6px 0 0;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  opacity: 0.72;
  letter-spacing: 0.04em;
}

.display-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.display-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--track);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.display-card:hover {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.06);
}

.display-card.is-active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
}

.display-card.is-locked {
  opacity: 0.72;
}

.display-card.is-demo {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.display-lock-note {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--accent);
}

.display-preview {
  width: 54px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.28);
}

.display-preview svg {
  display: block;
  width: 100%;
  height: 100%;
}

.display-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.display-card-text strong {
  font-size: 13px;
  font-weight: 650;
}

.display-card-text em {
  font-size: 11px;
  font-style: normal;
  color: var(--text-dim);
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.language-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--track);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.language-option:hover {
  border-color: rgba(var(--accent-rgb), 0.35);
}

.language-option.is-active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
}

.language-native {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.language-code {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

html[dir="rtl"] .skin-panel-head h3,
html[dir="rtl"] .settings-hub-item {
  text-align: right;
}

html[dir="rtl"] .language-option,
html[dir="rtl"] .skin-card,
html[dir="rtl"] .display-card {
  align-items: flex-end;
  text-align: right;
}

.part-title {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.part-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.part-name {
  width: 62px;
  flex: none;
  font-size: 11px;
  color: var(--text-dim);
}

.part-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.part-chip {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  cursor: pointer;
}

.part-chip.is-active,
.part-chip.is-preview {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.fill-chip.is-demo,
.part-chip.is-demo {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.fill-chip.is-locked,
.part-chip.is-locked {
  opacity: 0.62;
  cursor: pointer;
}

.fill-row {
  align-items: flex-start;
}

.fill-chip {
  width: auto;
  height: auto;
  padding: 5px 8px 5px 22px;
  border-radius: 999px;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
}

.fill-chip::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: var(--swatch, #ccc);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.fill-chip-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text);
  pointer-events: none;
}

.center-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  max-width: 560px;
  height: 100%;
  gap: 2px;
}

.hourglass-stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  container-type: size;
}

.left,
.right {
  position: relative;
  z-index: 3;
}

.time-block {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: min(360px, 86vw);
}

.time-total {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.time-display {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: var(--text);
  cursor: pointer;
  padding: 2px 16px 0;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  min-width: 200px;
  text-align: center;
}

.time-display:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
}

#hourglassCanvas {
  --cs: min(calc(100cqh * 540 / 420), calc(100cqw * 540 / 280));
  position: absolute;
  left: 50%;
  top: calc(var(--cs) * -60 / 540);
  width: var(--cs);
  height: var(--cs);
  transform: translateX(-50%);
  cursor: pointer;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.5));
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.tilt-block {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: min(360px, 86vw);
  margin-top: 0;
}

.flow-meter {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.flow-meter-value {
  font-size: 13px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--text);
  min-height: 1.2em;
}

.flow-forward .flow-meter-value {
  color: #e8b2a8;
}

.flow-reverse .flow-meter-value {
  color: #a8dcc4;
}

.flow-stopped .flow-meter-value {
  color: var(--text-dim);
}

/* Vertical : moitié haute = temps qui remonte (vert), basse = qui s'écoule (rouge) */
.flow-meter-scale {
  display: grid;
  grid-template-rows: 1fr 2px 1fr;
  justify-items: center;
  align-items: center;
  width: 12px;
  flex: 1;
}

.flow-meter-zero {
  width: 12px;
  height: 2px;
  background: rgba(232, 232, 240, 0.28);
  border-radius: 1px;
}

.flow-meter-half {
  position: relative;
  width: 3px;
  height: 100%;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.flow-meter-half.back {
  border-radius: 3px 3px 0 0;
}

.flow-meter-half.fwd {
  border-radius: 0 0 3px 3px;
}

.flow-meter-fill {
  position: absolute;
  left: 0;
  right: 0;
  height: 0%;
  transition: height 0.08s linear;
}

.flow-meter-half.fwd .flow-meter-fill {
  top: 0;
  background: linear-gradient(180deg, #d98b7e 0%, rgba(217, 139, 126, 0.15) 100%);
  box-shadow: 0 0 12px rgba(217, 139, 126, 0.4);
}

.flow-meter-half.back .flow-meter-fill {
  bottom: 0;
  background: linear-gradient(0deg, #7dcaa6 0%, rgba(125, 202, 166, 0.15) 100%);
  box-shadow: 0 0 12px rgba(125, 202, 166, 0.4);
}

.tilt-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.tilt-caption {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 70px;
}

.tilt-caption.end {
  text-align: right;
  align-items: flex-end;
}

.tilt-sense {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tilt-arrow {
  width: 8px;
  height: 10px;
  flex: none;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tilt-sense.fwd .tilt-arrow {
  stroke: #e2705f;
}

.tilt-sense.back .tilt-arrow {
  stroke: #5cc79b;
}

.tilt-sense.fwd {
  color: #d9a096;
}

.tilt-sense.back {
  color: #8ecbb0;
}

.tilt-sense.neutral {
  color: var(--text-dim);
}

.tilt-end {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
}

.tilt-track-wrap {
  position: relative;
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
}

.slider-mid-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 16px;
  transform: translate(-50%, -50%);
  background: rgba(232, 232, 240, 0.38);
  border-radius: 1px;
  pointer-events: none;
  z-index: 0;
}

.tilt-track-wrap input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  outline: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.tilt-track-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--track);
  border-radius: 4px;
  border: none;
}

.tilt-track-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border: none;
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.45);
  cursor: grab;
}

.tilt-track-wrap input[type="range"]::-moz-range-track {
  height: 8px;
  background: var(--track);
  border-radius: 4px;
  border: none;
}

.tilt-track-wrap input[type="range"]::-ms-ticks-before,
.tilt-track-wrap input[type="range"]::-ms-ticks-after {
  display: none;
}

.tilt-track-wrap input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.45);
  cursor: grab;
}

.tilt-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tilt-legend {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Pointe vers le bas quand le temps s'écoule, vers le haut quand il remonte.
   L'épaisseur du trait traduit le débit. */
.sense-arrow {
  width: 13px;
  height: 17px;
  fill: none;
  stroke: #e2705f;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  transition: stroke-width 0.15s ease-out, stroke 0.2s, transform 0.2s;
}

.sense-arrow.is-up {
  transform: rotate(180deg);
  stroke: #5cc79b;
}

.sense-arrow .sense-bar {
  display: none;
}

.sense-arrow.is-stopped {
  stroke: #9a9ab4;
  opacity: 0.85;
  transform: none;
}

.sense-arrow.is-stopped .sense-head {
  display: none;
}

.sense-arrow.is-stopped .sense-bar {
  display: inline;
}

.tilt-slider-row.is-hidden {
  display: none;
}

.eye-slash {
  opacity: 0;
}

.eye-btn.is-off .eye-slash {
  opacity: 1;
}

.eye-btn.is-off {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.1);
}

.tilt-track-wrap.is-locked {
  opacity: 0.55;
}

.tilt-track-wrap.is-locked input[type="range"] {
  cursor: not-allowed;
}

.lock-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(232, 232, 240, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lock-btn:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--text);
}

.lock-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lock-btn:not(.is-locked) .lock-shackle {
  transform: rotate(-28deg);
  transform-origin: 8px 11px;
}

.lock-btn.is-locked {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.1);
}


.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 24px;
  min-width: 300px;
  max-width: 90vw;
}

.modal-content h3 {
  margin-bottom: 8px;
  font-weight: 500;
  text-align: center;
}

.modal-hint {
  margin: -2px 0 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-align: center;
}

.modal-content input {
  width: 100%;
  padding: 10px 14px;
  font-size: 18px;
  background: var(--bg);
  border: 1px solid var(--track);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  font-variant-numeric: tabular-nums;
}

.modal-content input:focus {
  border-color: var(--accent);
}

.time-fields {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.time-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.time-field span {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.modal-content .time-field input {
  width: 74px;
  padding: 10px 4px;
  font-size: 26px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--track);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.modal-content .time-field input::-webkit-outer-spin-button,
.modal-content .time-field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.modal-content .time-field input:focus {
  border-color: var(--accent);
}

.time-sep {
  font-size: 24px;
  font-weight: 300;
  color: var(--text-dim);
  padding-top: 8px;
}

.time-steppers {
  display: flex;
  gap: 6px;
}

.time-steppers button {
  width: 34px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--track);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.time-steppers button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.time-steppers button:active {
  background: rgba(255, 255, 255, 0.06);
}

.time-steppers svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.time-presets {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

.time-presets button[data-seconds] {
  padding: 5px 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--track);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.time-presets button[data-seconds]:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.preset-sign {
  display: flex;
  border: 1px solid var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.preset-sign button {
  width: 28px;
  padding: 5px 0;
  font-size: 14px;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.preset-sign button + button {
  border-left: 1px solid var(--track);
}

.preset-sign button:hover {
  color: var(--text);
}

.preset-sign button.is-active {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent);
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-buttons button {
  padding: 8px 18px;
  border: 1px solid var(--track);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

.modal-buttons button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.modal-buttons button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.modal-buttons button.primary:hover {
  background: var(--accent-dim);
}

@media (max-width: 700px) {
  .app {
    gap: 0;
    padding:
      max(18px, env(safe-area-inset-top) + 10px)
      4px
      max(22px, env(safe-area-inset-bottom) + 16px)
      4px;
  }

  .stage {
    gap: 0;
    width: 100%;
  }

  .menu-btn {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    right: calc(16px + env(safe-area-inset-right));
  }

  .menu-btn.reset-btn {
    right: auto;
    left: calc(16px + env(safe-area-inset-left));
  }

  .menu-btn.shake-btn {
    right: calc(16px + 40px + 8px + env(safe-area-inset-right));
    left: auto;
  }

  .corner-actions {
    display: contents;
    margin-left: 0;
  }

  .left,
  .right {
    position: absolute;
    width: 28px;
    top: calc(90px + env(safe-area-inset-top));
    bottom: 186px;
    padding: 0;
    gap: 0;
    z-index: 3;
  }

  .left {
    left: max(18px, env(safe-area-inset-left) + 10px);
  }

  .right {
    right: max(18px, env(safe-area-inset-right) + 10px);
  }

  .center-panel {
    max-width: none;
    width: 100%;
    height: 100%;
    gap: 0;
  }

  .time-block {
    padding-top: 4px;
  }

  .time-display {
    font-size: clamp(26px, 7vw, 36px);
    padding: 0 12px;
    min-width: 0;
  }

  .hourglass-stage {
    width: 100%;
  }

  .tilt-block {
    width: min(360px, 92vw);
    padding-bottom: 2px;
  }

  .tilt-block:last-child {
    padding-bottom: 14px;
  }
}

.demo-badge {
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1a1a2e;
  background: var(--accent);
}

.demo-badge.hidden {
  display: none;
}

.demo-bar {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 240;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(16, 16, 32, 0.94);
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
}

.demo-bar.hidden {
  display: none;
}

.demo-bar-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.demo-bar-copy strong {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.demo-bar-copy span {
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.demo-bar-btn {
  border: 1px solid var(--track);
  border-radius: 9px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.demo-bar-btn-all {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: var(--accent);
  color: #1a1a2e;
}

.demo-bar-quit {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

/* ─── Paywall ─────────────────────────────────────────────────────────────── */

.paywall {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(8, 8, 18, 0.72);
  backdrop-filter: blur(8px);
}

.paywall.hidden {
  display: none;
}

.paywall-card {
  position: relative;
  width: min(400px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.paywall-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.paywall-card h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 600;
  text-align: center;
  color: var(--accent);
}

.paywall-lead {
  margin: 0 0 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
  color: var(--text-dim);
}

.paywall-status {
  min-height: 1.2em;
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-align: center;
  color: #f0a060;
}

.paywall-web-note {
  margin: 0 0 14px;
  font-size: 0.85rem;
  text-align: center;
  color: var(--accent-dim);
}

.paywall-offer {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--track);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
}

.paywall-offer-lifetime {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.06);
}

.paywall-trial {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent);
}

.paywall-offer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 600;
}

.paywall-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--accent);
  color: #1a1a2e;
}

.paywall-price {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.paywall-price-hint {
  margin: 2px 0 12px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.paywall-btn {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--track);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.paywall-btn-primary {
  border-color: rgba(var(--accent-rgb), 0.5);
  background: var(--accent);
  color: #1a1a2e;
}

.paywall-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.paywall-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 18px;
  margin: 14px 0 10px;
}

.paywall-link {
  border: none;
  background: none;
  color: var(--accent-dim);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}

.paywall-legal {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
  color: var(--text-dim);
}
