/* ================= app shell ================= */
.app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* ================= sidebar ================= */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  border-right: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.2s ease;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px 10px;
  min-width: 0;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px -10px var(--accent-ink);
}
.brand-text {
  min-width: 0;
}
.brand-text b {
  display: block;
  font-size: 0.88rem;
  font-weight: 660;
  letter-spacing: 0.01em;
}
.brand-text span {
  display: block;
  font-size: 10.5px;
  color: var(--text-3);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  min-height: 0;
}
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  padding: 10px 8px 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 550;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  transition: all 0.15s ease;
  min-width: 0;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 620;
}
.nav-item .nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 650;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: 99px;
  padding: 0 6px;
  height: 16px;
  line-height: 16px;
}
.nav-item.is-active .nav-badge {
  background: rgba(255, 255, 255, 0.7);
  color: var(--accent-ink);
}
.nav-foot {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.app.nav-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
  padding: 12px 8px;
}
.app.nav-collapsed .brand-text,
.app.nav-collapsed .nav-label,
.app.nav-collapsed .nav-badge,
.app.nav-collapsed .nav-group-label {
  display: none;
}
.app.nav-collapsed .nav-item {
  justify-content: center;
  padding: 0;
}
.app.nav-collapsed .brand {
  justify-content: center;
  padding: 4px 0 10px;
}

/* ================= main ================= */
.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 {
  font-size: 0.95rem;
  font-weight: 640;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .tb-date {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 550;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.view {
  padding: var(--gap);
  max-width: var(--view-max);
  width: 100%;
  margin: 0 auto;
  flex: 1 1 auto;
}

/* ================= dashboard grid ================= */
.dash {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  grid-auto-flow: row dense;
  align-items: start;
}
.w-tasks {
  grid-column: span 5;
  grid-row: span 2;
}
.w-focus {
  grid-column: span 4;
}
.w-mood {
  grid-column: span 3;
}
.w-schedule {
  grid-column: span 4;
}
.w-study {
  grid-column: span 3;
}
.w-finance {
  grid-column: span 4;
}
.w-health {
  grid-column: span 4;
}
.w-quick {
  grid-column: span 4;
}
.w-recent {
  grid-column: span 12;
}

/* ================= widget ================= */
.widget {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  position: relative;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.widget.clickable {
  cursor: pointer;
}
.widget.clickable:hover {
  box-shadow: var(--shadow-lift);
  border-color: var(--line);
}
.widget-h {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.widget-h .ico {
  color: var(--accent);
}
.widget-title {
  font-size: var(--fs-sm);
  font-weight: 640;
  letter-spacing: 0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.widget-h .spacer {
  margin-left: auto;
}
.widget-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 550;
}
.widget-b {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.widget-f {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line-2);
  padding-top: 8px;
  margin-top: auto;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.scroll-y {
  overflow-y: auto;
  max-height: 216px;
  min-height: 0;
  padding-right: 2px;
  margin-right: -2px;
}
.scroll-y.tall {
  max-height: 268px;
}

/* ================= bottom nav ================= */
.bottomnav {
  display: none;
}

/* ================= overlay / modal / sheet ================= */
.overlay-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(43, 36, 60, 0.32);
  backdrop-filter: blur(2px);
  pointer-events: auto;
  animation: fade 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}
@keyframes slide-up {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  width: 100%;
  max-width: 420px;
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  animation: pop 0.2s ease;
  overflow: hidden;
}
.modal.wide {
  max-width: 560px;
}
.modal-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
}
.modal-h h2 {
  font-size: 0.9rem;
  font-weight: 640;
}
.modal-b {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.modal-f {
  padding: 11px 14px;
  border-top: 1px solid var(--line-2);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid .span-2 {
  grid-column: span 2;
}

.bi-sheet .modal {
  align-self: flex-end;
  max-width: 520px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  animation: slide-up 0.22s ease;
}
.bi-sheet {
  align-items: flex-end;
  padding: 0;
}

/* ================= toast ================= */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 120;
  pointer-events: none;
  align-items: center;
}
.toast {
  pointer-events: auto;
  background: #3a3444;
  color: #f7f5fa;
  font-size: var(--fs-sm);
  font-weight: 550;
  padding: 8px 13px;
  border-radius: 99px;
  box-shadow: var(--shadow-lift);
  animation: pop 0.2s ease;
  max-width: 84vw;
  text-align: center;
}

/* ================= responsive ================= */
@media (max-width: 1180px) {
  .w-tasks {
    grid-column: span 7;
  }
  .w-focus {
    grid-column: span 5;
  }
  .w-mood {
    grid-column: span 5;
  }
  .w-schedule {
    grid-column: span 7;
  }
  .w-study {
    grid-column: span 5;
  }
  .w-finance,
  .w-health,
  .w-quick {
    grid-column: span 6;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .topbar {
    padding: 0 12px;
  }
  .bottomnav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line-2);
    z-index: 60;
  }
  .bn-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease;
  }
  .bn-item.is-active {
    color: var(--accent-ink);
  }
  .bn-item.is-active .ico {
    color: var(--accent);
  }
  .view {
    padding: 10px 10px calc(var(--bottomnav-h) + 18px);
  }
  .dash {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .w-tasks,
  .w-focus,
  .w-schedule,
  .w-finance,
  .w-recent {
    grid-column: span 2;
    grid-row: auto;
  }
  .w-mood,
  .w-study,
  .w-health,
  .w-quick {
    grid-column: span 1;
  }
  .widget {
    padding: 11px;
    gap: 8px;
    border-radius: 12px;
  }
  .modal {
    max-width: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: span 1;
  }
}

@media (min-width: 901px) and (max-width: 1040px) {
  .w-mood,
  .w-study {
    grid-column: span 4;
  }
  .w-focus {
    grid-column: span 8;
  }
}
