:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #86868b;
  --accent: #007aff;
  --accent-light: rgba(0, 122, 255, 0.08);
  --border: #e5e5e7;
  --complete: #34c759;
  --delete: #ff3b30;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Nav ---- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.nav-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.nav-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
}

.nav-tab {
  padding: 5px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.nav-tab:hover { color: var(--text); }

.nav-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ---- Today View ---- */

.today-view {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 16px;
}

.view-header h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
}

/* ---- Todo List ---- */

.todo-list {
  min-height: 32px;
  border-radius: 8px;
  transition: background 0.15s;
}

/* ---- Todo Item ---- */

.todo-item {
  display: flex;
  align-items: center;
  padding: 7px 8px;
  margin: 2px 0;
  border-radius: 8px;
  background: var(--card);
  gap: 6px;
  transition: opacity 0.15s, background 0.15s, box-shadow 0.15s;
  user-select: none;
}

.todo-item:hover { background: #f0f0f2; }
.todo-item.completed { opacity: 0.55; }
.todo-item.completed .todo-text { text-decoration: line-through; }
.todo-item.dragging { opacity: 0.25; }

/* ---- Drag Handle ---- */

.drag-handle {
  cursor: grab;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 2px;
  user-select: none;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  line-height: 1;
  touch-action: none;
}

.todo-item:hover .drag-handle,
.todo-item:active .drag-handle { opacity: 0.5; }

/* ---- Checkbox ---- */

.todo-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: white;
  flex-shrink: 0;
  transition: all 0.15s;
  font-family: inherit;
  line-height: 1;
}

.todo-checkbox:hover { border-color: var(--complete); }
.todo-checkbox.checked {
  background: var(--complete);
  border-color: var(--complete);
}

/* ---- Todo Text ---- */

.todo-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.4;
  min-width: 0;
  cursor: text;
  padding: 2px 0;
}

.edit-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  padding: 2px 0;
  border-bottom: 2px solid var(--accent);
  min-width: 0;
}

/* ---- Add Child Button ---- */

.todo-add-child {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
}

.todo-item:hover .todo-add-child { opacity: 0.6; }
.todo-add-child:hover {
  opacity: 1 !important;
  color: var(--accent);
  background: var(--accent-light);
}

/* ---- Breadcrumb Prefix ---- */

.breadcrumb-prefix {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ---- Delete Button ---- */

.todo-delete {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
}

.todo-item:hover .todo-delete { opacity: 0.6; }
.todo-delete:hover {
  opacity: 1 !important;
  color: var(--delete);
  background: rgba(255, 59, 48, 0.1);
}

/* ---- Collapse Toggle ---- */

.collapse-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 9px;
  color: var(--text-secondary);
  padding: 2px;
  width: 18px;
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
  transition: color 0.15s;
}

.collapse-toggle:hover { color: var(--text); }

.collapse-toggle-spacer {
  width: 18px;
  flex-shrink: 0;
}

/* ---- Add Form ---- */

.add-todo-form { margin-top: 12px; }

.add-todo-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.add-todo-input:focus { border-color: var(--accent); }
.add-todo-input::placeholder { color: var(--text-secondary); }

/* ---- Plan View ---- */

.plan-view { height: calc(100vh - 52px); }

.plan-content {
  display: flex;
  height: 100%;
}

.plan-days {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-unassigned {
  width: 340px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  background: var(--card);
  display: flex;
  flex-direction: column;
}

.plan-unassigned .todo-list { flex: 1; }

.section-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ---- Day Card ---- */

.day-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
  flex-shrink: 0;
}

.day-card.is-today { border-left: 3px solid var(--accent); }

.day-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.day-card.is-today .day-header { color: var(--accent); }

.day-card .add-todo-form { margin-top: 6px; }

.day-card .add-todo-input {
  padding: 6px 10px;
  font-size: 13px;
}

/* ---- Empty State ---- */

.empty-state {
  text-align: center;
  padding: 20px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.day-card .empty-state {
  padding: 8px;
  font-size: 13px;
}

/* ---- Drag Preview ---- */

.drag-preview {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.92;
  transform: rotate(1.5deg) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  background: var(--card);
  display: flex;
  align-items: center;
  padding: 7px 8px;
  gap: 6px;
  font-size: 15px;
}

/* ---- Drop Indicators ---- */

.drop-line {
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 1px 0;
  pointer-events: none;
}

.nest-highlight {
  box-shadow: inset 0 0 0 2px var(--accent) !important;
  background: var(--accent-light) !important;
}

.drop-highlight {
  background: var(--accent-light) !important;
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: var(--radius);
}

/* ---- Rotate Message (portrait mobile) ---- */

.rotate-message {
  display: none;
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.rotate-icon {
  font-size: 48px;
  line-height: 1;
}

.rotate-message p {
  font-size: 16px;
  max-width: 260px;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .drag-handle { opacity: 0.35; }
  .todo-delete { opacity: 0.4; }
  .todo-add-child { opacity: 0.4; }
}

@media (max-width: 768px) and (orientation: portrait) {
  .plan-content { display: none !important; }
  .rotate-message { display: flex; }
}

@media (max-width: 900px) and (orientation: landscape) {
  .plan-unassigned { width: 240px; padding: 12px; }
  .plan-days { padding: 12px; }
}

@media (max-width: 768px) {
  .today-view { padding: 20px 12px; }
  .view-header h2 { font-size: 22px; }
}
