/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --glass-bg: rgba(0, 0, 0, 0.4);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.6);
  --overlay-bg: rgba(0, 0, 0, 0.15);
  --modal-bg: rgba(20, 20, 30, 0.95);
  --input-bg: rgba(255, 255, 255, 0.08);
  --hover-bg: rgba(255, 255, 255, 0.12);
  --ring-track: rgba(255, 255, 255, 0.1);
  --panel-bg: rgba(0, 0, 0, 0.6);
  --accent: #ff6b6b;
  --shadow: 0 4px 30px rgba(0,0,0,0.4);
}

body.light {
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(0, 0, 0, 0.08);
  --text: #1a1a2e;
  --text-dim: rgba(30, 30, 50, 0.55);
  --overlay-bg: rgba(255, 255, 255, 0.1);
  --modal-bg: rgba(255, 255, 255, 0.96);
  --input-bg: rgba(0, 0, 0, 0.05);
  --hover-bg: rgba(0, 0, 0, 0.07);
  --ring-track: rgba(0, 0, 0, 0.08);
  --panel-bg: rgba(255, 255, 255, 0.7);
  --shadow: 0 4px 30px rgba(0,0,0,0.15);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

/* ===== Background Slideshow — Full bleed, NO blur ===== */
#bg-slideshow {
  position: fixed; inset: 0; z-index: 0;
}

.bg-slide {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 2.5s ease-in-out;
}

.bg-slide.active { opacity: 1; }

/* ===== Top Bar ===== */
#top-bar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
}

.logo {
  display: flex;
  align-items: center;
}

.logo-img {
  height: 32px;
  width: auto;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.3));
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#clock {
  font-size: 0.8rem;
  font-weight: 500;
  margin-right: 0.5rem;
  opacity: 0.8;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

.icon-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 0.95rem;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.2s, transform 0.15s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.icon-btn:hover { background: var(--hover-bg); transform: scale(1.08); }
.icon-btn.small { width: 28px; height: 28px; font-size: 0.8rem; }

/* ===== Mode Tabs — Left side vertical ===== */
#mode-tabs {
  position: fixed;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 4px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.mode-tab:hover:not(.active) {
  color: var(--text);
  background: var(--hover-bg);
}

/* ===== Center Timer ===== */
#timer-center {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 3.5rem 1rem 5rem;
}

#timer-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(5rem, 14vw, 10rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 40px rgba(0,0,0,0.5), 0 1px 4px rgba(0,0,0,0.3);
  line-height: 1;
}

.timer-colon { opacity: 0.9; }
body.running .timer-colon { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* Clickable timer display */
#timer-display {
  cursor: pointer;
  border-radius: 16px;
  padding: 0.08em 0.15em;
  transition: background 0.2s;
  outline: none;
}

#timer-display:hover { background: rgba(255, 255, 255, 0.08); }
body.light #timer-display:hover { background: rgba(0, 0, 0, 0.05); }
body.running #timer-display { cursor: default; pointer-events: none; }

#edit-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.3s;
  margin-top: -0.2rem;
}

#timer-display:hover ~ #edit-hint { opacity: 1; }
body.running #edit-hint { display: none; }

/* Greeting */
#greeting {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text);
  text-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.2);
  margin-bottom: 0.3rem;
  text-align: center;
  line-height: 1.4;
}

#greeting-name {
  font-weight: 600;
  outline: none;
  border-bottom: 1.5px dashed transparent;
  padding: 0 0.1em;
  border-radius: 4px;
  transition: border-color 0.2s, background 0.2s;
  cursor: text;
  min-width: 2em;
  display: inline-block;
}

#greeting-name:hover {
  border-bottom-color: var(--text-dim);
}

#greeting-name:focus {
  border-bottom-color: var(--accent);
  background: rgba(255,255,255,0.08);
}

body.light #greeting-name:focus {
  background: rgba(0,0,0,0.04);
}

#greeting-line1 { font-size: 1.3em; }
#greeting-line2 { font-size: 0.85em; opacity: 0.85; font-weight: 500; }

@media (max-width: 480px) {
  #greeting { font-size: 0.95rem; }
}

@media (max-width: 360px) {
  #greeting { font-size: 0.85rem; }
}

/* ===== Apple-Style Scroll Wheel Picker ===== */
#time-picker {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
}

