:root {
  --bg: #F7F3EE;
  --surface: #FFFFFF;
  --surface2: #FBF8F4;
  --border: #E8E1D9;
  --border2: #D6CEC4;
  --text: #1C1917;
  --muted: #79716B;
  --accent: #F97316;
  --accent-light: rgba(249,115,22,0.10);
  --accent2: #7C3AED;
  --success: #16A34A;
  --danger: #DC2626;
  --shadow-sm: 0 1px 4px rgba(28,25,23,0.06);
  --shadow: 0 4px 18px rgba(28,25,23,0.09);
  --shadow-lg: 0 12px 40px rgba(28,25,23,0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --header-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Header ── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
}

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

.header-logo {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.header-name {
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text);
}

.header-date {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  padding-left: 4px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--bg); color: var(--danger); }
.icon-btn svg { width: 17px; height: 17px; stroke-width: 1.8; }

/* ── Main 3-col layout ── */
.app-layout {
  display: grid;
  grid-template-columns: 255px 1fr 274px;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--header-h));
}

/* ── Tasks panel ── */
.tasks-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.add-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
  letter-spacing: 0.01em;
}

.add-btn:hover { opacity: 0.88; transform: scale(1.04); }
.add-btn:active { transform: scale(0.97); }

/* Task form */
.task-form {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.task-form input[type=text] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 9px;
  font-family: inherit;
}

.task-form input[type=text]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}

.task-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.task-form select {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
  font-family: inherit;
}

.color-picks {
  display: flex;
  gap: 5px;
  align-items: center;
}

.color-pick {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  outline: none;
  padding: 0;
}

.color-pick:hover { transform: scale(1.2); }
.color-pick.active { border-color: var(--text); transform: scale(1.18); }

.task-form-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}

.btn-primary:hover { opacity: 0.87; }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 13px;
  font-size: 0.82rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

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

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}

.btn-danger:hover { opacity: 0.87; }

/* Unscheduled label */
.unscheduled-label {
  padding: 9px 16px 3px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--border2);
  flex-shrink: 0;
}

.unscheduled-list {
  flex: 1;
  overflow-y: auto;
  padding: 5px 10px 14px;
}

.empty-msg {
  color: var(--border2);
  font-size: 0.8rem;
  text-align: center;
  padding: 20px 12px;
  line-height: 1.5;
}

/* Task chip (draggable) */
.task-chip {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  overflow: hidden;
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.12s, border-color 0.15s;
  user-select: none;
  position: relative;
}

.task-chip:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  border-color: var(--border2);
}

.task-chip:active { cursor: grabbing; }
.task-chip.dragging { opacity: 0.45; box-shadow: var(--shadow-lg); }

.task-chip-bar {
  width: 3.5px;
  background: var(--task-color, #F97316);
  flex-shrink: 0;
}

.task-chip-body {
  flex: 1;
  padding: 8px 8px 8px 9px;
  min-width: 0;
}

.task-chip-title {
  display: block;
  font-size: 0.855rem;
  font-weight: 530;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.task-chip-dur {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
  display: block;
}

.task-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 8px 9px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  align-self: center;
}

.task-chip:hover .task-del { opacity: 1; }
.task-del:hover { color: var(--danger); }

/* ── Time grid ── */
.time-grid {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.time-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 24px;
}

/* Current time line */
.time-now-bar {
  grid-column: 1 / -1;
  height: 2px;
  background: var(--danger);
  border-radius: 1px;
  position: relative;
  margin: 2px 0;
}

.time-now-bar::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
}

/* Hour block */
.hour-block {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 6px;
  margin-bottom: 3px;
  align-items: start;
}

.hour-block.current-hour .hour-zone {
  border-color: var(--border2);
  background: rgba(249,115,22,0.03);
}

.hour-label {
  font-size: 0.68rem;
  font-weight: 650;
  color: var(--border2);
  text-align: right;
  padding-top: 9px;
  white-space: nowrap;
  user-select: none;
}

.hour-block.current-hour .hour-label {
  color: var(--accent);
}

.hour-zone {
  min-height: 40px;
  border-radius: 8px;
  border: 1.5px dashed var(--border);
  padding: 3px;
  transition: background 0.15s, border-color 0.15s, border-style 0.1s;
}

