:root{
  --bg: #0b0d11;
  --panel: rgba(255,255,255,0.035);
  --panel-solid: #171a20;
  --line: rgba(255,255,255,0.09);
  --line-soft: rgba(255,255,255,0.06);
  --text: #f1ede5;
  --text-dim: #9aa0ab;
  --text-faint: #5c626d;

  --e0: rgba(255,255,255,0.05);
  --e1: #3c3129;
  --e2: #7a4a26;
  --e3: #c1701c;
  --e4: #f0961e;
  --e5: #ffca52;

  --accent: #ff7a4d;
  --accent-2: #ffb347;
  --accent-soft: rgba(255,122,77,0.16);
  --danger: #ef5b48;

  --f-display: 'Fraunces', serif;
  --f-body: 'Inter', sans-serif;
  --f-mono: 'IBM Plex Mono', monospace;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

*{ box-sizing: border-box; }
html,body{
  margin:0; padding:0;
  height:100%;
  overflow:hidden;
}
body{
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* ---------- Ambient background ---------- */
.orb{
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}
.orb-a{
  width: 620px; height: 620px;
  top: -220px; left: -160px;
  background: radial-gradient(circle, rgba(255,122,77,0.35), transparent 70%);
}
.orb-b{
  width: 560px; height: 560px;
  bottom: -240px; right: -180px;
  background: radial-gradient(circle, rgba(255,195,80,0.22), transparent 70%);
}
.noise{
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ---------- App shell (single viewport, no scroll) ---------- */
.app{
  position: relative;
  z-index: 2;
  height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 26px 40px 30px;
  max-width: 1360px;
  margin: 0 auto;
}

/* ---------- Topbar ---------- */
.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding-bottom: 22px;
  flex-shrink: 0;
}
.brand{ display:flex; align-items:center; gap:10px; }
.brand-mark{
  width: 22px; height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(255,150,60,0.5);
}
.brand-name{
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.badge{
  display:flex;
  align-items:center;
  gap:8px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  padding: 7px 14px;
  border-radius: 100px;
  backdrop-filter: blur(12px);
}
.dot-pulse{
  width:6px; height:6px; border-radius:50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse{
  0%,100%{ opacity: 1; transform: scale(1); }
  50%{ opacity: 0.4; transform: scale(0.7); }
}

.topbar-right{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-indicator{
  display:flex;
  align-items:center;
  gap:7px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-faint);
  transition: color 0.2s ease;
}
.save-indicator.saved{ color: #7fd88f; }
.save-dot{
  width:5px; height:5px; border-radius:50%;
  background: currentColor;
}

.icon-btn{
  display:flex;
  align-items:center;
  gap: 6px;
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 8px 13px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}
.icon-btn:hover:not(:disabled){ color: var(--text); border-color: var(--line); background: rgba(255,255,255,0.06); }
.icon-btn:active:not(:disabled){ transform: scale(0.96); }
.icon-btn:disabled{ opacity: 0.35; cursor: default; }

.save-btn{
  display:flex;
  align-items:center;
  gap: 7px;
  font-family: var(--f-body);
  font-size: 12.5px;
  font-weight: 600;
  color: #1a0d08;
  background: linear-gradient(100deg, var(--accent-2), var(--accent));
  border: none;
  border-radius: 9px;
  padding: 9px 15px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255,122,77,0.3);
  transition: opacity 0.12s ease, transform 0.1s ease;
}
.save-btn:hover{ opacity: 0.9; }
.save-btn:active{ transform: scale(0.96); }
.save-btn.just-saved{
  background: linear-gradient(100deg, #7fd88f, #4fb868);
  box-shadow: 0 6px 18px rgba(79,184,104,0.3);
}
.save-btn.folder-connected{
  background: linear-gradient(100deg, #7fd88f, #4fb868);
  color: #0a1a0d;
  box-shadow: 0 6px 18px rgba(79,184,104,0.25);
}
.save-btn.folder-error{
  background: linear-gradient(100deg, #ff8a6f, var(--danger));
  box-shadow: 0 6px 18px rgba(239,91,72,0.3);
}
.icon-btn.just-saved{ color: #7fd88f; border-color: rgba(127,216,143,0.4); }

/* ---------- Board layout ---------- */
.board{
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 22px;
}

.card{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Grid card ---------- */
.grid-card{
  flex: 1.5;
  padding: 34px 36px 26px;
}
.grid-card-head{ flex-shrink: 0; margin-bottom: 22px; }
.grid-card-head h1{
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.08;
  margin: 0 0 10px;
  letter-spacing: -0.015em;
}
.grid-card-head h1 em{
  font-style: italic;
  font-weight: 500;
  background: linear-gradient(100deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.grid-card-head p{
  font-size: 14px;
  color: var(--text-dim);
  margin: 0;
  max-width: 380px;
}

.month-nav{
  display:flex;
  align-items:center;
  gap: 10px;
  margin: 14px 0 4px;
  flex-shrink: 0;
}
.month-nav-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  width: 28px; height: 28px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}
.month-nav-btn:hover:not(:disabled){ color: var(--text); border-color: var(--line); background: rgba(255,255,255,0.06); }
.month-nav-btn:disabled{ opacity: 0.3; cursor: default; }
.month-nav-label{
  font-family: var(--f-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 96px;
}
.month-nav-today{
  margin-left: 4px;
  background: none;
  border: 1px solid var(--line-soft);
  border-radius: 100px;
  padding: 5px 12px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.month-nav-today:hover{ color: var(--text-dim); border-color: var(--line); }
.month-nav-today:disabled{ opacity: 0.3; cursor: default; }

.grid-wrap{
  flex: 1;
  min-height: 0;
  display:flex;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
}

.day-labels{
  display:flex;
  flex-direction: column;
  gap: clamp(4px, 0.9vh, 8px);
  flex-shrink: 0;
}
.day-labels span{
  height: clamp(20px, 3.6vh, 28px);
  display:flex;
  align-items:center;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  width: 28px;
}

.rows{
  display:flex;
  flex-direction: column;
  gap: clamp(4px, 0.9vh, 8px);
}
.row{ display:flex; gap: clamp(4px, 0.6vw, 8px); }

.dot{
  width: clamp(20px, 3.6vh, 28px);
  height: clamp(20px, 3.6vh, 28px);
  border-radius: 5px;
  border: 1px solid var(--line-soft);
  background: var(--e0);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.14s cubic-bezier(.2,.8,.3,1.4), box-shadow 0.14s ease, border-color 0.14s ease;
}
.dot:hover{
  transform: translateY(-3px) scale(1.06);
  border-color: rgba(255,255,255,0.3);
  z-index: 5;
}
.dot.level-1{ background: var(--e1); border-color: var(--e1); }
.dot.level-2{ background: var(--e2); border-color: var(--e2); }
.dot.level-3{ background: var(--e3); border-color: var(--e3); }
.dot.level-4{ background: var(--e4); border-color: var(--e4); box-shadow: 0 0 8px rgba(240,150,30,0.3); }
.dot.level-5{
  background: var(--e5);
  border-color: var(--e5);
  animation: ember-glow 2.4s ease-in-out infinite;
}
@keyframes ember-glow{
  0%,100%{ box-shadow: 0 0 10px rgba(255,202,82,0.45), 0 0 0 rgba(255,202,82,0); }
  50%{ box-shadow: 0 0 20px rgba(255,202,82,0.85), 0 0 8px rgba(255,150,60,0.4); }
}

.dot.has-cat{ position: relative; }
.cat-glow{
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 10px var(--glow-soft, transparent);
}
.cat-glow-pulse{
  animation: cat-ember-glow 2.4s ease-in-out infinite;
}
@keyframes cat-ember-glow{
  0%,100%{ box-shadow: 0 0 10px var(--glow-soft, transparent), 0 0 0 transparent; }
  50%{ box-shadow: 0 0 20px var(--glow-strong, transparent), 0 0 8px var(--glow-soft, transparent); }
}

.dot.today{ box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent); }
.dot.future{
  cursor: default;
  background: transparent;
  border-color: transparent;
  opacity: 0.25;
  background-image: repeating-linear-gradient(135deg, var(--line) 0 1px, transparent 1px 6px);
}
.dot.future:hover{ transform:none; border-color: transparent; }
.dot.pad{
  cursor: default;
  background: transparent;
  border-color: transparent;
  opacity: 0.12;
}
.dot.pad:hover{ transform:none; border-color: transparent; }
.dot.open{ border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.legend{
  display:flex;
  align-items:center;
  gap: 7px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.legend .sq{ width:12px; height:12px; border-radius:3px; border:1px solid var(--line-soft); }
.legend-hint{ margin-left: auto; }

/* ---------- Side card (tabs) ---------- */
.side-card{
  flex: 1;
  padding: 10px 10px 18px;
  min-width: 300px;
}

.tabs{
  display:flex;
  align-items: center;
  gap: 4px;
  padding: 14px 14px 0;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar{ display: none; }
.tab{
  background: none;
  border: none;
  color: var(--text-faint);
  font-family: var(--f-body);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 4px 12px;
  margin-right: 14px;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
}
.tab:hover{ color: var(--text-dim); }
.tab.active{ color: var(--text); }
.tab.active::after{
  content:"";
  position:absolute;
  left:0; right:0; bottom:0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.tab-panel{
  flex:1;
  min-height:0;
  padding: 18px 18px 4px;
  display:flex;
  flex-direction: column;
  gap: 12px;
}
.tab-panel.hidden{ display:none; }

.stat-card{
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-top{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stat-lbl{
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.stat-icon{ font-size: 13px; opacity: 0.8; }
.stat-num{
  font-family: var(--f-display);
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
  background: linear-gradient(100deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-sub{
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 6px;
}

.log-toolbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding-bottom: 4px;
  flex-shrink: 0;
}
.log-count{
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}
.clear-all-btn{
  background:none;
  border:none;
  font-family: var(--f-body);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 6px;
}
.clear-all-btn:hover{ color: var(--danger); }

.log-list{
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
.log-list::-webkit-scrollbar{ width: 5px; }
.log-list::-webkit-scrollbar-thumb{ background: var(--line); border-radius: 4px; }
.log-list::-webkit-scrollbar-track{ background: transparent; }

.log-row{
  display:flex;
  align-items:center;
  gap: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  text-align:left;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.log-row:hover{ background: rgba(255,255,255,0.045); border-color: var(--line); }
.log-row.open{ border-color: var(--accent); }
.log-swatch{
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.log-body{ min-width:0; flex:1; }
.log-date{
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.log-content{
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.log-time{
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--accent-2);
  flex-shrink: 0;
  background: rgba(255,122,77,0.1);
  padding: 3px 8px;
  border-radius: 100px;
}

.log-empty{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 20px;
}

/* ---------- Categories: chips, palette, manager ---------- */
.hidden{ display: none !important; }

.cat-row{
  display:flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cat-chip{
  display:flex;
  align-items:center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 5px 10px 5px 8px;
  font-family: var(--f-body);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.cat-chip:hover{ border-color: rgba(255,255,255,0.28); color: var(--text); }
.cat-chip.active{
  color: var(--text);
  border-color: var(--chip-color, var(--accent));
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 18%, transparent);
}
.cat-chip-dot{
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--chip-color, var(--accent));
  flex-shrink: 0;
}
.cat-chip-add{
  display:flex;
  align-items:center;
  justify-content:center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
  border: 1px dashed var(--line);
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}
.cat-chip-add:hover{ color: var(--accent-2); border-color: var(--accent-2); background: var(--accent-soft); }
.cat-chip-add.active{ color: var(--accent-2); border-color: var(--accent-2); transform: rotate(45deg); }

.cat-manager{
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cat-manager-list{
  display:flex;
  flex-direction: column;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}
.cat-manager-item{
  display:flex;
  align-items:center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.cat-manager-item .cat-chip-dot{ width: 9px; height: 9px; }
.cat-manager-item-name{ flex: 1; }
.cat-manager-item-del{
  background:none;
  border:none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  line-height: 1;
}
.cat-manager-item-del:hover{ color: var(--danger); }

.cat-new{
  display:flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.cat-new input[type="text"]{
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 12.5px;
  padding: 8px 10px;
  outline: none;
}
.cat-new input[type="text"]:focus{ border-color: var(--accent); }
.cat-palette{
  display:flex;
  flex-wrap: wrap;
  gap: 7px;
}
.cat-swatch{
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.cat-swatch:hover{ transform: scale(1.12); }
.cat-swatch.selected{ border-color: var(--text); }
.cat-new-actions{
  display:flex;
  align-items:center;
  gap: 8px;
}
.cat-new-actions input[type="color"]{
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  padding: 2px;
  cursor: pointer;
}
.cat-add-btn{ padding: 8px 14px; font-size: 12px; margin-left: auto; }

.cat-legend{
  display:flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  flex-shrink: 0;
}
.cat-legend:empty{ display: none; }
.cat-legend-item{
  display:flex;
  align-items:center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-faint);
}
.cat-legend-ramp{
  display:flex;
  gap: 2px;
}
.cat-legend-step{
  width: 8px; height: 8px;
  border-radius: 2px;
}

.day-modal-cat{
  padding: 14px 24px 0;
  flex-shrink: 0;
}

.pop-summary{
  display:flex;
  align-items:center;
  justify-content: space-between;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.pop-summary-total{
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--text);
}
.pop-breakdown{
  display:flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}
.pop-breakdown:empty{ margin: 0; }
.pop-breakdown-row{
  display:flex;
  align-items:center;
  gap: 8px;
}
.pop-breakdown-dot{
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--chip-color, var(--accent));
  flex-shrink: 0;
}
.pop-breakdown-name{
  font-size: 11.5px;
  color: var(--text-dim);
  width: 74px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pop-breakdown-bar{
  flex: 1;
  height: 6px;
  border-radius: 100px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.pop-breakdown-fill{
  height: 100%;
  border-radius: 100px;
  background: var(--chip-color, var(--accent));
}
.pop-breakdown-pct{
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  width: 34px;
  text-align: right;
  flex-shrink: 0;
}

.btn-open-hours{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 7px;
  width: 100%;
  background: var(--accent-soft);
  border: 1px solid rgba(255,122,77,0.3);
  border-radius: 8px;
  color: var(--accent-2);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.1s ease;
}
.btn-open-hours:hover{ background: rgba(255,122,77,0.24); }
.btn-open-hours:active{ transform: scale(0.98); }

.day-modal-breakdown{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 24px 16px;
  flex-shrink: 0;
}
.day-modal-breakdown:empty{ display: none; }
.breakdown-chip{
  display:flex;
  align-items:center;
  gap: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line-soft);
  border-radius: 100px;
  padding: 5px 10px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}
.breakdown-chip.dominant{
  border-color: var(--chip-color, var(--accent));
  color: var(--text);
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 16%, transparent);
}
.breakdown-chip .cat-chip-dot{ width: 8px; height: 8px; }

/* ---------- Popover (Figma-comment style) ---------- */
.popover{
  position: fixed;
  width: 300px;
  min-width: 200px;
  min-height: 150px;
  max-height: calc(100vh - 24px);
  resize: both;
  overflow: auto;
  overscroll-behavior: contain;
  background: #1a1d24;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,122,77,0.08);
  z-index: 1000;
  display: none;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.popover.visible{
  display: block;
  opacity: 1;
  transform: translateY(0) scale(1);
}
.popover::before{
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  background: #1a1d24;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
.popover.arrow-left::before{ left: -6px; top: var(--arrow-top, 18px); }
.popover.arrow-right::before{ right: -6px; top: var(--arrow-top, 18px); transform: rotate(225deg); }

.pop-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 15px 17px 10px;
}
.pop-date{
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--accent-2);
  letter-spacing: 0.02em;
}
.pop-close{
  background:none;
  border:none;
  color: var(--text-faint);
  font-size: 16px;
  cursor:pointer;
  line-height:1;
  padding: 2px 4px;
}
.pop-close:hover{ color: var(--text); }

.pop-body{ padding: 0 17px 14px; display:flex; flex-direction:column; gap: 12px; }
.field label{
  display:block;
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.field input, .field textarea{
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 13px;
  padding: 9px 11px;
  outline: none;
  resize: vertical;
  transition: border-color 0.12s ease;
}
.field input:focus, .field textarea:focus{ border-color: var(--accent); }
.field textarea{ min-height: 84px; line-height: 1.5; font-family: var(--f-body); }

.pop-foot{
  display:flex;
  justify-content: space-between;
  align-items:center;
  padding: 12px 17px 17px;
  border-top: 1px solid var(--line-soft);
  margin-top: 2px;
}
.btn{
  font-family: var(--f-body);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.12s ease, transform 0.1s ease;
}
.btn:active{ transform: scale(0.96); }
.btn:hover{ opacity: 0.9; }
.btn-save{
  background: linear-gradient(100deg, var(--accent-2), var(--accent));
  color: #1a0d08;
  border:none;
  box-shadow: 0 6px 18px rgba(255,122,77,0.3);
}
.btn-delete{ background: none; color: var(--text-faint); }
.btn-delete:hover{ color: var(--danger); }

/* ---------- Day detail modal (24h view) ---------- */
.day-modal-backdrop{
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(6,7,9,0.6);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.day-modal-backdrop.visible{
  display: flex;
  opacity: 1;
}
.day-modal{
  width: 560px;
  min-width: 320px;
  min-height: 200px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  resize: both;
  overflow: hidden;
  background: #14161c;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,122,77,0.08);
  display: flex;
  flex-direction: column;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.16s cubic-bezier(.2,.8,.3,1.3);
}
.day-modal-backdrop.visible .day-modal{
  transform: translateY(0) scale(1);
}
.day-modal-head{
  display:flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.day-modal-date{
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}
.day-modal-sub{
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 6px;
}
.day-modal-body{
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hour-segment{
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hour-segment-head{
  display:flex;
  align-items: center;
  gap: 8px;
}
.hour-segment-icon{ font-size: 13px; opacity: 0.85; }
.hour-segment-name{
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hour-segment-range{
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-faint);
  opacity: 0.6;
  margin-left: auto;
}
.hour-grid{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hour-sq{
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--e0);
  cursor: pointer;
  padding: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--f-mono);
  font-size: 8.5px;
  color: var(--text-faint);
  touch-action: none;
  user-select: none;
  transition: transform 0.12s cubic-bezier(.2,.8,.3,1.4), box-shadow 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.hour-sq:hover{
  transform: translateY(-2px) scale(1.08);
  border-color: rgba(255,255,255,0.3);
  z-index: 2;
}
.hour-sq[data-empty]:hover{
  background: var(--brush-preview-bg, var(--e0));
  border-color: var(--brush-preview, rgba(255,255,255,0.3));
}
.hour-sq.level-1{ background: var(--e1); border-color: var(--e1); color: rgba(241,237,229,0.55); }
.hour-sq.level-2{ background: var(--e2); border-color: var(--e2); color: rgba(241,237,229,0.7); }
.hour-sq.level-3{ background: var(--e3); border-color: var(--e3); color: rgba(20,10,4,0.65); }
.hour-sq.level-4{ background: var(--e4); border-color: var(--e4); color: rgba(20,10,4,0.75); box-shadow: 0 0 7px rgba(240,150,30,0.3); }
.hour-sq.level-5{
  background: var(--e5);
  border-color: var(--e5);
  color: rgba(20,10,4,0.85);
  animation: ember-glow 2.4s ease-in-out infinite;
}
.hour-sq.now{ box-shadow: 0 0 0 2px #14161c, 0 0 0 3px var(--accent); }

.day-modal-foot{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.day-modal-total{
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--accent-2);
}

/* ---------- In-app confirm dialog (replaces native confirm/alert) ---------- */
.confirm-backdrop{
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(6,7,9,0.65);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.14s ease;
}
.confirm-backdrop.visible{ display: flex; opacity: 1; }
.confirm-box{
  width: 340px;
  max-width: calc(100vw - 40px);
  background: #181b22;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,122,77,0.08);
  padding: 22px 22px 18px;
  transform: translateY(6px) scale(0.97);
  transition: transform 0.16s cubic-bezier(.2,.8,.3,1.3);
}
.confirm-backdrop.visible .confirm-box{ transform: translateY(0) scale(1); }
.confirm-title{
  font-family: var(--f-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.confirm-message{
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  white-space: pre-line;
}
.confirm-actions{
  display:flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.confirm-actions.alert-only{ justify-content: flex-end; }
.confirm-box.danger .btn-save{
  background: linear-gradient(100deg, #ff8a6f, var(--danger));
  box-shadow: 0 6px 18px rgba(239,91,72,0.3);
}

/* ---------- Toasts ---------- */
.toast-stack{
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 1400;
  display:flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast{
  display:flex;
  align-items:center;
  gap: 9px;
  background: #181b22;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 16px;
  font-family: var(--f-body);
  font-size: 12.5px;
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(.2,.8,.3,1.3);
}
.toast.visible{ opacity: 1; transform: translateY(0); }
.toast-icon{ font-size: 13px; flex-shrink: 0; }
.toast.success .toast-icon::before{ content: "✓"; color: #7fd88f; }
.toast.error .toast-icon::before{ content: "!"; color: var(--danger); }
.toast.info .toast-icon::before{ content: "●"; color: var(--accent-2); font-size: 8px; }

/* ---------- Greed is Justice tab ---------- */
.greed-quick-edit{
  margin-left: auto;
  align-self: center;
  width: 26px; height: 26px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.greed-quick-edit:hover{ color: var(--text-dim); border-color: var(--line); }

.greed-scroll{
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 18px 18px;
  display:flex;
  flex-direction: column;
  gap: 16px;
}
.greed-scroll::-webkit-scrollbar{ width: 5px; }
.greed-scroll::-webkit-scrollbar-thumb{ background: var(--line); border-radius: 4px; }

.greed-banner{
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 150px;
  background:
    linear-gradient(160deg, rgba(255,122,77,0.28), rgba(20,10,30,0.85)),
    radial-gradient(circle at 30% 20%, rgba(255,195,80,0.25), transparent 60%);
  background-size: cover;
  background-position: center;
  display:flex;
  align-items: flex-end;
}
.greed-banner-overlay{
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 16px 18px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.55) 70%);
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.greed-banner-title{
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
}
.greed-banner-quote{
  font-size: 12px;
  font-style: italic;
  color: rgba(241,237,229,0.8);
  line-height: 1.4;
}
.greed-edit-btn{
  align-self: flex-start;
  display:flex;
  align-items:center;
  gap: 6px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 11.5px;
  font-weight: 500;
  padding: 7px 12px;
  margin-top: 4px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.greed-edit-btn:hover{ background: rgba(255,255,255,0.2); }

.greed-stats{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.greed-stat-card{
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.greed-stat-label{
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.greed-stat-value{
  font-family: var(--f-display);
  font-size: 21px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.15;
}
.greed-stat-value span{
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
}
.greed-stat-value.greed-arrival{
  color: #7fd88f;
  font-size: 18px;
}
.greed-stat-sub{
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 6px;
}
.greed-progress-row{
  display:flex;
  align-items: baseline;
}
.greed-progress-pct{
  font-family: var(--f-display);
  font-size: 21px;
  font-weight: 500;
  color: var(--accent-2);
}
.greed-progress-bar{
  margin-top: 10px;
  height: 8px;
  border-radius: 100px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.greed-progress-fill{
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.greed-visions-head{
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}
.greed-visions{
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.greed-vision-card{
  display:flex;
  align-items:center;
  gap: 10px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--chip-color, var(--accent));
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.greed-vision-main{ flex: 1; min-width: 0; }
.greed-vision-cat{
  display:flex;
  align-items:center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}
.greed-vision-cat .cat-chip-dot{ width: 7px; height: 7px; }
.greed-vision-text{
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}
.greed-vision-text.empty{ color: var(--text-faint); font-style: italic; }
.greed-vision-hours{
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
}

/* ---------- Greed edit modal ---------- */
.greed-modal-backdrop{
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(6,7,9,0.6);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.greed-modal-backdrop.visible{ display: flex; opacity: 1; }
.greed-modal{
  width: 460px;
  min-width: 320px;
  min-height: 200px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 60px);
  resize: both;
  overflow: hidden;
  background: #14161c;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,122,77,0.08);
  display: flex;
  flex-direction: column;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.16s cubic-bezier(.2,.8,.3,1.3);
}
.greed-modal-backdrop.visible .greed-modal{ transform: translateY(0) scale(1); }
.greed-modal-body{
  padding: 16px 24px;
  overflow-y: auto;
  display:flex;
  flex-direction: column;
  gap: 12px;
}
.field-row{
  display:flex;
  gap: 8px;
}
.field-row .field{ flex: 1; min-width: 0; }
.field-currency{ max-width: 64px; }
.field-per{ max-width: 90px; }
.greed-form-visions{
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.greed-form-vision-row{
  display:flex;
  align-items:center;
  gap: 8px;
}
.greed-form-vision-row .cat-chip-dot{ width: 8px; height: 8px; flex-shrink: 0; }
.greed-form-vision-row span{
  font-size: 11.5px;
  color: var(--text-dim);
  width: 70px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.greed-form-vision-row input{
  flex: 1;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 12.5px;
  padding: 7px 10px;
  outline: none;
}
.greed-form-vision-row input:focus{ border-color: var(--accent); }

/* ---------- Module badge on hour squares ---------- */
.hour-sq .module-badge{
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 8px;
  line-height: 1;
  display: flex;
  gap: 2px;
  pointer-events: none;
}
.hour-sq .module-badge .mbadge{
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
}
.hour-sq .module-badge .mbadge.mbadge-tick{
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, #059669);
  color: #ffffff;
  box-shadow: 0 0 7px rgba(16, 185, 129, 0.85), 0 1px 2px rgba(0,0,0,0.45);
  border: 1px solid rgba(255, 255, 255, 0.45);
  animation: tick-pop 0.25s cubic-bezier(.2,.8,.3,1.4) forwards;
}
@keyframes tick-pop{
  from{ transform: scale(0.3); opacity: 0; }
  to{   transform: scale(1);   opacity: 1; }
}
.hour-sq .module-badge .tick-svg{
  width: 7.5px;
  height: 7.5px;
  stroke: #ffffff;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}

/* ---------- Module Radial Picker (Pinterest-style floating cards) ---------- */
#moduleRadialOverlay{
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: none;
}

/* Source pulse dot — appears at the long-pressed square center */
.module-radial-source{
  position: fixed;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(127,216,143,0.28) 0%, transparent 70%);
  box-shadow: 0 0 0 2px rgba(127,216,143,0.4), 0 0 0 6px rgba(127,216,143,0.12);
  pointer-events: none;
  animation: radial-src-in 0.28s cubic-bezier(.2,.8,.3,1.3) forwards;
}
@keyframes radial-src-in{
  from{ transform: translate(-50%,-50%) scale(0); opacity:0; }
  to{   transform: translate(-50%,-50%) scale(1); opacity:1; }
}

/* Connecting line from source to each card (decorative) */
.module-radial-line{
  position: fixed;
  height: 1px;
  background: linear-gradient(90deg, rgba(127,216,143,0.3), rgba(127,216,143,0));
  transform-origin: 0 50%;
  pointer-events: none;
  opacity: 0;
  animation: radial-line-in 0.22s ease 0.1s forwards;
}
@keyframes radial-line-in{
  to{ opacity: 1; }
}

/* Each module card */
.module-radial-card{
  position: fixed;
  width: 76px;
  height: 86px;
  border-radius: 20px;
  background: rgba(18, 20, 28, 0.95);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  box-shadow:
    0 16px 48px rgba(0,0,0,0.65),
    0 0 0 1px rgba(255,255,255,0.06),
    inset 0 1px 0 rgba(255,255,255,0.09);
  transform: scale(0);
  opacity: 0;
  /* transition set by JS per card for staggered entrance */
}
.module-radial-card:hover{
  background: rgba(24, 27, 36, 0.98);
  border-color: rgba(255,255,255,0.22);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.75),
    0 0 0 1px rgba(255,255,255,0.14),
    0 0 28px rgba(127,216,143,0.18),
    inset 0 1px 0 rgba(255,255,255,0.12);
}
.module-radial-card:active{
  transform: scale(0.92) !important;
}
.module-radial-card.has-data{
  border-color: rgba(127,216,143,0.45);
  background: rgba(12,22,16,0.95);
}
.module-radial-card.has-data:hover{
  border-color: rgba(127,216,143,0.7);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.75),
    0 0 0 1px rgba(127,216,143,0.3),
    0 0 32px rgba(127,216,143,0.25),
    inset 0 1px 0 rgba(127,216,143,0.15);
}

.module-radial-icon{
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
  transition: transform 0.18s cubic-bezier(.2,.8,.3,1.5);
}
.module-radial-card:hover .module-radial-icon{
  transform: scale(1.18) translateY(-2px);
}
.module-radial-label{
  font-family: var(--f-body);
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(241,237,229,0.75);
  letter-spacing: 0.02em;
  text-align: center;
}
.module-radial-card:hover .module-radial-label{
  color: rgba(241,237,229,0.95);
}

/* Green "has data" dot indicator */
.module-radial-dot{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7fd88f;
  box-shadow: 0 0 8px rgba(127,216,143,0.9);
  animation: dot-pulse 2s ease-in-out infinite;
}
@keyframes dot-pulse{
  0%,100%{ box-shadow: 0 0 6px rgba(127,216,143,0.8); }
  50%{     box-shadow: 0 0 14px rgba(127,216,143,1); }
}
.module-radial-tick{
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.45);
}
.module-radial-tick .tick-svg{
  width: 9px;
  height: 9px;
  stroke: #ffffff;
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Workout Panel (slides over module picker) ---------- */
.workout-panel-backdrop{
  position: fixed;
  inset: 0;
  z-index: 1700;
  background: rgba(6,7,9,0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.workout-panel-backdrop.visible{
  display: flex;
  opacity: 1;
}
.workout-panel{
  width: 100%;
  max-width: 480px;
  background: #181b22;
  border: 1px solid rgba(255,255,255,0.1);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 16px 20px 32px;
  box-shadow: 0 -24px 60px rgba(0,0,0,0.5);
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(.2,.8,.3,1.2);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.workout-panel-backdrop.visible .workout-panel{
  transform: translateY(0);
}
.workout-panel-handle{
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  margin: 0 auto 14px;
  flex-shrink: 0;
}
.workout-panel-head{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.workout-panel-icon{
  font-size: 22px;
  line-height: 1;
}
.workout-panel-title{
  font-family: var(--f-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.workout-panel-hour-badge{
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-faint);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 3px 8px;
}
.workout-panel-close{
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.12s;
}
.workout-panel-close:hover{ color: var(--text); }
.workout-panel-body{
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.workout-panel-body::-webkit-scrollbar{ width: 4px; }
.workout-panel-body::-webkit-scrollbar-thumb{ background: var(--line); border-radius: 2px; }

/* Exercise list rows */
.workout-ex-row{
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 12px;
  animation: workout-row-in 0.18s ease forwards;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.workout-ex-row.is-done{
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.28);
}
.workout-ex-tick{
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
  color: transparent;
  padding: 0;
}
.workout-ex-tick:hover{
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.12);
}
.workout-ex-tick.is-done{
  background: linear-gradient(135deg, #34d399, #059669);
  border-color: #34d399;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.45);
}
.workout-ex-tick .tick-svg{
  width: 11px;
  height: 11px;
  stroke: #ffffff;
  stroke-width: 2.3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@keyframes workout-row-in{
  from{ opacity:0; transform: translateY(6px); }
  to{ opacity:1; transform: translateY(0); }
}
.workout-ex-icon{
  font-size: 18px;
  flex-shrink: 0;
}
.workout-ex-info{
  flex: 1;
  min-width: 0;
}
.workout-ex-name{
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.workout-ex-val{
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--accent-2);
  margin-top: 2px;
}
.workout-ex-del{
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
}
.workout-ex-del:hover{
  color: var(--danger);
  background: rgba(239,91,72,0.1);
}
.workout-ex-empty{
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 20px 0 8px;
  font-style: italic;
}

/* Add exercise form */
.workout-add-form{
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
  margin-top: 6px;
}
.workout-add-row{
  display: flex;
  gap: 6px;
}
.workout-add-row input{
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}
.workout-add-row input:focus{ border-color: var(--accent); }
.workout-add-row .workout-val-input{
  max-width: 80px;
  text-align: center;
}
.workout-add-btn{
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.12s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(255,122,77,0.3);
}
.workout-add-btn:hover{ opacity: 0.85; }
.workout-add-btn:active{ transform: scale(0.92); }
.workout-unit-select{
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--f-body);
  font-size: 12px;
  padding: 9px 10px;
  outline: none;
  cursor: pointer;
  max-width: 72px;
}

/* ---------- Long-press ripple ---------- */
@keyframes lp-ring{
  0%{ box-shadow: 0 0 0 0 rgba(127,216,143,0.6); }
  100%{ box-shadow: 0 0 0 10px rgba(127,216,143,0); }
}
.hour-sq.longpress-active{
  animation: lp-ring 0.55s ease forwards;
}

/* ---------- Fallback for very small viewports ---------- */
@media (max-height: 680px), (max-width: 880px){
  html,body{ overflow-y: auto; height: auto; }
  .app{ height: auto; min-height: 100vh; padding: 20px; }
  .board{ flex-direction: column; }
  .grid-card, .side-card{ flex: none; }
  .side-card{ min-height: 320px; }
}