#time-picker.hidden { display: none; }

.picker-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.picker-sheet {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--modal-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px 20px 0 0;
  padding: 0 0 1.5rem 0;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 -4px 40px rgba(0,0,0,0.3);
  animation: sheetSlideUp 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--glass-border);
}

.picker-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.picker-action {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  transition: background 0.15s;
}

.picker-action:hover { background: var(--hover-bg); }
.picker-action.accent { color: var(--accent); font-weight: 600; }

/* Wheels container */
.picker-wheels {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 1.2rem 1rem;
  position: relative;
}

.picker-separator {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  padding: 0 0.3rem;
  opacity: 0.6;
}

.picker-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.picker-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

/* Individual drum wheel */
.picker-wheel {
  width: 90px;
  height: 180px;
  overflow: hidden;
  position: relative;
  cursor: grab;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,0,0,0.3) 15%,
    rgba(0,0,0,0.7) 30%,
    black 42%,
    black 58%,
    rgba(0,0,0,0.7) 70%,
    rgba(0,0,0,0.3) 85%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0,0,0,0.3) 15%,
    rgba(0,0,0,0.7) 30%,
    black 42%,
    black 58%,
    rgba(0,0,0,0.7) 70%,
    rgba(0,0,0,0.3) 85%,
    transparent 100%
  );
}

.picker-wheel:active { cursor: grabbing; }
.picker-wheel { touch-action: none; }

.picker-wheel-inner {
  position: absolute;
  left: 0; right: 0;
  will-change: transform;
  transition: transform 0.12s ease-out;
}

.picker-wheel-inner.snapping {
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.picker-wheel-item {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: color 0.15s, font-weight 0.15s, transform 0.15s;
}

.picker-wheel-item.selected {
  color: var(--text);
  font-weight: 700;
  font-size: 1.6rem;
}

/* Selection highlight band */
.picker-highlight {
  position: absolute;
  left: 1rem; right: 1rem;
  top: 50%;
  height: 38px;
  transform: translateY(-50%);
  border-top: 1.5px solid var(--glass-border);
  border-bottom: 1.5px solid var(--glass-border);
  background: var(--hover-bg);
  border-radius: 10px;
  pointer-events: none;
  z-index: -1;
}

/* Desktop: center the sheet */
@media (min-width: 601px) {
  #time-picker { align-items: center; }
  .picker-sheet {
    border-radius: 20px;
    max-width: 340px;
    animation-name: sheetScaleUp;
  }
  @keyframes sheetScaleUp {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
  }
}

/* Phone: smaller wheels */
@media (max-width: 480px) {
  .picker-wheel { width: 80px; height: 160px; }
  .picker-wheel-item { height: 32px; font-size: 1.2rem; }
  .picker-wheel-item.selected { font-size: 1.4rem; }
  .picker-highlight { height: 34px; }
  .picker-separator { font-size: 1.6rem; }
}

/* Timer Controls */
#timer-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.ctrl-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 1.1rem;
  width: 46px; height: 46px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.2s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.ctrl-btn:hover { background: var(--hover-bg); transform: scale(1.08); }

.ctrl-btn.primary {
  width: 60px; height: 60px;
  font-size: 1.4rem;
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.25);
  backdrop-filter: blur(16px);
}

.ctrl-btn.primary:hover { background: rgba(255,255,255,0.3); }

.ctrl-btn.pill {
  width: auto;
  border-radius: 24px;
  padding: 0 1.4rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 600;
}

/* Session Info */
#session-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
}

.dot { opacity: 0.4; }

/* Daily Goal */
#daily-goal {
  margin-top: 1.2rem;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

#goal-prompt {
  font-size: 0.975rem;
  color: var(--text-dim);
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
  margin-bottom: 0.35rem;
  transition: opacity 0.3s;
}

#daily-goal.has-goal #goal-prompt { opacity: 0.6; font-size: 0.875rem; }

#goal-input {
  background: rgba(255,255,255,0.07);
  border: 1px dashed rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 0.45rem 0.8rem;
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 500;
  text-align: center;
  min-height: 1.6em;
  outline: none;
  cursor: text;
  transition: background 0.2s, border-color 0.2s;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#goal-input:empty::before {
  content: "Tap here to set your goal...";
  color: var(--text-dim);
  font-weight: 400;
  font-style: italic;
}

