/* ============================================================
   มาลา (Mala) — Sanctuary Lacquer & Antique Gold Design System
   ============================================================ */

:root {
  --bg-page: #0D0B09;
  --bg-elevated: #161310;
  --bg-card: #1B1713;
  --bg-card-hover: #231E18;
  --bg-orb: radial-gradient(circle at 35% 28%, #2A231B 0%, #17130F 65%, #110E0B 100%);
  --border-subtle: rgba(212, 168, 83, 0.14);
  --border-strong: rgba(212, 168, 83, 0.34);

  --text-primary: #F5EFE6;
  --text-secondary: #A99B89;
  --text-muted: #6F6355;

  --gold-100: #F8E3AE;
  --gold-400: #D4A853;
  --gold-600: #A87C2D;
  --saffron: #D97A3A;
  --saffron-soft: rgba(217, 122, 58, 0.16);
  --danger: #D16058;
  --success: #79B473;

  --shadow-orb: 0 22px 54px rgba(0, 0, 0, 0.65), inset 0 1px 1px rgba(248, 227, 174, 0.18);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);

  --font-serif: 'Noto Serif Thai', serif;
  --font-sans: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
}

[data-theme="light"] {
  --bg-page: #F6F0E4;
  --bg-elevated: #FFFDF8;
  --bg-card: #FBF7EE;
  --bg-card-hover: #F2EAD9;
  --bg-orb: radial-gradient(circle at 35% 25%, #FFFFFF 0%, #F7EFE0 68%, #EDE1CC 100%);
  --border-subtle: rgba(139, 98, 41, 0.16);
  --border-strong: rgba(139, 98, 41, 0.36);

  --text-primary: #241C14;
  --text-secondary: #6E5D4B;
  --text-muted: #9A8874;

  --gold-100: #B37E29;
  --gold-400: #9E6B1E;
  --gold-600: #7B5012;
  --saffron: #C86424;
  --saffron-soft: rgba(200, 100, 36, 0.12);
  --danger: #B8423B;
  --success: #3F7D3B;

  --shadow-orb: 0 18px 40px rgba(84, 58, 24, 0.14), inset 0 1px 2px rgba(255, 255, 255, 0.9);
  --shadow-card: 0 6px 20px rgba(84, 58, 24, 0.06);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  transition: background 0.3s ease, color 0.3s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

/* Warm Candlelight Ambient Glow */
.ambient-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(600px circle at 50% 22%, rgba(212, 168, 83, 0.09), transparent 65%),
    radial-gradient(500px circle at 85% 85%, rgba(217, 122, 58, 0.05), transparent 60%);
}

[data-theme="light"] .ambient-glow {
  background:
    radial-gradient(600px circle at 50% 18%, rgba(212, 168, 83, 0.14), transparent 65%);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 18px 44px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  color: var(--gold-400);
  display: grid;
  place-items: center;
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.brand-text .brand-th {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--gold-400);
}

.brand-text > span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.icon-btn .icon {
  width: 16px;
  height: 16px;
}

/* Mantra Bar */
.mantra-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mantra-select-wrap {
  flex: 1;
  display: flex;
  gap: 8px;
}

.mantra-select,
.mantra-custom {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.mantra-select:focus,
.mantra-custom:focus {
  border-color: var(--gold-400);
}

.shortcut-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.shortcut-hint kbd {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
}

/* Mode Switcher */
.mode-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.mode-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.22s ease;
}

.mode-tab:hover {
  color: var(--text-primary);
  background: rgba(212, 168, 83, 0.05);
}

.mode-tab.active {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.mode-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(212, 168, 83, 0.12);
  color: var(--gold-400);
  flex-shrink: 0;
}

.mode-tab.active .mode-badge {
  background: var(--gold-400);
  color: #15110C;
}

.mode-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.mode-info strong {
  font-size: 0.86rem;
  font-weight: 500;
}

.mode-info small {
  font-size: 0.69rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Dedicated Standalone Focus Mode Launch Bar */
.focus-launch-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: linear-gradient(135deg, rgba(212, 168, 83, 0.16) 0%, var(--bg-card) 75%);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
}

.focus-launch-bar:hover {
  border-color: var(--gold-400);
  background: linear-gradient(135deg, rgba(212, 168, 83, 0.25) 0%, var(--bg-card-hover) 75%);
  transform: translateY(-1px);
}

.focus-launch-bar:active {
  transform: scale(0.985);
}

.focus-launch-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #D4A853, #B3812A);
  color: #16110A;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 600;
  flex-shrink: 0;
}

