/* ============================================================
   TAP COUNTER — styles.css
   ============================================================ */

/* ---------- CSS Custom Properties (Design Tokens) ---------- */
:root {
  --bg:      #0a0a0a;
  --surface: #111111;
  --accent:  #e8ff47;
  --accent2: #ff4757;
  --text:           #f0f0f0;
  --text-secondary: rgba(240, 240, 240, 0.55);
  --muted:          #777;
  --ripple:  rgba(232, 255, 71, 0.15);
  --border:  #1e1e1e;
  --nav-h:   62px;
}

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

/* ---------- Base ---------- */
html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  overflow: hidden;
  touch-action: manipulation;
}

/* ---------- App Shell ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;       /* fallback */
  height: 100dvh;      /* actual visible area on mobile (excludes browser chrome) */
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* ---------- Views ---------- */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.view.active {
  display: flex;
}

/* Scrollable non-counter views */
#view-categories,
#view-history,
#view-dashboard {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- View Header ---------- */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.view-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 30px;
  letter-spacing: 0.06em;
  color: var(--text);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.1s;
}

.btn-icon:active { opacity: 0.75; }

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-icon {
  font-size: 17px;
  line-height: 1;
}

.nav-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- HUD (top stats bar) ---------- */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 24px 10px;
  z-index: 10;
  position: relative;
  flex-shrink: 0;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1;
  margin-bottom: 4px;
}

.hud-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 0.05em;
  color: var(--accent);
  line-height: 1;
}

.hud-right {
  text-align: right;
}

/* ---------- Category Bar (Counter view) ---------- */
.category-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 12px;
  z-index: 10;
  flex-shrink: 0;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid #222;
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 0 10px;
  height: 34px;
  cursor: pointer;
  max-width: 52%;
  overflow: hidden;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.category-btn:hover {
  border-color: var(--accent);
}

#category-btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-chevron {
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
}

.session-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ---------- HUD Target Column ---------- */
.hud-target-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  text-align: center;
  padding: 0;
  font-family: inherit;
  transition: opacity 0.1s;
}

.hud-target-btn:active { opacity: 0.65; }

.hud-edit-hint {
  font-size: 8px;
  color: var(--muted);
  vertical-align: middle;
  margin-left: 2px;
}

.hud-target-value {
  min-width: 40px;
  display: inline-block;
}

/* ---------- Target Progress Bar ---------- */
.target-bar-wrap {
  display: none;          /* shown only when target is set */
  height: 4px;
  background: var(--surface);
  margin: 0 24px 6px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.target-bar-wrap.active { display: block; }

.target-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.25s ease, background-color 0.4s ease;
}

.target-bar-fill.near { background: #ffaa00; }   /* ≥ 80 % */
.target-bar-fill.done { background: var(--accent); width: 100% !important; }

/* ---------- Target Celebration Overlay ---------- */
.target-celebration {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  pointer-events: none;
  opacity: 0;
}

.target-celebration.show {
  animation: tc-fade 2.2s ease forwards;
}

@keyframes tc-fade {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  72%  { opacity: 1; }
  100% { opacity: 0; }
}

.target-celebration-card {
  background: var(--accent);
  border-radius: 28px;
  padding: 36px 52px;
  text-align: center;
  animation: tc-pop 2.2s ease forwards;
}

@keyframes tc-pop {
  0%   { transform: scale(0.75); }
  10%  { transform: scale(1.06); }
  18%  { transform: scale(1); }
  72%  { transform: scale(1); }
  100% { transform: scale(0.92); }
}

.target-celebration-icon {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 10px;
}

.target-celebration-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 56px;
  letter-spacing: 0.06em;
  color: #000;
  line-height: 1.1;
}

/* ---------- Streak Bar ---------- */
.streak-bar {
  height: 3px;
  background: var(--surface);
  position: relative;
  margin: 0 24px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.streak-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a8ff00);
  border-radius: 2px;
  transition: width 0.15s ease;
  width: 0%;
}

/* ---------- Counter Area ---------- */
.counter-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  min-height: 0;
}

