:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2333;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --success: #3fb950;
  --danger: #f85149;
  --warning: #d29922;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Connection Banner ─── */
.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 8px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.banner.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.banner.offline {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
  border-bottom: 1px solid rgba(248, 81, 73, 0.3);
}

.banner.online {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
  border-bottom: 1px solid rgba(63, 185, 80, 0.3);
}

/* ─── Header ─── */
.header {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s;
}

.icon-btn:hover, .icon-btn:active {
  background: var(--bg-hover);
  color: var(--text);
}

/* ─── Tabs ─── */
.tabs {
  display: flex;
  padding: 0 16px;
  gap: 4px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ─── Task List ─── */
.task-list {
  padding: 0 16px;
}

.task-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

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

.task-item:active {
  transform: scale(0.98);
}

.task-item.completed {
  opacity: 0.5;
}

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

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-checkbox {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.task-checkbox.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.task-item.completed .task-checkbox {
  background: var(--success);
  border-color: var(--success);
}

.task-item.completed .task-checkbox::after {
  content: '✓';
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.task-title {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
}

.task-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.expand-toggle {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.task-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
  font-weight: 600;
}

/* ─── Subtasks ─── */
.subtask-list {
  margin-top: 10px;
  padding-left: 34px;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}

.subtask-checkbox {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.subtask-item.completed .subtask-checkbox {
  background: var(--success);
  border-color: var(--success);
}

.subtask-item.completed .subtask-checkbox::after {
  content: '✓';
  color: white;
  font-size: 9px;
  font-weight: 700;
}

.subtask-item.completed .subtask-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.subtask-title {
  font-size: 13px;
  color: var(--text);
}

.subtask-progress {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 15px;
  line-height: 1.6;
}

/* ─── Add Task Form ─── */
.add-task-section {
  padding: 16px;
}

.add-task-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.add-task-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.add-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.add-form input, .add-form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  outline: none;
}

.add-form input:focus {
  border-color: var(--accent);
}

.form-row {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
}

/* ─── Typical Day Editor ─── */
.def-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.def-item .def-title {
  font-size: 15px;
  font-weight: 500;
}

.def-item .def-type {
  font-size: 11px;
  color: var(--text-muted);
}

.def-actions {
  display: flex;
  gap: 6px;
}

.def-actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.def-actions button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.def-actions button.delete:hover {
  color: var(--danger);
}

/* ─── History ─── */
.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.history-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s;
}

.history-header:hover {
  background: var(--bg-hover);
}

.history-date {
  font-size: 15px;
  font-weight: 600;
}

.history-stats {
  font-size: 13px;
  color: var(--text-muted);
}

.history-details {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}

.history-details .history-task {
  padding: 6px 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-task .dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
}

.history-task .dot.done {
  background: var(--success);
}

.history-task .dot.missed {
  background: var(--danger);
}

.history-task .dot.partial {
  background: var(--warning);
}

.history-task.completed-task {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ─── Settings ─── */
.settings-section {
  padding: 16px;
}

.setting-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.setting-card label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.setting-card .setting-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.setting-card input[type="time"] {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  width: 100%;
}

.setting-card input[type="time"]:focus {
  border-color: var(--accent);
}

/* ─── Date Display ─── */
.date-display {
  padding: 0 16px 16px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

.date-display span {
  color: var(--accent);
  font-weight: 600;
}

/* ─── Progress Bar ─── */
.progress-section {
  padding: 0 16px 16px;
}

.progress-bar-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--success);
  border-radius: 20px;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ─── Subtask input ─── */
.subtask-inputs {
  margin-top: 8px;
}

.subtask-input-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.subtask-input-row input {
  flex: 1;
  margin-bottom: 0 !important;
}

.subtask-input-row button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}

.add-subtask-link {
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 900;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  padding: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  margin-bottom: 16px;
  font-size: 18px;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
  }
  .modal {
    border-radius: var(--radius);
    max-width: 450px;
  }
}

/* ─── Changelog ─── */
.changelog-entry {
  margin-bottom: 20px;
}

.changelog-version {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.changelog-date {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

.changelog-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.changelog-list li {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 0 4px 16px;
  position: relative;
  line-height: 1.5;
}

.changelog-list li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ─── Icon Picker ─── */
.icon-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.icon-opt {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.icon-opt:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.icon-opt.selected {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.15);
}

/* ─── Desktop Contained Layout ─── */
@media (min-width: 768px) {
  body {
    padding: 32px 16px;
  }

  #app {
    max-width: 720px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
}