#goal-input:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.3);
}

#goal-input:focus {
  background: rgba(255,255,255,0.12);
  border-color: var(--accent);
  border-style: solid;
}

body.light #goal-input {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.15);
}

body.light #goal-input:hover {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.25);
}

body.light #goal-input:focus {
  background: rgba(0,0,0,0.06);
  border-color: var(--accent);
}

/* ===== Tasks Panel ===== */
#tasks-panel {
  position: fixed;
  left: 1rem;
  bottom: 5rem;
  z-index: 20;
  width: 320px;
  max-height: 400px;
  background: var(--panel-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow-y: auto;
  transition: transform 0.3s, opacity 0.3s;
  box-shadow: var(--shadow);
}

#tasks-panel.hidden {
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.panel-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

#task-input-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

#task-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

#task-input:focus { border-color: var(--accent); }
#task-input::placeholder { color: var(--text-dim); }

#btn-add-task {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  width: 34px; height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.15s;
}

#btn-add-task:hover { transform: scale(1.08); }

#task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.task-item:hover { background: var(--hover-bg); }

.task-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px; height: 15px;
  cursor: pointer;
}

.task-item .task-text { flex: 1; }

.task-item.done .task-text {
  text-decoration: line-through;
  opacity: 0.4;
}

.task-item .task-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.task-item:hover .task-delete { opacity: 1; }

/* ===== Music Bar — Bottom ===== */
#music-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: var(--glass-bg);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.music-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}

#music-icon { font-size: 1.1rem; }

#music-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
}

.music-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.music-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.2s;
}

.music-btn:hover { background: var(--hover-bg); }

.music-btn.play-btn {
  font-size: 1.2rem;
  width: 40px; height: 40px;
  background: var(--hover-bg);
}

.music-volume {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 140px;
  justify-content: flex-end;
}

#volume-slider {
  width: 90px;
  accent-color: var(--accent);
}

/* ===== Settings Modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  background: var(--modal-bg);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 1.8rem;
  width: 90%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.modal-header h2 { font-size: 1.1rem; font-weight: 600; }

.setting-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--glass-border);
}

.setting-group label {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.setting-group input[type="number"],
.setting-group select {
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.35rem 0.6rem;
  font-family: inherit;
  font-size: 0.82rem;
  width: 80px;
  text-align: center;
  outline: none;
}

.setting-group select { width: 130px; text-align: left; }
.setting-group input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px; }

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.2rem;
  justify-content: flex-end;
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 0.5rem 1.3rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--hover-bg); color: var(--text); }
.btn-primary:hover, .btn-secondary:hover { transform: scale(1.04); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ===== Responsive — Tablets (≤768px) ===== */
@media (max-width: 768px) {
  #mode-tabs {
    position: fixed;
    left: 50%;
    top: auto;
    bottom: calc(3.8rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    flex-direction: row;
    gap: 0.2rem;
  }

  .mode-tab { padding: 0.5rem 0.9rem; font-size: 0.76rem; }

  #timer-center { padding: 3.5rem 1rem 6rem; }

  #tasks-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    bottom: 6.5rem;
    max-height: 50vh;
  }

  .music-volume { min-width: auto; }
  #volume-slider { width: 70px; }
}

