:root {
  --accent: #7c3aed;
  --bg: #f5f7fb;
  --card: #ffffff;
  --shadow: rgba(0,0,0,0.12);
  --radius: 20px;
}
body.theme-pastel {
  --bg: #f7f5ff;
  --card: rgba(255,255,255,0.9);
  --accent: #a855f7;
}
body.theme-matrix {
  --bg: linear-gradient(180deg, #000000 0%, #071018 100%);
  --card: rgba(8, 12, 16, 0.92);
  --accent: #00ff41;
  --text: #e8fff2;
  --muted-text: rgba(232,255,242,0.65);
  --shadow: rgba(0,0,0,0.66);
  --glass-tint: rgba(255,255,255,0.02);
  color: var(--text);
}
body.theme-glass {
  --bg: #e3f2ff;
  --card: rgba(255,255,255,0.55);
  backdrop-filter: blur(12px);
  --accent: #0ea5e9;
}
html, body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  color: #333;
  transition: background .4s, color .4s;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 12px);
  padding-right: env(safe-area-inset-right, 12px);
  padding-top: env(safe-area-inset-top, 12px);
}
body.theme-matrix {
  background: var(--bg);
}
.brand a {
  text-decoration: none;
  color: #020202;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
body.theme-matrix .brand a { color: var(--text); }
.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
#parallax-bg {
  position: fixed;
  inset: 0;
  z-index: -10;
  overflow: hidden;
  pointer-events: none;
}
#ambience-canvas {
  position: fixed;
  inset: 0;
  z-index: -9;
  pointer-events: none;
}
body.theme-matrix #parallax-bg {
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(4,8,12,0.92));
}
.parallax-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.75;
  transition: transform 0.1s linear;
  pointer-events: none;
}
.topbar {
  background: var(--card);
  padding: 12px 14px;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 20px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 120;
}
body.theme-matrix .topbar { color: var(--text); }
.brand {
  font-size: 20px;
  font-weight: 700;
}
.brand .beta {
  font-size: 11px;
  background: var(--accent);
  color: #e3f2ff;
  padding: 3px 7px;
  border-radius: 6px;
  margin-left: 6px;
}
.feature-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
}
.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 2px 8px var(--shadow);
  border: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon.active {
  background: var(--accent);
  color: #e3f2ff;
}
body.theme-matrix .btn-icon {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.04));
  border: 1px solid rgba(255,255,255,0.03);
  color: var(--muted-text);
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
}
body.theme-matrix .btn-icon.active {
  background: linear-gradient(180deg, rgba(0,255,65,0.12), rgba(0,255,65,0.06));
  color: #001;
  border: 1px solid rgba(0,255,65,0.18);
  box-shadow:
    0 6px 22px rgba(0,255,65,0.10),
    0 0 28px rgba(0,255,65,0.12),
    inset 0 0 8px rgba(255,255,255,0.02);
  transform: translateY(-1px);
}
.mobile-menu .feature-toggles {
  justify-content: center;
}
#workspace {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1100px) {
  #workspace {
    grid-template-columns: repeat(2, 1fr);
    padding: 14px;
  }
}
@media (max-width: 768px) {
  #workspace {
    grid-template-columns: repeat(2, 1fr);
    padding: 12px;
  }
}
@media (max-width: 700px) {
  #workspace {
    grid-template-columns: 1fr;
    padding: 10px;
  }
}
.widget {
  background: var(--card);
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  position: relative;
  min-height: 64px;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  color: inherit;
}
.widget:active { cursor: grabbing; }
.widget[draggable="true"] { -webkit-user-drag: element; }
.widget-head h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.widget-glint {
  position: absolute;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(255,255,255,0.35), transparent);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.widget:hover {
  transform: translateY(-3px);
}
.widget.no-glint { transform: none !important; }
body.theme-matrix .widget {
  background: rgba(8,12,16,0.86);
  border: 1px solid rgba(0,255,65,0.04);
  box-shadow:
    0 10px 28px rgba(0,0,0,0.7),
    inset 0 0 18px rgba(0,255,65,0.02);
  color: var(--text);
}
.focumi-toast {
  position: fixed;
  top: calc(22px + env(safe-area-inset-top, 0px));
  right: calc(22px + env(safe-area-inset-right, 0px));
  background: var(--accent);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(-8px);
  transition: all .25s ease;
  z-index: 99999;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.focumi-toast.visible {
  opacity: 1;
  transform: translateY(0);
}
body.theme-matrix .focumi-toast {
  box-shadow: 0 12px 36px rgba(0,0,0,0.75), 0 0 22px rgba(0,255,65,0.06);
  color: #001;
  font-weight: 700;
}
.focumi-center-alert-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100001;
  pointer-events: auto;
}
.focumi-center-alert {
  background: var(--card);
  color: inherit;
  padding: 18px 20px;
  border-radius: 12px;
  max-width: 92%;
  width: 420px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.28);
  text-align: center;
}
.focumi-center-alert .alert-msg {
  font-size: 16px;
  margin-bottom: 12px;
  word-break: break-word;
}
.focumi-center-alert .alert-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.focumi-center-alert .alert-actions .btn {
  min-width: 70px;
}
body.theme-matrix .focumi-center-alert {
  background: rgba(8,12,16,0.96);
  color: var(--text);
  border: 1px solid rgba(0,255,65,0.05);
}
.todo-item {
  box-shadow: 0 3px 10px var(--shadow);
  border-radius: 12px;
}
.pomo-display {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
}
.pomo-templates {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.pomo-templates button {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.9);
  cursor: pointer;
}
.pomo-templates button.active { background: var(--accent); color: #fff; }
body.theme-matrix .pomo-templates button {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.03);
  color: var(--muted-text);
}
body.theme-matrix .pomo-templates button.active { background: var(--accent); color: #001; }
#pomoCustom input[type="number"] {
  -moz-appearance: textfield;
}
#pomoCustom .form-control-sm {
  padding: .25rem .5rem;
  font-size: .85rem;
  border-radius: 8px;
}
.notes-area {
  position: relative;
  min-height: 220px;
  background: rgba(0,0,0,0.03);
  border-radius: 12px;
  padding: 10px;
  overflow: hidden;
}
.note-card {
  position: absolute;
  min-width: 120px;
  min-height: 80px;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 10px var(--shadow);
  cursor: grab;
  touch-action: none;
  color: inherit;
}
.note-card:active { cursor: grabbing; }
body.theme-matrix .note-card {
  color: var(--text);
  box-shadow: 0 8px 20px rgba(0,0,0,0.6);
}
.note-card .note-text {
  min-height: 48px;
  outline: none;
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  pointer-events: auto !important;
  caret-color: var(--accent);
}
.wheel-wrap {
  width: 240px;
  height: 240px;
  margin: 0 auto;
}
#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 6px 20px var(--shadow);
}
.modal-mood-btn {
  font-size: 20px;
  border-radius: 10px;
}
#dashboard strong {
  font-size: 22px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-weekdays {
  display: contents;
}
.calendar-cell {
  min-height: 72px;
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
  padding: 6px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.calendar-cell.other-month { opacity: 0.35; }
.calendar-day-num {
  font-size: 13px;
  font-weight: 600;
}
.event-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.calendar-weekday-label {
  font-size: 12px;
  text-align: center;
  opacity: 0.6;
}
.timeline { display: none; }
.focus-room {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(10px);
  display: none;
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
.focus-inner {
  background: var(--card);
  padding: 30px 40px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 6px 20px var(--shadow);
}
.focus-timer {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
}
#moodModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  display: none;
  z-index: 6000;
  justify-content: center;
  align-items: center;
}
#moodModal[style*="display:block"],
#moodModal[style*="display: block"],
#moodModal[style*="display:flex"],
#moodModal[style*="display: flex"] {
  display: flex !important;
}
#moodModal .modal-content {
  background: var(--card);
  padding: 14px 18px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  text-align: center;
  width: 360px;
  max-width: calc(100% - 40px);
  box-sizing: border-box;
}
.small-modal {
  width: 320px;
  max-width: calc(100% - 40px);
}
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 10px 0;
  opacity: 0.9;
  background: transparent;
  z-index: 80;
}
body.theme-matrix .footer { color: var(--muted-text); }
@media(max-width: 768px) {
  .focus-inner {
    width: 92%;
    padding: 22px;
  }
  .pomo-display { font-size: 28px; }
  #workspace { gap: 12px; padding: 12px; }
  #moodModal .modal-content,
  .small-modal {
    width: 92%;
    padding: 12px 14px;
  }
}
.widget {
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(8px);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.35);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow:
        0 4px 14px rgba(0,0,0,0.10),
        inset 0 0 8px rgba(255,255,255,0.08);
    transition: all 0.22s ease;
}
.widget:hover {
    transform: translateY(-3px);
    box-shadow:
        0 10px 25px rgba(0,0,0,0.12),
        inset 0 0 14px rgba(255,255,255,0.18);
}
#parallax-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -10;
}
#ambience-canvas {
    position: fixed ;
    inset: 0 ;
    pointer-events: none ;
    z-index: -9 ;
}
.quote-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 7000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18px;
  box-sizing: border-box;
  background: rgba(0,0,0,0.18);
}
.quote-modal .quote-content {
  pointer-events: auto;
  background: var(--card);
  color: #222;
  max-width: 720px;
  width: 92%;
  padding: 20px 22px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  margin: 0 auto;
  transform-origin: center top;
}
.quote-text {
  font-size: 18px;
  line-height: 1.4;
  color: var(--accent);
  font-weight: 600;
}
@media (max-width: 480px) {
  .quote-modal .quote-content { padding: 14px; }
  .quote-text { font-size: 16px; }
}
#musicSelect {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: linear-gradient(180deg, #ffffff, #f3f6ff);
  border: 1px solid rgba(0,0,0,0.06);
  padding: .35rem .8rem;
  padding-right: 44px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15,23,42,0.06);
  min-width: 220px;
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path fill="%237c3aed" d="M4.5 6.5L9 11l4.5-4.5z"/></svg>');
  font-weight: 600;
}
body.theme-matrix #musicSelect {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path fill="%2300ff41" d="M4.5 6.5L9 11l4.5-4.5z"/></svg>');
  background-color: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  color: var(--muted-text);
}
#musicSelect.w-auto {
  min-width: 160px;
}
#musicSelect option {
  font-weight: 600;
  padding: 6px;
}
#musicSelect:focus {
  outline: 2px solid rgba(0,255,65,0.12);
  box-shadow: 0 8px 20px rgba(0,255,65,0.06);
}
#closeQuote { min-width: 90px; }
@media (max-width: 768px) {
  #menuToggle { display: inline-block; }
  .top-actions { display: none; }
  .topbar { padding-right: 12px; padding-left: 12px; }
}
@media (max-width: 420px) {
  .mobile-menu { left: 8px; right: 8px; padding: 10px; }
}
@media (max-width: 768px) {
  #workspace {
    padding-left: calc(12px + env(safe-area-inset-left, 12px));
    padding-right: calc(12px + env(safe-area-inset-right, 12px));
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    overflow: visible;
  }
  .widget {
    width: auto;
    max-width: calc(100% - (24px + env(safe-area-inset-left, 12px) + env(safe-area-inset-right, 12px)));
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 12px;
    border-radius: 12px;
    transition: transform .18s ease, box-shadow .18s ease;
  }
  .widget:hover {
    transform: translateY(-3px) !important;
    box-shadow:
      0 8px 20px rgba(0,0,0,0.10),
      inset 0 0 10px rgba(255,255,255,0.12) !important;
  }
  .topbar {
    padding-left: calc(12px + env(safe-area-inset-left, 12px));
    padding-right: calc(12px + env(safe-area-inset-right, 12px));
  }
  main.container-fluid {
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
  }
  .mobile-menu {
    left: calc(12px + env(safe-area-inset-left, 12px));
    right: calc(12px + env(safe-area-inset-right, 12px));
    box-sizing: border-box;
  }
  @media (max-width: 420px) {
    #workspace { padding-left: calc(8px + env(safe-area-inset-left, 8px)); padding-right: calc(8px + env(safe-area-inset-right, 8px)); }
    .widget { padding-left: 12px; padding-right: 12px; }
    .topbar { padding-left: calc(8px + env(safe-area-inset-left, 8px)); padding-right: calc(8px + env(safe-area-inset-right, 8px)); }
  }
}
@media (max-width: 768px) {
  .topbar .brand { margin-right: 8px; }
}
canvas {
  max-width: 100% !important;
  height: auto !important;
  display: block;
}
@media (max-width: 480px) {
  #pomodoro {
    width: 100%;
    max-width: calc(100% - (24px + env(safe-area-inset-left, 12px) + env(safe-area-inset-right, 12px)));
    box-sizing: border-box;
    padding: 12px;
  }
  #pomodoro .pomo-display {
    font-size: 26px;
    word-break: break-word;
    text-align: left;
  }
  #pomodoro .widget-body > .d-flex.align-items-center.justify-content-between {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  #pomodoro .widget-body .pomo-templates {
    width: 100%;
    justify-content: flex-start;
  }
  .pomo-templates .pomo-template {
    min-width: 64px;
    padding: 6px 8px;
    font-size: 13px;
  }
  #pomoCustom {
    flex-wrap: wrap;
    gap: 6px;
  }
  #pomoCustom input {
    width: 48%;
    min-width: 110px;
  }
  #pomoCustom button {
    width: 100%;
    margin-top: 4px;
  }
  #pomoStats {
    max-height: 120px !important;
    height: auto !important;
  }
  #music {
    width: 100%;
    max-width: calc(100% - (24px + env(safe-area-inset-left, 12px) + env(safe-area-inset-right, 12px)));
    box-sizing: border-box;
    padding: 12px;
  }
  #music .widget-body .d-flex.gap-2.align-items-center {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  #musicSelect {
    width: 100% !important;
    min-width: 0;
  }
  #musicPlay {
    align-self: flex-start;
  }
  #musicVol {
    width: 100% !important;
  }
  #musicEQ {
    height: 36px !important;
  }
  #wheelCanvas, #moodChart, #dashBar, #dashPie {
    max-width: 100% !important;
    height: auto !important;
  }
  .widget {
    padding: 10px !important;
  }
  #pomoStart, #pomoPause, #pomoReset {
    padding: 6px 8px;
    font-size: 13px;
  }
}
@media (min-width: 481px) and (max-width: 767px) {
  #pomodoro, #music {
    max-width: calc(100% - (32px + env(safe-area-inset-left, 12px) + env(safe-area-inset-right, 12px)));
    padding: 12px;
  }
  .pomo-display { font-size: 30px; }
  #musicSelect { min-width: 180px; width: auto; }
}