.counter-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 50%, #1a1a1a 0%, var(--bg) 100%);
}

.count-display {
  position: relative;
  z-index: 2;
  text-align: center;
  pointer-events: none;
}

.count-number {
  font-family: 'Bebas Neue', sans-serif;
  font-size: var(--count-font-size, clamp(96px, 28vw, 180px));
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--text);
  transition: transform 0.08s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: block;
}

.count-number.pop {
  transform: scale(1.08);
}

.count-label {
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* ---------- Ring Progress Indicator ---------- */
.ring-container {
  position: absolute;
  width: 260px;
  height: 260px;
  z-index: 1;
  pointer-events: none;
}

.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.ring-track {
  fill: none;
  stroke: #1e1e1e;
  stroke-width: 3;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

/* ---------- Ripple Effect ---------- */
.ripple-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: var(--ripple);
  transform: scale(0);
  animation: ripple-out 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple-out {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ---------- Floating +N Label ---------- */
.float-num {
  position: absolute;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 32px;
  color: var(--accent);
  pointer-events: none;
  z-index: 10;
  animation: float-up 0.7s ease-out forwards;
}

@keyframes float-up {
  0%   { opacity: 1; transform: translateY(0)     scale(1);   }
  100% { opacity: 0; transform: translateY(-80px) scale(0.6); }
}

/* ---------- Tap Hint ---------- */
.tap-hint {
  position: absolute;
  bottom: 50%;
  transform: translateY(60px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.5s;
}

/* ---------- Corner Buttons (inside tap area) ---------- */
.corner-btn {
  position: absolute;
  z-index: 10;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: rgba(17, 17, 17, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.corner-btn:active {
  transform: scale(0.86);
}

/* Positions */
.corner-tl { top: 24px;    left: 24px; }
.corner-tr { top: 24px;    right: 24px; }
.corner-bl { bottom: 24px; left: 24px; }
.corner-br { bottom: 24px; right: 24px; }

.corner-btn-icon {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  line-height: 1;
}

.corner-btn-label {
  font-family: 'DM Mono', monospace;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1;
}

/* Reset button */
.corner-btn-reset .corner-btn-icon {
  color: var(--accent2);
}

/* Active step button */
.corner-btn.active {
  border-color: var(--accent);
  background: rgba(232, 255, 71, 0.1);
}

.corner-btn.active .corner-btn-icon,
.corner-btn.active .corner-btn-label {
  color: var(--accent);
}

/* ---------- Milestone Flash Overlay ---------- */
.milestone-flash {
  position: fixed;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  mix-blend-mode: overlay;
}

.milestone-flash.flash {
  animation: flash-in 0.4s ease-out;
}

@keyframes flash-in {
  0%   { opacity: 0.4; }
  100% { opacity: 0;   }
}

/* ============================================================
   CATEGORIES VIEW
   ============================================================ */

.list-container {
  flex: 1;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
}

.cat-select-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  padding: 0;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
  overflow: hidden;
}

.cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.cat-dot.is-active {
  background: var(--accent);
  border-color: var(--accent);
}

.cat-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-item.is-active-item .cat-item-name {
  color: var(--accent);
}

.cat-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.cat-edit,
.cat-delete {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #161616;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}

.cat-edit { color: var(--muted); }
.cat-edit:hover { border-color: var(--accent); color: var(--accent); }

.cat-delete { color: var(--muted); }
.cat-delete:hover { border-color: var(--accent2); color: var(--accent2); }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  padding: 56px 32px;
}

.hidden {
  display: none !important;
}

/* ============================================================
   HISTORY VIEW
   ============================================================ */

.history-date-header {
  padding: 10px 20px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 69px; /* below sticky view-header */
  z-index: 5;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.history-cat-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.history-count {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-left: 12px;
  flex-shrink: 0;
}

/* ============================================================
   DASHBOARD VIEW
   ============================================================ */

.dash-tabs {
  display: flex;
  padding: 12px 16px;
  gap: 8px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.dash-tabs::-webkit-scrollbar { display: none; }

.dash-tab {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid #333;
  background: none;
  color: var(--text-secondary);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.dash-tab.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.dash-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0 24px;
}

.dash-summary {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.dash-total-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.dash-total-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 48px;
  color: var(--accent);
  letter-spacing: 0.04em;
  line-height: 1;
}

.dash-total-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Bar chart */
.bar-chart {
  padding: 4px 20px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.bar-date {
  width: 52px;
  font-size: 10px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
}

.bar-track {
  flex: 1;
  height: 22px;
  background: #1a1a1a;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  min-width: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-val {
  width: 44px;
  font-size: 11px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  flex-shrink: 0;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}

.modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  letter-spacing: 0.06em;
  margin: 0 0 18px;
  color: var(--text);
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.15s;
}

.modal-input:focus {
  border-color: var(--accent);
}

.modal-body {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-modal-cancel {
  flex: 1;
  background: #111;
  color: var(--muted);
  border: 1px solid #333;
}

.btn-modal-save {
  flex: 1;
  background: var(--accent);
  color: #000;
  font-weight: 500;
  border: none;
}

.btn-modal-delete {
  flex: 1;
  background: var(--accent2);
  color: #fff;
  border: none;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ============================================================
   CATEGORY ICON — counter view
   ============================================================ */

/* Small icon inside the category button */
.cat-btn-icon {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  display: none; /* hidden when empty */
}

.cat-btn-icon.has-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cat-btn-icon.is-image {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  font-size: 0;
}

/* Large icon above the count number */
.counter-cat-icon {
  position: relative;
  z-index: 2;
  pointer-events: none;
  font-size: 72px;
  line-height: 1;
  margin-bottom: 4px;
  display: none; /* hidden when empty */
}

.counter-cat-icon.has-icon {
  display: block;
}

.counter-cat-icon.is-image {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  font-size: 0;
  border: 2px solid rgba(255,255,255,0.08);
}

/* ============================================================
   ICON PICKER — inside modal
   ============================================================ */

.icon-section {
  margin-bottom: 20px;
}

.icon-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.icon-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* Current selection preview badge */
.icon-preview {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #222;
  border: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background-size: cover;
  background-position: center;
  overflow: hidden;
  flex-shrink: 0;
}

/* Emoji grid */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}

.icon-opt {
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #161616;
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s;
  padding: 0;
}

.icon-opt:active { transform: scale(0.92); }

.icon-opt:hover  { border-color: #444; }

.icon-opt.selected {
  border-color: var(--accent);
  background: rgba(232,255,71,0.06);
}

/* "None" clear option */
.icon-opt.is-none {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0;
}

.icon-opt.is-none.selected {
  color: var(--accent);
}

/* Section labels (Uploaded / Emoji) */
.icon-group-label {
  grid-column: 1 / -1;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  padding: 4px 0 2px;
}

/* Wrapper holds the image button + the × delete badge */
.icon-opt-wrap {
  position: relative;
  display: flex;
}

/* × delete badge overlaid on uploaded images */
.icon-opt-delete {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent2);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  padding: 0;
  transition: transform 0.1s;
}

.icon-opt-delete:active { transform: scale(0.85); }

/* Upload button */
.icon-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 1px dashed #333;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
  gap: 6px;
}

.icon-upload-label:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
   THEME / BACKGROUND PICKER
   ============================================================ */

/* Palette button in category bar */
.theme-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  font-size: 17px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.theme-btn:hover,
.theme-btn:active { opacity: 1; }

/* Swatch grid — 4 columns */
.theme-swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
}

.theme-swatch-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.12s;
}

.theme-swatch.selected .theme-swatch-circle {
  border-color: var(--accent);
  transform: scale(1.1);
}

.theme-swatch-name {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

/* Custom colour row */
.theme-custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
}

.theme-custom-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.theme-color-input {
  width: 48px;
  height: 32px;
  border: 1px solid #333;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  padding: 2px;
}

/* ============================================================
   SETTINGS VIEW
   ============================================================ */

#view-settings {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-list {
  padding: 4px 0 48px;
}

/* Live preview badge in settings header */
.settings-preview-badge {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 30px;
  letter-spacing: -0.02em;
  line-height: 1;
  padding: 4px 12px;
  border-radius: 10px;
  transition: font-size 0.2s ease, color 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
}

/* Section label above each card */
.settings-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  padding: 20px 20px 8px;
}

/* Card — groups rows with subtle background, no harsh borders */
.settings-card {
  margin: 0 16px;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
}

/* Row inside card */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  gap: 12px;
  position: relative;
}

/* Hairline between rows — barely visible, no hard border */
.settings-card .settings-row + .settings-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.settings-row-label {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.settings-row-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.settings-row-chevron {
  font-size: 20px;
  color: var(--muted);
  line-height: 1;
}

/* Tappable rows get a press state */
.settings-card .settings-row[id] {
  cursor: pointer;
}
.settings-card .settings-row[id]:active {
  background: rgba(255, 255, 255, 0.05);
}

.settings-row-danger .settings-row-label {
  color: var(--accent2);
  text-align: center;
  width: 100%;
}

/* Font size buttons */
.settings-font-btns {
  display: flex;
  gap: 6px;
}

.settings-font-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.settings-font-btn.active {
  background: var(--accent);
  color: #000;
}

/* Colour swatches */
.settings-color-swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.settings-color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, border-color 0.12s;
}

.settings-color-dot.active {
  border-color: var(--text);
  transform: scale(1.2);
}

/* Save button */
.settings-save-wrap {
  padding: 20px 16px 4px;
}

.settings-save-btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #000;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.15s, transform 0.1s, background 0.3s;
}

.settings-save-btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.settings-save-btn.saved {
  background: #4caf50;
  color: #fff;
  letter-spacing: 0.12em;
}

/* Uploaded image thumbnail shown inside grid */
.icon-opt.is-upload {
  background-size: cover;
  background-position: center;
  font-size: 0;
  border-radius: 8px;
}

/* Category list icon column */
.cat-icon-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

/* ============================================================
   CHANT / VOICE DETECTION
   ============================================================ */

.chant-section {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.mic-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: #161616;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.mic-btn.active {
  border-color: #ff4757;
  background: rgba(255, 71, 87, 0.14);
}

.mic-btn:active { transform: scale(0.88); }

.mic-icon-glyph { font-size: 18px; line-height: 1; }

.mic-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
  transition: background 0.2s;
}