.focus-launch-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.focus-launch-text strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--gold-100);
}

[data-theme="light"] .focus-launch-text strong {
  color: var(--gold-600);
}

.focus-launch-text small {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.focus-launch-arrow {
  font-size: 1.15rem;
  color: var(--gold-400);
  flex-shrink: 0;
}

/* Main Stage & Mala Orb */
.stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Sacred Buddha Image Shrine Card */
.shrine-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.shrine-card.dragover {
  border-color: var(--gold-400);
  background: rgba(212, 168, 83, 0.08);
}

.shrine-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.shrine-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--gold-100);
}

[data-theme="light"] .shrine-title {
  color: var(--gold-600);
}

.shrine-dot {
  color: var(--gold-400);
  font-size: 0.8rem;
}

.shrine-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.shrine-btn {
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.shrine-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.shrine-btn-danger:hover {
  border-color: rgba(209, 96, 88, 0.5);
  color: var(--danger);
}

.shrine-btn-gold {
  border-color: var(--border-strong);
  background: rgba(212, 168, 83, 0.14);
  color: var(--gold-100);
}

[data-theme="light"] .shrine-btn-gold {
  color: var(--gold-600);
}

.shrine-btn-gold:hover {
  background: rgba(212, 168, 83, 0.26);
}

.shrine-body {
  margin-top: 10px;
}

.shrine-dropzone {
  width: 100%;
  padding: 20px 14px;
  border-radius: 13px;
  border: 1.5px dashed var(--border-strong);
  background: radial-gradient(circle at 50% 35%, rgba(212, 168, 83, 0.08), transparent 72%);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

.shrine-dropzone:hover {
  border-color: var(--gold-400);
  background: radial-gradient(circle at 50% 35%, rgba(212, 168, 83, 0.14), transparent 72%);
}

.shrine-placeholder-icon {
  width: 44px;
  height: 44px;
  color: var(--gold-400);
  margin-bottom: 2px;
}

.shrine-dropzone strong {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gold-100);
}

[data-theme="light"] .shrine-dropzone strong {
  color: var(--gold-600);
}

.shrine-dropzone span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.shrine-preview-wrap {
  position: relative;
  width: 100%;
  max-height: 260px;
  min-height: 170px;
  border-radius: 16px 16px 12px 12px;
  border: 1px solid var(--border-strong);
  background: radial-gradient(circle at 50% 42%, rgba(212, 168, 83, 0.18), #0B0907 78%);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

[data-theme="light"] .shrine-preview-wrap {
  background: radial-gradient(circle at 50% 42%, rgba(212, 168, 83, 0.2), #EFE5D3 78%);
}

.shrine-aura {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(246, 218, 150, 0.22), transparent 65%);
}

.shrine-img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 246px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.shrine-img.dragging,
.focus-img.dragging {
  cursor: grabbing;
}

.img-adjust-bar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(13, 11, 9, 0.72);
  border: 1px solid rgba(212, 168, 83, 0.28);
  backdrop-filter: blur(8px);
}

[data-theme="light"] .img-adjust-bar {
  background: rgba(255, 253, 248, 0.85);
}

.img-adjust-hint {
  font-size: 0.68rem;
  color: var(--text-secondary);
  white-space: nowrap;
  padding-left: 3px;
}

.img-adjust-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.img-adj-btn {
  height: 24px;
  min-width: 24px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.img-adj-btn:hover {
  border-color: var(--gold-400);
  color: var(--gold-100);
}

[data-theme="light"] .img-adj-btn:hover {
  color: var(--gold-600);
}

.img-adj-zoom {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--gold-400);
  min-width: 34px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.shrine-preview-wrap.cover-mode {
  padding: 0;
  height: 240px;
}

.shrine-preview-wrap.cover-mode .shrine-img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center 20%;
  border-radius: 0;
}

/* Prayer / Chant Text Box */
.chant-text-box {
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.chant-text-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.chant-text-label {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.chant-text-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chant-text-display {
  font-family: var(--font-serif);
  font-size: var(--chant-font-size, 0.96rem);
  line-height: 1.75;
  color: var(--text-primary);
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
  padding-right: 4px;
}

.chant-text-display.empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
}

.chant-text-editor {
  width: 100%;
  min-height: 110px;
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--gold-400);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.94rem;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

/* Full-Screen Focus Mode Overlay */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.focus-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(13, 11, 9, 0.85);
  backdrop-filter: blur(12px);
}

[data-theme="light"] .focus-topbar {
  background: rgba(246, 240, 228, 0.9);
}

.focus-meta strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--gold-100);
}

