:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --bg3: #1a1a1a;
  --border: rgba(255,255,255,0.08);
  --text: #f0ede8;
  --text2: #888880;
  --text3: #444440;
  --accent-green: #3dd68c;
  --accent-red: #e24b4a;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  height: 100%;
  overflow: hidden;
  user-select: none;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.view {
  display: none;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 0 20px 24px;
}
.view.active { display: flex; }

/* TOP BAR */
.top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0 0;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
.icon-btn:hover, .icon-btn.has-alarms { color: var(--text); }
.icon-btn.has-alarms svg { stroke: var(--accent-green); }

/* RING — premier plan absolu */
.ring-container {
  position: relative;
  /* 80% de la largeur viewport, max 344px */
  width: min(80vw, 344px);
  height: min(80vw, 344px);
  flex-shrink: 0;
  margin: 4px 0 0;
  z-index: 3;
}

#ring-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.ring-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  /* Contenu centré sans débordement */
  width: 55%;
}

#pct-display {
  font-family: var(--font-display);
  /* Taille fluide — s'adapte au conteneur 55% du ring */
  font-size: clamp(28px, 10vw, 52px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
  white-space: nowrap;
}

#pct-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text2);
  font-weight: 300;
  margin-top: 2px;
}

/* INFO SOLO */
.info-solo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin: 14px 0 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.info-val {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.info-lbl {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ACTION BUTTONS */
.actions-row {
  display: flex;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.action-btn {
  flex: 1;
  background: var(--bg3);
  border: 0.5px solid var(--border);
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 13px 8px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.action-btn:hover {
  background: #1e1e1e;
  color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

/* ALARMS LIST */
#alarms-list {
  width: 100%;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  position: relative;
  z-index: 2;
}

.alarm-chip {
  background: var(--bg3);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  flex-shrink: 0;
}

.alarm-chip.fired {
  border-color: rgba(226,75,74,0.35);
  background: rgba(226,75,74,0.07);
}

.alarm-chip-left { display: flex; flex-direction: column; gap: 2px; }
.alarm-chip-type { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.alarm-chip-info { color: var(--text); }

.alarm-chip-del {
  background: none; border: none;
  color: var(--text3); cursor: pointer;
  padding: 4px; border-radius: 6px;
  transition: color 0.2s; font-size: 14px;
}
.alarm-chip-del:hover { color: var(--accent-red); }

/* OVERLAYS */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.overlay.hidden { display: none; }

.picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
}

.picker-panel {
  position: relative;
  background: var(--bg2);
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 430px;
  padding: 28px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.confirm-panel { padding: 28px 24px 36px; gap: 12px; }
.confirm-text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  align-self: flex-start;
}

.alarms-panel { max-height: 75vh; overflow-y: auto; }

.picker-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  align-self: flex-start;
}

/* BUDGET SLIDER */
.budget-input-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.budget-input-wrap input[type=range] {
  width: 100%;
  accent-color: var(--accent-green);
  cursor: pointer;
}

.budget-display {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

/* SOUND SELECT */
.sound-select-wrap { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.sound-select-wrap label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.sound-select-wrap select {
  background: var(--bg3);
  border: 0.5px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  width: 100%;
  cursor: pointer;
  appearance: none;
}

/* PICKER ACTIONS */
.picker-actions { display: flex; gap: 10px; width: 100%; }

.cancel-btn, .confirm-btn {
  flex: 1; padding: 14px;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.cancel-btn { background: var(--bg3); border: 0.5px solid var(--border); color: var(--text2); }
.cancel-btn:hover { color: var(--text); }
.confirm-btn { background: var(--text); border: none; color: var(--bg); font-weight: 500; }
.confirm-btn:hover { opacity: 0.9; }

/* ALARMS MANAGER */
#alarms-manager-list { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.alarm-mgr-item {
  background: var(--bg3); border: 0.5px solid var(--border);
  border-radius: 10px; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.alarm-mgr-item.fired { border-color: rgba(226,75,74,0.4); background: rgba(226,75,74,0.08); }
.alarm-mgr-left { display: flex; flex-direction: column; gap: 3px; }
.alarm-mgr-type { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.alarm-mgr-info { font-size: 14px; color: var(--text); }
.alarm-mgr-status { font-size: 12px; color: var(--text2); }
.alarm-mgr-del { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 6px; transition: color 0.2s; }
.alarm-mgr-del:hover { color: var(--accent-red); }

/* FIRED BANNER */
.alarm-fired-banner {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  background: var(--accent-red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 24px;
  border-radius: 0 0 16px 16px;
  z-index: 100;
  animation: slideDown 0.3s ease;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  max-width: 430px; width: 90%;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-100%); }
  to   { transform: translateX(-50%) translateY(0); }
}