/* ===== Responsive — Phones (≤480px) ===== */
@media (max-width: 480px) {
  /* Top bar: tighter spacing */
  #top-bar { padding: 0.5rem 0.75rem; }
  .logo { font-size: 0.95rem; }
  .top-right { gap: 0.25rem; }
  .icon-btn { width: 34px; height: 34px; font-size: 0.85rem; }
  #clock { font-size: 0.72rem; margin-right: 0.3rem; }

  /* Timer: scale down for small screens */
  #timer-display { font-size: clamp(3.2rem, 18vw, 5rem); }
  #timer-center { gap: 0.5rem; padding: 3rem 0.75rem 7rem; }

  /* Greeting: wrap to two lines and shrink */
  #greeting {
    font-size: 0.95rem;
    max-width: 90vw;
    line-height: 1.35;
  }

  /* Controls: bigger touch targets */
  .ctrl-btn { width: 48px; height: 48px; font-size: 1.1rem; }
  .ctrl-btn.primary { width: 58px; height: 58px; font-size: 1.3rem; }
  .ctrl-btn.pill { padding: 0 1.2rem; font-size: 0.82rem; height: 48px; }
  #timer-controls { gap: 0.7rem; }

  #session-info { font-size: 0.72rem; gap: 0.35rem; }

  #daily-goal { max-width: 90vw; }
  #goal-prompt { font-size: 0.9rem; }
  #goal-input { font-size: 1.02rem; padding: 0.4rem 0.7rem; }

  /* Mode tabs: centered at bottom, above music bar */
  #mode-tabs {
    bottom: calc(3.2rem + env(safe-area-inset-bottom, 0px));
    padding: 3px;
    border-radius: 12px;
  }
  .mode-tab { padding: 0.45rem 0.75rem; font-size: 0.72rem; border-radius: 9px; }

  /* Music bar: compact */
  #music-bar { padding: 0.4rem 0.6rem; }
  .music-info { min-width: 60px; gap: 0.3rem; }
  #music-icon { font-size: 0.9rem; }
  #music-label { font-size: 0.7rem; }
  .music-btn { width: 30px; height: 30px; font-size: 0.85rem; }
  .music-btn.play-btn { width: 36px; height: 36px; font-size: 1rem; }
  .music-controls { gap: 0.15rem; }
  #volume-slider { width: 50px; }
  .music-volume { gap: 0.2rem; }

  /* Tasks panel: full width overlay */
  #tasks-panel {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    bottom: 6rem;
    max-height: 45vh;
    border-radius: 14px;
    padding: 0.8rem;
  }

  #task-input { font-size: 16px; padding: 0.55rem 0.7rem; }  /* 16px prevents iOS zoom */
  #btn-add-task { width: 36px; height: 36px; }
  .task-item { padding: 0.45rem 0.5rem; font-size: 0.82rem; }
  .task-item input[type="checkbox"] { width: 18px; height: 18px; }
  .task-item .task-delete { opacity: 1; }  /* Always visible on touch */

  /* Modal: full width on phones */
  .modal-content {
    width: 95%;
    padding: 1.4rem;
    border-radius: 16px;
    max-height: 90vh;
  }

  .setting-group { padding: 0.65rem 0; }
  .setting-group label { font-size: 0.8rem; }
  .setting-group input[type="number"] { width: 70px; }
  .setting-group select { width: 120px; }
  .setting-group input[type="checkbox"] { width: 20px; height: 20px; }
  .btn-primary, .btn-secondary { padding: 0.6rem 1.2rem; font-size: 0.85rem; }

  /* Picker: full-width bottom sheet */
  .picker-sheet { max-width: 100%; border-radius: 16px 16px 0 0; }
  .picker-action { font-size: 1rem; padding: 0.5rem 0.8rem; }
}

/* ===== Responsive — Very small phones (≤360px) ===== */
@media (max-width: 360px) {
  #timer-display { font-size: clamp(2.8rem, 20vw, 3.5rem); }
  #timer-center { gap: 0.4rem; padding: 2.8rem 0.5rem 7rem; }
  #greeting { font-size: 0.82rem; }
  .ctrl-btn { width: 44px; height: 44px; }
  .ctrl-btn.primary { width: 52px; height: 52px; }
  .mode-tab { padding: 0.4rem 0.6rem; font-size: 0.68rem; }
  #music-label { display: none; }
  #volume-slider { width: 40px; }
  .logo { font-size: 0.85rem; }
  #clock { display: none; }
}

/* ===== Landscape phones ===== */
@media (max-height: 500px) and (orientation: landscape) {
  #timer-display { font-size: clamp(2.5rem, 10vh, 4rem); }
  #timer-center { gap: 0.3rem; padding: 2.5rem 1rem 3.5rem; }
  #greeting { font-size: 0.8rem; }
  #session-info { font-size: 0.7rem; }

  #mode-tabs {
    position: fixed;
    left: 0.5rem;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    flex-direction: column;
  }

  .mode-tab { padding: 0.35rem 0.6rem; font-size: 0.68rem; }

  #tasks-panel { max-height: 60vh; bottom: 3.5rem; }
}

/* ===== Safe area support for notched phones ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #music-bar {
    padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0px));
  }
}