.mic-dot.active {
  background: #ff4757;
  animation: mic-pulse 1.3s ease infinite;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.4); opacity: 0.65; }
}

.chant-body {
  flex: 1;
  min-width: 0;
}

.chant-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
}

.chant-lbl {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.chant-word-input {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--text-secondary);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.07em;
  outline: none;
  min-width: 0;
  flex: 1;
  padding: 0 2px;
  transition: border-color 0.15s, color 0.15s;
}

.chant-word-input:focus {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.chant-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1;
  display: block;
  transition: color 0.15s;
}

.chant-num.chant-pulse {
  animation: chant-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chant-pop {
  0%   { transform: scale(1);    color: var(--text); }
  40%  { transform: scale(1.5);  color: var(--accent); }
  100% { transform: scale(1);    color: var(--text); }
}

.chant-reset-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #161616;
  color: var(--accent2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.chant-reset-btn:active { transform: scale(0.86); border-color: var(--accent2); }

.no-speech-msg {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 8px 20px 12px;
  flex-shrink: 0;
}

/* ============================================================
   QUALITY FLASH (inside tap area, fixed overlay)
   ============================================================ */

.quality-flash {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  letter-spacing: 0.12em;
  padding: 8px 26px;
  border-radius: 32px;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  white-space: nowrap;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quality-flash.show {
  animation: quality-show 0.52s ease forwards;
}

@keyframes quality-show {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  24%  { transform: translate(-50%, -50%) scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.93); }
}

/* ============================================================
   MODAL — new field labels + textarea
   ============================================================ */

.modal-field-label {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 7px;
}

.modal-input-sm {
  margin-bottom: 14px;
}

.modal-textarea {
  resize: none;
  height: 62px;
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 18px;
}
