:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa1ac;
  --accent: #4f8cff;
  --accent-hover: #3d7aef;
  --danger: #e5484d;
  --green: #2e7d32;
  --yellow: #b8860b;
  --red: #c62828;
  --open: #546e7a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
}

.sidebar-header h1 {
  font-size: 1.2rem;
  margin: 0 0 12px 0;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: white; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: rgba(229, 72, 77, 0.1); }

.btn-add {
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--border);
  width: 100%;
  margin-top: 8px;
}
.btn-add:hover { border-color: var(--accent); }

.btn-small {
  background: var(--accent);
  color: white;
  padding: 8px 12px;
}

.week-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}

.week-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
}
.week-item:hover { background: var(--panel-2); }
.week-item.active { background: var(--panel-2); border-color: var(--accent); }

.week-item-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.week-item-date {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.week-item-badges {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 20px;
  color: white;
}

.category-manager {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.category-manager h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 10px 0;
}

.category-list {
  list-style: none;
  margin: 0 0 10px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  background: var(--panel-2);
  padding: 6px 10px;
  border-radius: var(--radius);
}

.category-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.category-name { display: flex; align-items: center; }

.category-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
}
.category-delete:hover { color: var(--danger); }

.category-form {
  display: flex;
  gap: 6px;
}
.category-form input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
}
.category-form input[type="color"] {
  width: 36px;
  border: none;
  background: none;
  padding: 0;
  border-radius: var(--radius);
}

.main {
  flex: 1;
  padding: 30px 40px;
  overflow-y: auto;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  margin-top: 100px;
  font-size: 1.1rem;
}

.hidden { display: none !important; }

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 4px;
}

.week-title-input {
  flex: 1;
  font-size: 1.5rem;
  font-weight: 700;
  background: none;
  border: none;
  color: var(--text);
  padding: 6px 0;
}
.week-title-input:focus { outline: none; border-bottom: 1px solid var(--accent); }

.editor-actions { display: flex; gap: 10px; }

.week-date-label {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.editor-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.editor-section h2 {
  font-size: 1rem;
  margin: 0 0 14px 0;
}

.people-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.person-column .person-name {
  font-size: 1.1rem;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}

.person-column .editor-section h3 {
  font-size: 0.9rem;
  margin: 0 0 12px 0;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.item-list { display: flex; flex-direction: column; gap: 10px; }

.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  padding: 10px;
  border-radius: var(--radius);
}

.item-row select,
.item-row input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px;
}

.item-row .item-category { min-width: 110px; }
.item-row .item-text { flex: 1; }
.item-row .item-status { min-width: 100px; }

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-green { background: var(--green); }
.status-yellow { background: var(--yellow); }
.status-red { background: var(--red); }
.status-open { background: var(--open); }

.item-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
}
.item-remove:hover { color: var(--danger); }

textarea#week-notes,
.person-notes {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: opacity 0.2s ease;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

/* --- Mobile topbar / drawer (hidden on desktop) --- */
.mobile-topbar { display: none; }
.btn-sidebar-close { display: none; }
.sidebar-backdrop { display: none; }

body.no-scroll { overflow: hidden; }

/* --- Responsive breakpoints --- */
@media (max-width: 900px) {
  .app { flex-direction: column; min-height: 100vh; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-title {
    font-size: 1.05rem;
    margin: 0;
  }

  .btn-menu-toggle {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.2rem;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 30;
  }
  .sidebar-backdrop.hidden { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    min-width: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 40;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-header {
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .sidebar-header h1 { flex: 1 1 auto; margin: 0; }

  .btn-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.3rem;
    cursor: pointer;
  }

  .main {
    padding: 16px;
  }

  .editor-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .editor-actions {
    display: flex;
    gap: 10px;
  }
  .editor-actions .btn { flex: 1; }

  .week-title-input {
    font-size: 1.25rem;
  }

  .item-row {
    flex-wrap: wrap;
  }
  .item-row .item-text {
    flex: 1 1 100%;
    order: -1;
  }
  .item-row .item-category,
  .item-row .item-status {
    flex: 1 1 auto;
    min-width: 0;
  }

  .people-columns {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .empty-state {
    margin-top: 60px;
    padding: 0 16px;
  }

  /* Touch-friendly tap targets */
  .btn,
  .item-row select,
  .item-row input[type="text"],
  .category-form input[type="text"],
  .week-title-input {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .main { padding: 12px; }
  .editor-section { padding: 14px; }
  .sidebar { width: 88%; }
  .week-title-input { font-size: 1.1rem; }
}