.hour-zone.drag-over {
  background: var(--accent-light);
  border-color: var(--accent);
  border-style: solid;
}

.drop-hint {
  font-size: 0.68rem;
  color: var(--border);
  text-align: center;
  padding: 7px 0;
  user-select: none;
  pointer-events: none;
}

/* Scheduled task */
.scheduled-task {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 3px;
  overflow: hidden;
  transition: opacity 0.2s;
}

.scheduled-task.done { opacity: 0.5; }

.scheduled-bar {
  width: 3px;
  background: var(--task-color, #F97316);
  flex-shrink: 0;
}

.scheduled-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 7px;
  min-width: 0;
}

.scheduled-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.scheduled-check input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--success);
  cursor: pointer;
  flex-shrink: 0;
}

.scheduled-title {
  font-size: 0.84rem;
  font-weight: 480;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scheduled-task.done .scheduled-title {
  text-decoration: line-through;
  color: var(--muted);
}

.scheduled-dur {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.task-unschedule {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  align-self: center;
  flex-shrink: 0;
  line-height: 1;
}

.scheduled-task:hover .task-unschedule { opacity: 1; }
.task-unschedule:hover { color: var(--accent2); }

/* ── Focus panel ── */
.focus-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Momentum ring */
.ring-section {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ring-wrap {
  position: relative;
  width: 148px;
  height: 148px;
}

.momentum-ring {
  width: 148px;
  height: 148px;
  transform: rotate(-90deg);
}

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

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.65s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s;
}

.ring-fill.complete {
  stroke: var(--success);
  filter: drop-shadow(0 0 5px rgba(22,163,74,0.5));
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ring-pct {
  font-size: 1.65rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}

.ring-sub {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-top: 3px;
}

.ring-stats {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

/* Sounds section */
.sounds-section {
  padding: 16px 16px 22px;
  flex: 1;
}

.sounds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.sounds-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.play-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px 5px 10px;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.18s;
  font-family: inherit;
}

.play-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.play-btn.playing {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.play-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Sound tracks */
.sound-track {
  display: grid;
  grid-template-columns: 80px 1fr 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.sound-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sound-icon { font-size: 0.95rem; line-height: 1; }

.sound-name {
  font-size: 0.8rem;
  font-weight: 530;
  color: var(--text);
}

.sound-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  width: 100%;
}

.sound-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(249,115,22,0.35);
  transition: transform 0.12s;
}

.sound-slider::-webkit-slider-thumb:hover { transform: scale(1.25); }

.sound-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 5px rgba(249,115,22,0.35);
}

.sound-vol {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 24px 20px;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: scaleIn 0.2s cubic-bezier(0.34, 1.36, 0.64, 1);
}

@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal h3 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 7px;
}

.modal p {
  font-size: 0.87rem;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.55;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Touch ghost ── */
.touch-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.82;
  transform: rotate(2deg) scale(1.04);
  transition: none;
  box-shadow: var(--shadow-lg);
}

/* ── Mobile / responsive ── */
@media (max-width: 900px) {
  body { overflow-y: auto; }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    overflow: visible;
  }

  /* Reorder: ring first, then tasks, then time grid */
  .focus-panel { order: 0; border-left: none; border-bottom: 1px solid var(--border); }
  .tasks-panel { order: 1; border-right: none; border-bottom: 1px solid var(--border); max-height: 320px; }
  .time-grid { order: 2; min-height: 420px; max-height: 70vh; overflow: hidden; }

  .ring-section {
    flex-direction: row;
    gap: 24px;
    justify-content: center;
    padding: 16px 20px;
  }

  .ring-wrap { width: 110px; height: 110px; }
  .momentum-ring { width: 110px; height: 110px; }
  .ring-pct { font-size: 1.35rem; }

  .sounds-section { padding: 12px 16px 16px; }

  .sound-track { grid-template-columns: 74px 1fr 28px; gap: 6px; margin-bottom: 10px; }
}

@media (max-width: 560px) {
  .header-date { display: none; }
  .header-name { font-size: 1rem; }

  .ring-section { flex-direction: column; align-items: center; }
  .ring-wrap { width: 120px; height: 120px; }
  .momentum-ring { width: 120px; height: 120px; }

  .time-scroll { padding: 10px 12px 20px; }
  .hour-block { grid-template-columns: 46px 1fr; }
}
