:root {
  --bg: #0d1017;
  --panel: #151a24;
  --panel2: #1b2230;
  --card: rgba(255,255,255,.075);
  --card2: rgba(255,255,255,.11);
  --text: #f4f7fb;
  --muted: #9aa7b8;
  --line: rgba(255,255,255,.12);
  --accent: #7c5cff;
  --accent2: #00d4ff;
  --danger: #ff5c7a;
  --good: #3cff9d;
  --warn: #ffd166;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
  --radius: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124,92,255,.32), transparent 28%),
    radial-gradient(circle at top right, rgba(0,212,255,.20), transparent 26%),
    var(--bg);
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: rgba(13,16,23,.78);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-weight: 900;
  box-shadow: 0 12px 32px rgba(124,92,255,.35);
}

.brand h1, .brand p, .topbar h2, .topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

.brand p, .topbar p, .side-title, .task-note, .meta {
  color: var(--muted);
}

.primary, .ghost, .nav-item, .tiny, .icon {
  border-radius: 16px;
  min-height: 44px;
  padding: 11px 14px;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-weight: 800;
  box-shadow: 0 10px 25px rgba(124,92,255,.22);
}

.ghost {
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
}

.full {
  width: 100%;
  display: block;
  text-align: center;
}

nav {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.nav-item {
  text-align: left;
  background: transparent;
  color: var(--muted);
}

.nav-item.active, .nav-item:hover {
  background: rgba(255,255,255,.09);
  color: var(--text);
}

.side-block {
  margin-top: 20px;
}

.side-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}

.tiny, .icon {
  min-height: 34px;
  padding: 5px 10px;
  background: rgba(255,255,255,.09);
}

.branch-list {
  display: grid;
  gap: 8px;
}

.branch-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  color: var(--text);
}

.branch-chip.active {
  border-color: rgba(124,92,255,.8);
  background: rgba(124,92,255,.18);
}

.file-label {
  margin-top: 8px;
}

.main {
  padding: 26px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: -1.4px;
}

.mobile-menu {
  display: none;
  background: rgba(255,255,255,.09);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 48px;
  height: 48px;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric b {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 190px 130px;
  gap: 12px;
  margin-bottom: 18px;
}

input, textarea, select {
  width: 100%;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input::placeholder, textarea::placeholder {
  color: #748094;
}

.workspace {
  display: grid;
  gap: 18px;
}

.branch-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.branch-head {
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.branch-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.emoji {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 16px;
  background: var(--card2);
  font-size: 23px;
}

.branch-name h3 {
  margin: 0;
  font-size: 20px;
}

.branch-name p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.branch-actions, .topic-actions, .task-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topics {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.topic-card {
  background: rgba(0,0,0,.20);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
}

.topic-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.topic-head h4 {
  margin: 0;
  font-size: 16px;
}

.tasks {
  display: grid;
  gap: 8px;
}

.task {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.055);
  border: 1px solid transparent;
}

.task:hover {
  border-color: var(--line);
}

.check {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  color: transparent;
}

.task.done .check {
  background: rgba(60,255,157,.16);
  color: var(--good);
  border-color: rgba(60,255,157,.45);
}

.task-main b {
  display: block;
  line-height: 1.25;
}

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

.task-note {
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.35;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255,255,255,.08);
  color: var(--muted);
  white-space: nowrap;
}

.badge.high {
  color: #ffd4dc;
  background: rgba(255,92,122,.17);
}

.badge.mid {
  color: #fff0bc;
  background: rgba(255,209,102,.16);
}

.badge.low {
  color: #c9ffdf;
  background: rgba(60,255,157,.13);
}

.danger {
  color: #ffd4dc;
  background: rgba(255,92,122,.14);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 30px 14px;
  border: 1px dashed var(--line);
  border-radius: 22px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 60;
  background: rgba(0,0,0,.62);
  padding: 18px;
}

.modal.show {
  display: grid;
}

.modal-card {
  width: min(620px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: #151a24;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
  font-size: 22px;
}

.form {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #202838;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: .2s;
  z-index: 80;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mobile-bottom {
  display: none;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 310px;
    max-width: 86vw;
    z-index: 50;
    transform: translateX(-105%);
    transition: .22s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 16px;
    padding-bottom: 92px;
  }

  .mobile-menu {
    display: block;
  }

  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar #addTaskBtn {
    display: none;
  }

  .branch-head, .topic-head {
    align-items: flex-start;
  }

  .branch-actions, .topic-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .task {
    grid-template-columns: 34px 1fr;
  }

  .task-actions {
    grid-column: 2;
  }

  .mobile-bottom {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 8px;
    background: rgba(21,26,36,.88);
    backdrop-filter: blur(16px);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
  }

  .mobile-bottom button {
    min-height: 46px;
    border-radius: 16px;
    background: rgba(255,255,255,.08);
    font-size: 12px;
  }

  #mobileAdd {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    font-size: 20px;
    font-weight: 900;
  }
}

@media (max-width: 520px) {
  .dashboard {
    gap: 8px;
  }

  .metric {
    padding: 13px;
    border-radius: 18px;
  }

  .metric b {
    font-size: 24px;
  }

  .topbar h2 {
    font-size: 26px;
  }

  .branch-head {
    flex-direction: column;
  }

  .branch-actions {
    width: 100%;
  }

  .branch-actions button {
    flex: 1;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal {
    align-items: end;
    padding: 10px;
  }

  .modal-card {
    border-radius: 24px;
  }
}