[data-theme="light"] .focus-meta strong {
  color: var(--gold-600);
}

.focus-meta span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.focus-top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.focus-pill-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.focus-pill-btn.running {
  background: var(--saffron);
  border-color: #F2A359;
  color: #FFF8F0;
}

.focus-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.focus-image-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: radial-gradient(circle at 50% 45%, rgba(212, 168, 83, 0.2), #0A0806 78%);
  padding: 10px;
  min-height: 160px;
  overflow: hidden;
}

[data-theme="light"] .focus-image-wrap {
  background: radial-gradient(circle at 50% 45%, rgba(212, 168, 83, 0.22), #EFE5D3 78%);
}

.focus-img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 46vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.focus-upload-btn {
  position: relative;
  z-index: 1;
  padding: 18px 22px;
  border-radius: 14px;
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  color: var(--gold-100);
  font-family: var(--font-serif);
  font-size: 0.92rem;
  cursor: pointer;
}

[data-theme="light"] .focus-upload-btn {
  color: var(--gold-600);
}

.focus-chant-text {
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-serif);
  font-size: var(--chant-font-size, 1.05rem);
  line-height: 1.85;
  color: var(--text-primary);
  white-space: pre-wrap;
  text-align: center;
}

/* Floating Bottom Clicker Dock */
.focus-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg-page) 32%);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.focus-clicker-btn {
  pointer-events: auto;
  width: 100%;
  max-width: 540px;
  min-height: 92px;
  padding: 14px 22px;
  border-radius: 26px;
  border: 2px solid var(--gold-400);
  background: linear-gradient(135deg, #2D2419 0%, #17120C 100%);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.7), 0 0 28px rgba(212, 168, 83, 0.28);
  color: var(--text-primary);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.09s ease, box-shadow 0.2s ease;
}

[data-theme="light"] .focus-clicker-btn {
  background: linear-gradient(135deg, #FFFDF8 0%, #EFE4CF 100%);
  box-shadow: 0 12px 32px rgba(84, 58, 24, 0.2);
}

.focus-clicker-btn:active,
.focus-clicker-btn.pressed {
  transform: scale(0.965);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 32px rgba(212, 168, 83, 0.42);
}

.focus-clicker-left {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.focus-tag {
  font-size: 0.72rem;
  color: var(--gold-400);
  font-weight: 500;
}

.focus-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.focus-count {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1;
  color: var(--gold-100);
  font-variant-numeric: tabular-nums;
}

[data-theme="light"] .focus-count {
  color: var(--gold-600);
}

.focus-clicker-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.focus-round {
  font-size: 0.74rem;
  color: var(--gold-100);
}

[data-theme="light"] .focus-round {
  color: var(--gold-600);
}

.focus-last {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.mala-stage {
  position: relative;
  width: min(336px, 86vw);
  height: min(336px, 86vw);
  margin: 6px auto 2px;
  display: grid;
  place-items: center;
}

.mala-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 5;
}

.ring-progress {
  fill: none;
  stroke: url(#goldGrad);
  stroke-width: 5.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-auto {
  fill: none;
  stroke: url(#saffronGrad);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ring-auto.active {
  opacity: 0.85;
}

.mala-bead {
  fill: var(--text-muted);
  opacity: 0.25;
  transition: fill 0.2s ease, opacity 0.2s ease, r 0.2s ease;
}

.mala-bead.lit {
  fill: var(--gold-400);
  opacity: 0.95;
}

.mala-bead.head {
  fill: var(--gold-100);
  opacity: 1;
}

/* Interactive Clicker Orb */
.clicker-orb {
  position: relative;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-orb);
  box-shadow: var(--shadow-orb);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  transition: transform 0.09s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.clicker-orb:hover {
  border-color: var(--gold-400);
}

.clicker-orb:active,
.clicker-orb.pressed {
  transform: scale(0.955);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 36px rgba(212, 168, 83, 0.22);
}

.clicker-orb.breathing-in {
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.65), 0 0 42px rgba(212, 168, 83, 0.32), inset 0 0 28px rgba(246, 218, 150, 0.14);
  border-color: var(--gold-400);
}

.clicker-orb.breathing-out {
  box-shadow: var(--shadow-orb);
}

.orb-count.time-display {
  font-size: clamp(2.15rem, 8.2vw, 2.95rem);
  letter-spacing: -0.02em;
}

.orb-ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246, 218, 150, 0.34) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
}

.orb-ripple.animate {
  animation: orbPulse 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes orbPulse {
  0% { opacity: 0.9; transform: scale(0.45); }
  100% { opacity: 0; transform: scale(1.25); }
}

.orb-tag {
  font-size: 0.72rem;
  color: var(--gold-400);
  letter-spacing: 0.03em;
  font-weight: 500;
}

.orb-count {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 11vw, 4.1rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, var(--text-primary) 20%, var(--gold-100) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .orb-count {
  background: linear-gradient(180deg, #241C14 20%, #8A5B14 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.orb-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.orb-round-timer {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(212, 168, 83, 0.09);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gold-100);
  font-variant-numeric: tabular-nums;
}

[data-theme="light"] .orb-round-timer {
  color: var(--gold-600);
}

.dot-live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.dot-live.running {
  background: var(--gold-400);
  box-shadow: 0 0 8px var(--gold-400);
  animation: blinkDot 1.2s infinite;
}

.dot-live.auto {
  background: var(--saffron);
  box-shadow: 0 0 10px var(--saffron);
  animation: blinkDot 0.8s infinite;
}

@keyframes blinkDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.orb-cta {
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Control Panels */
.control-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.control-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.eta-pill {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(212, 168, 83, 0.1);
  color: var(--gold-400);
  font-variant-numeric: tabular-nums;
}

.eta-pill.auto-on {
  background: var(--saffron-soft);
  color: var(--saffron);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.preset-chip {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.preset-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.preset-chip.active {
  background: rgba(212, 168, 83, 0.18);
  border-color: var(--gold-400);
  color: var(--gold-100);
  font-weight: 600;
}

[data-theme="light"] .preset-chip.active {
  color: var(--gold-600);
}

.custom-input-group {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 5px;
}

.custom-input-group input {
  width: 72px;
  height: 34px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: center;
  outline: none;
}

.custom-input-group input:focus {
  border-color: var(--gold-400);
}

.btn-small {
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: rgba(212, 168, 83, 0.14);
  color: var(--gold-100);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

[data-theme="light"] .btn-small {
  color: var(--gold-600);
}

.btn-small:hover {
  background: rgba(212, 168, 83, 0.25);
}

/* Auto-Click Action Row */
.auto-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-auto-toggle {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--gold-400);
  background: linear-gradient(135deg, #D4A853, #B3812A);
  color: #16110A;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-auto-toggle:hover {
  filter: brightness(1.07);
}

.btn-auto-toggle.running {
  background: linear-gradient(135deg, #D97A3A, #B5561E);
  border-color: #F2A359;
  color: #FFF8F0;
}

.auto-interval-readout {
  min-width: 78px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  text-align: center;
  line-height: 1.15;
}

.auto-interval-readout span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gold-400);
}

.auto-interval-readout small {
  font-size: 0.66rem;
  color: var(--text-muted);
}

/* Practice Mode Options (Meditation & Walking) */
.practice-options-single {
  display: block;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.practice-opt {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.practice-opt label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.practice-select {
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  outline: none;
}

.practice-select:focus {
  border-color: var(--gold-400);
}

@media (max-width: 440px) {
  .practice-options-grid {
    grid-template-columns: 1fr;
  }
}

/* Utility Row */
.utility-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.util-btn {
  height: 38px;
  padding: 0 8px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.util-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.util-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.util-btn.util-gold:not(:disabled) {
  border-color: rgba(212, 168, 83, 0.32);
  color: var(--gold-400);
}

.util-btn.util-danger:hover:not(:disabled) {
  border-color: rgba(209, 96, 88, 0.45);
  color: var(--danger);
}

.icon-sm {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Live Total Chanting Duration Banner */
.elapsed-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(212, 168, 83, 0.1), var(--bg-card));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card);
}

.elapsed-prefix {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.elapsed-units {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.elapsed-unit {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.elapsed-unit strong {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold-100);
  margin-right: 3px;
  font-variant-numeric: tabular-nums;
}

[data-theme="light"] .elapsed-unit strong {
  color: var(--gold-600);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.metric-card.highlight {
  border-color: var(--border-strong);
  background: linear-gradient(180deg, rgba(212, 168, 83, 0.08), var(--bg-card));
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.metric-card.highlight .metric-value {
  color: var(--gold-100);
}

[data-theme="light"] .metric-card.highlight .metric-value {
  color: var(--gold-600);
}

.metric-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.metric-sub.faster {
  color: var(--success);
}

.metric-sub.slower {
  color: var(--saffron);
}

/* Drawer Panel (Laps & History) */
.drawer-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.drawer-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-tab {
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.drawer-tab.active {
  color: var(--gold-400);
  border-bottom-color: var(--gold-400);
  background: rgba(212, 168, 83, 0.04);
}

.pill-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(212, 168, 83, 0.14);
  color: var(--gold-400);
}

.drawer-content {
  padding: 12px;
  max-height: 230px;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  padding: 20px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.laps-list,
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lap-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.lap-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lap-num {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--gold-400);
}

.lap-type {
  font-size: 0.66rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(212, 168, 83, 0.1);
  color: var(--text-secondary);
}

.lap-type.auto {
  background: var(--saffron-soft);
  color: var(--saffron);
}

.lap-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.lap-duration {
  font-weight: 600;
  color: var(--text-primary);
}

.lap-total {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-summary {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  cursor: pointer;
}

.history-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-note {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--gold-100);
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(212, 168, 83, 0.08);
  border-left: 2px solid var(--gold-400);
  white-space: pre-wrap;
}

[data-theme="light"] .history-note {
  color: var(--gold-600);
  background: rgba(158, 107, 30, 0.08);
}

/* Unified Luxury Custom Dropdown (.jitr-dropdown) */
select.jitr-select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.jitr-dropdown {
  position: relative;
  width: 100%;
  flex: 1;
}

.jitr-dropdown-trigger {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.jitr-dropdown-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.jitr-dropdown.open .jitr-dropdown-trigger {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.16);
}

.jitr-dropdown-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jitr-dropdown-chevron {
  width: 16px;
  height: 16px;
  color: var(--gold-400);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.jitr-dropdown.open .jitr-dropdown-chevron {
  transform: rotate(180deg);
}

.jitr-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 45;
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: none;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

[data-theme="light"] .jitr-dropdown-menu {
  box-shadow: 0 14px 32px rgba(84, 58, 24, 0.16);
}

.jitr-dropdown.open .jitr-dropdown-menu {
  display: flex;
  animation: dropdownFade 0.14s ease-out;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.jitr-dropdown-option {
  width: 100%;
  padding: 9px 11px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.jitr-dropdown-option:hover {
  background: rgba(212, 168, 83, 0.12);
}

.jitr-dropdown-option.selected {
  background: rgba(212, 168, 83, 0.18);
  color: var(--gold-100);
  font-weight: 500;
}

[data-theme="light"] .jitr-dropdown-option.selected {
  color: var(--gold-600);
}

.jitr-dropdown-check {
  color: var(--gold-400);
  font-size: 0.85rem;
  opacity: 0;
}

.jitr-dropdown-option.selected .jitr-dropdown-check {
  opacity: 1;
}

/* Modal Note Section */
.modal-note-section {
  text-align: left;
  margin-bottom: 16px;
}

.modal-note-label {
  display: block;
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.note-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.note-chip {
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.note-chip:hover {
  border-color: var(--gold-400);
  color: var(--gold-100);
  background: rgba(212, 168, 83, 0.14);
}

[data-theme="light"] .note-chip:hover {
  color: var(--gold-600);
}

.modal-note-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 0.86rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}

.modal-note-input:focus {
  border-color: var(--gold-400);
}

.history-main strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 500;
}

.history-main span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-stats {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.history-stats strong {
  display: block;
  color: var(--gold-400);
  font-size: 0.84rem;
}

.history-stats span {
  color: var(--text-secondary);
  font-size: 0.68rem;
}

/* Completion Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 6, 4, 0.78);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-lotus {
  font-size: 2rem;
  color: var(--gold-400);
  margin-bottom: 6px;
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--gold-100);
}

[data-theme="light"] .modal-card h2 {
  color: var(--gold-600);
}

.modal-subtitle {
  margin: 6px 0 18px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 10px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  margin-bottom: 18px;
}

.modal-stats span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.modal-stats strong {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-primary {
  height: 44px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #D4A853, #B3812A);
  color: #151009;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost {
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  cursor: pointer;
}

@media (max-width: 440px) {
  .utility-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .shortcut-hint {
    display: none;
  }
  .custom-input-group {
    margin-left: 0;
    width: 100%;
  }
  .custom-input-group input {
    flex: 1;
  }
}
