:root {
  color-scheme: light;
  --ink: #20231f;
  --muted: #756f64;
  --line: #ded5c5;
  --paper: #f6efe3;
  --panel: #fffaf2;
  --green: #4f6f52;
  --green-dark: #324936;
  --yellow: #d9a441;
  --coral: #bd654f;
  --blue: #5b6f9c;
  --lilac: #8a6f9f;
  --soft: #edf3ea;
  --soft-blue: #eceff7;
  --danger-bg: #f9e8e1;
  --danger: #9b4938;
  --shadow: 0 18px 45px rgba(61, 50, 34, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(79, 111, 82, 0.12), transparent 42%),
    linear-gradient(315deg, rgba(217, 164, 65, 0.14), transparent 34%),
    var(--paper);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: rgba(255, 250, 242, 0.78);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.05rem;
}

.eyebrow,
.metric-label {
  margin: 0;
  color: var(--muted);
}

.primary-button,
.ghost-button,
.inline-form button,
.exam-form button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 10px 24px rgba(79, 111, 82, 0.22);
}

.primary-button.compact {
  width: auto;
  min-width: 92px;
  box-shadow: none;
}

.ghost-button {
  background: var(--soft);
  color: var(--green-dark);
}

.ghost-button.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.app-nav {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.app-nav-item {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
}

.app-nav-item.active,
.app-nav-item:hover {
  background: var(--soft);
  color: var(--green-dark);
}

.topic-tree {
  margin-top: 14px;
}

.sidebar.section-mode #addRootTopic,
.sidebar.section-mode .topic-tree {
  display: none;
}

.tree-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 4px;
  margin: 3px 0;
}

.tree-item.sidebar-dragging {
  opacity: 0.35;
}

.tree-item.drop-inside .tree-row {
  box-shadow: inset 0 0 0 2px var(--green);
  background: var(--soft);
}

.tree-item.drop-before {
  border-top: 3px solid var(--yellow);
}

.tree-item.drop-after {
  border-bottom: 3px solid var(--yellow);
}

.tree-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 38px;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.tree-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row.active,
.tree-row:hover {
  background: var(--soft);
}

.tree-row.draggable-row {
  cursor: grab;
}

.tree-row.draggable-row:active {
  cursor: grabbing;
}

.tree-collapse,
.tree-delete {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 0.78rem;
  font-weight: 650;
}

.tree-collapse {
  background: transparent;
  color: var(--muted);
}

.tree-collapse:not(:disabled):hover,
.tree-collapse:focus-visible {
  background: var(--soft);
  color: var(--green-dark);
}

.tree-delete {
  background: transparent;
  color: var(--danger);
  opacity: 0;
  box-shadow: inset 0 0 0 1px rgba(155, 73, 56, 0.08);
}

.tree-item:hover .tree-delete,
.tree-delete:focus-visible {
  opacity: 1;
  background: var(--danger-bg);
  box-shadow: inset 0 0 0 1px rgba(155, 73, 56, 0.18);
}

.tree-indent {
  margin-left: calc(var(--depth) * 12px);
}

.folder-icon {
  width: 18px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 3px;
  position: relative;
  color: var(--green);
}

.folder-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -6px;
  width: 9px;
  height: 6px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: var(--soft);
}

.area-badge {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
}

.tree-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 0.92rem;
}

.tree-count {
  color: var(--muted);
  font-size: 0.8rem;
}

.workspace {
  padding: 28px;
}

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

.title-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.back-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--green-dark);
  font-size: 1.25rem;
  font-weight: 900;
}

.back-button:disabled {
  opacity: 0.35;
}

.topbar h2 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.breadcrumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 5px 0 2px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.breadcrumbs button {
  padding: 0;
  background: transparent;
  color: var(--green-dark);
  font-weight: 800;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  font-size: 0.73rem;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  position: relative;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.9rem;
}

.metric-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.content-grid[data-app-view="life"]:not(.subject-mode) .folder-panel {
  grid-column: 1 / -1;
}

.content-grid[data-focus-panel="tasks"]:not(.subject-mode) .task-panel,
.content-grid[data-focus-panel="notes"]:not(.subject-mode) .notes-panel {
  grid-column: 1;
  opacity: 1;
}

.content-grid[data-focus-panel="tasks"]:not(.subject-mode) .notes-panel,
.content-grid[data-focus-panel="notes"]:not(.subject-mode) .task-panel {
  grid-column: 2;
  opacity: 0.82;
}

.content-grid[data-focus-panel="notes"]:not(.subject-mode) .notes-editor {
  min-height: 360px;
}

.content-grid[data-focus-panel="notes"]:not(.subject-mode) .task-panel .task-tools {
  grid-template-columns: 1fr;
}

.content-grid[data-app-view="calendar"],
.content-grid[data-app-view="brain"],
.content-grid[data-app-view="time"],
.content-grid[data-app-view="habits"],
.content-grid[data-app-view="exams"] {
  grid-template-columns: 1fr;
}

.content-grid[data-app-view="calendar"] .panel,
.content-grid[data-app-view="brain"] .panel,
.content-grid[data-app-view="time"] .panel,
.content-grid[data-app-view="habits"] .panel,
.content-grid[data-app-view="exams"] .panel {
  display: none;
}

.content-grid[data-app-view="life"] .calendar-panel,
.content-grid[data-app-view="life"] .brain-panel,
.content-grid[data-app-view="life"] .time-tracker-panel,
.content-grid[data-app-view="life"] .habits-panel,
.content-grid[data-app-view="life"] .exam-panel {
  display: none;
}

.content-grid[data-app-view="calendar"] .calendar-panel,
.content-grid[data-app-view="brain"] .brain-panel,
.content-grid[data-app-view="time"] .time-tracker-panel,
.content-grid[data-app-view="habits"] .habits-panel,
.content-grid[data-app-view="exams"] .exam-panel {
  display: block;
}

.content-grid[data-app-view="exams"] .exam-panel {
  padding: 24px;
}

.content-grid[data-app-view="exams"] .exam-panel h3 {
  font-size: 2rem;
}

.panel {
  padding: 18px;
}

.priority-panel {
  transition: border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.priority-panel .panel-heading {
  cursor: grab;
}

.priority-panel .panel-heading:active {
  cursor: grabbing;
}

.priority-panel .panel-heading::after {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: 0.28;
  background-image: radial-gradient(circle, currentColor 1.5px, transparent 1.6px);
  background-size: 6px 6px;
}

.priority-panel.panel-dragging {
  opacity: 0.16;
  transform: scale(0.985);
}

.priority-panel.panel-drop-target {
  border-color: var(--green);
  box-shadow: 0 16px 34px rgba(79, 111, 82, 0.18);
  transform: translateY(-2px);
}

.primary-panel h3 {
  font-size: 1.3rem;
}

.notes-panel {
  opacity: 0.82;
}

.notes-panel .panel-heading {
  margin-bottom: 8px;
}

.notes-panel h3 {
  font-size: 1rem;
}

.notes-workspace {
  display: grid;
  gap: 10px;
}

.notes-collapse {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.notes-collapse span {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms ease;
}

.notes-collapse:hover,
.notes-collapse:focus-visible {
  color: var(--green-dark);
  outline: none;
}

.notes-panel.notes-collapsed .notes-collapse span {
  transform: translateY(2px) rotate(225deg);
}

.notes-editor {
  width: 100%;
  min-height: 116px;
  max-height: 68vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: #fffdf7;
  border-radius: 8px;
  color: var(--ink);
  padding: 12px;
  line-height: 1.5;
}

.notes-editor:empty::before {
  content: attr(data-placeholder);
  color: #a49b8e;
}

.notes-editor a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.notes-editor ol,
.notes-editor ul {
  padding-left: 24px;
}

.notes-editor li {
  margin: 4px 0;
}

.notes-panel.notes-collapsed .notes-workspace {
  display: none;
}

.brain-panel {
  background: rgba(255, 253, 247, 0.78);
}

.brain-board {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 14px;
  min-height: 560px;
}

.brain-files,
.brain-editor {
  border: 1px solid rgba(222, 213, 197, 0.78);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.58);
}

.brain-files {
  padding: 10px;
}

.brain-new-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  margin-bottom: 10px;
}

.brain-new-form input {
  min-height: 34px;
  border-radius: 7px;
  background: rgba(255, 253, 247, 0.82);
  font-size: 0.84rem;
}

.brain-new-form button {
  min-height: 34px;
  border-radius: 7px;
  padding: 0;
}

.brain-file-list {
  display: grid;
  gap: 7px;
  max-height: 490px;
  overflow-y: auto;
  padding-right: 3px;
}

.brain-file {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  background: rgba(237, 243, 234, 0.42);
  color: var(--ink);
  text-align: left;
  opacity: 0.82;
}

.brain-file:hover,
.brain-file:focus-visible,
.brain-file.active {
  border-color: rgba(79, 111, 82, 0.28);
  background: rgba(237, 243, 234, 0.72);
  opacity: 1;
}

.brain-file-state {
  width: fit-content;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(91, 111, 156, 0.11);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.brain-file strong,
.brain-file small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brain-file small {
  color: var(--muted);
  font-size: 0.76rem;
}

.brain-editor {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
}

.brain-editor-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 34px;
  gap: 8px;
  margin-bottom: 10px;
}

.brain-editor-top input,
.brain-editor-top select {
  min-height: 36px;
  border-radius: 7px;
  background: rgba(255, 253, 247, 0.78);
}

.brain-editor textarea {
  width: 100%;
  min-height: 460px;
  resize: vertical;
  border: 0;
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 253, 247, 0.62);
  color: var(--ink);
  font: inherit;
  line-height: 1.6;
  outline: none;
}

.brain-editor textarea::placeholder {
  color: rgba(91, 83, 71, 0.52);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  min-height: 88px;
}

.folder-grid.compact-empty {
  min-height: 0;
}

.folder-grid.compact-empty .empty {
  min-height: 44px;
  padding: 10px 12px;
}

.content-grid.folder-focus {
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.75fr);
}

.content-grid.folder-focus .folder-panel {
  grid-column: 1 / -1;
}

.content-grid.folder-focus .folder-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.content-grid.folder-focus .folder-card {
  min-height: 150px;
  padding: 18px;
}

.content-grid.subject-mode {
  grid-template-columns: 1fr;
}

.content-grid.subject-mode .panel {
  display: none;
}

.content-grid.subject-mode[data-view="homework"] .task-panel,
.content-grid.subject-mode[data-view="topics"] .folder-panel,
.content-grid.subject-mode[data-view="notes"] .notes-panel {
  display: block;
}

.content-grid.subject-mode[data-view="homework"] .task-panel .eyebrow {
  display: none;
}

.content-grid.subject-mode[data-view="homework"] .task-panel h3 {
  font-size: 1.45rem;
}

.content-grid.subject-mode .folder-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.subject-tabs {
  display: flex;
  gap: 8px;
  margin: -4px 0 18px;
  border-bottom: 1px solid var(--line);
}

.subject-tab {
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  border-bottom: 3px solid transparent;
}

.subject-tab.active {
  color: var(--green-dark);
  border-bottom-color: var(--green);
}

.folder-card {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  position: relative;
}

.folder-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 650;
  line-height: 1;
  opacity: 0;
}

.folder-card:hover .folder-delete,
.folder-delete:focus-visible {
  opacity: 1;
}

.folder-card:hover {
  border-color: var(--green);
  transform: translateY(-1px);
}

.folder-card[draggable="true"] {
  cursor: grab;
}

.folder-card.dragging {
  opacity: 0;
  cursor: grabbing;
}

.folder-card.drag-over {
  border-color: var(--green);
  opacity: 0.48;
  transform: translateY(12px) scale(0.98);
  box-shadow: inset 0 0 0 2px rgba(79, 111, 82, 0.18);
}

.folder-card strong {
  overflow-wrap: anywhere;
}

.folder-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.folder-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

/* Keep life areas visually small so the next action carries more weight. */
body[data-app-view="life"] .topbar {
  margin-bottom: 12px;
}

body[data-app-view="life"] .topbar h2 {
  font-size: 1.6rem;
  line-height: 1.2;
}

body[data-app-view="life"] .title-row {
  align-items: center;
}

body[data-app-view="life"] .topbar-actions {
  gap: 6px;
}

body[data-app-view="life"] .topbar-actions .ghost-button {
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  font-size: 0.76rem;
  font-weight: 650;
}

body[data-app-view="life"] .topbar-actions .ghost-button:hover,
body[data-app-view="life"] .topbar-actions .ghost-button:focus-visible {
  background: var(--soft);
}

body[data-app-view="life"] .back-button {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--line);
  font-size: 1rem;
}

body[data-app-view="life"] .overview-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

body[data-app-view="life"] .metric {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 0;
  border-radius: 0;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: none;
}

body[data-app-view="life"] .metric strong {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--green-dark);
  font-size: 0.9rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-app-view="life"] .metric-label {
  font-size: 0.69rem;
  letter-spacing: 0;
  text-transform: none;
}

body[data-app-view="life"] .metric-dismiss {
  top: 1px;
  right: 1px;
  width: 18px;
  height: 18px;
  background: transparent;
  opacity: 0;
}

body[data-app-view="life"] .metric:hover .metric-dismiss,
body[data-app-view="life"] .metric-dismiss:focus-visible {
  opacity: 0.72;
}

body[data-app-view="life"] .folder-panel,
body[data-app-view="life"] .content-grid.folder-focus .folder-panel {
  padding: 2px 0 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body[data-app-view="life"] .folder-panel .panel-heading {
  margin: 0 0 8px;
  padding: 0 2px;
}

body[data-app-view="life"] .folder-panel h3 {
  font-size: 1rem;
}

body[data-app-view="life"] .folder-panel .eyebrow {
  font-size: 0.64rem;
  opacity: 0.74;
}

body[data-app-view="life"] .folder-panel .icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.72);
  color: var(--green-dark);
  font-size: 1rem;
  font-weight: 500;
}

body[data-app-view="life"] .folder-panel .ghost-button.compact {
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 253, 247, 0.62);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 780;
}

body[data-app-view="life"] .folder-panel .ghost-button.compact.active {
  background: rgba(237, 243, 234, 0.96);
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px rgba(79, 111, 82, 0.22);
}

.folder-grid[hidden] {
  display: none;
}

body[data-app-view="life"] .folder-grid,
body[data-app-view="life"] .content-grid.folder-focus .folder-grid,
body[data-app-view="life"] .content-grid.subject-mode .folder-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  min-height: 62px;
}

body[data-app-view="life"] .folder-card,
body[data-app-view="life"] .content-grid.folder-focus .folder-card {
  min-height: 62px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 2px 9px;
  align-items: center;
  justify-content: initial;
  padding: 9px 34px 9px 10px;
  border-color: color-mix(in srgb, var(--line) 78%, transparent);
  background: rgba(255, 253, 247, 0.68);
  box-shadow: none;
}

body[data-app-view="life"] .folder-card .area-badge {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  opacity: 0.78;
  font-size: 0.62rem;
}

body[data-app-view="life"] .folder-card strong {
  grid-column: 2;
  grid-row: 1;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 740;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-app-view="life"] .folder-note {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  overflow: hidden;
  font-size: 0.73rem;
  line-height: 1.2;
  opacity: 0.7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-app-view="life"] .folder-meta {
  grid-column: 3;
  grid-row: 1 / 3;
  font-size: 0.68rem;
  white-space: nowrap;
  opacity: 0.66;
}

body[data-app-view="life"] .folder-delete {
  top: 50%;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  transform: translateY(-50%);
  background: transparent;
  font-weight: 450;
}

body[data-app-view="life"] .folder-card:hover {
  border-color: color-mix(in srgb, var(--green) 45%, var(--line));
  background: rgba(255, 253, 247, 0.96);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(61, 50, 34, 0.07);
}

body[data-app-view="life"] .folder-card:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--green) 55%, transparent);
  outline-offset: 2px;
}

body[data-app-view="life"] .folder-card.drag-over {
  opacity: 0.48;
  transform: translateY(6px);
}

.inline-form,
.exam-form {
  display: grid;
  gap: 10px;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.task-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.segmented button {
  min-height: 32px;
  border-radius: 6px;
  padding: 0 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active {
  background: var(--green);
  color: #fff;
}

.exam-form {
  grid-template-columns: minmax(0, 1fr);
}

.creator {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7e8;
  padding: 12px;
}

.creator summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--green-dark);
}

.creator[open] summary {
  margin-bottom: 12px;
}

.date-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf7;
  border-radius: 8px;
  color: var(--ink);
}

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

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 116px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

.inline-form button,
.exam-form button {
  background: var(--blue);
  color: #fff;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 10px;
  max-height: min(720px, 72vh);
  overflow-y: auto;
  padding-right: 4px;
}

.task-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fffdf7;
  position: relative;
  overflow: hidden;
}

.task-item[draggable="true"] {
  cursor: grab;
}

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

.task-item.dragging {
  opacity: 0;
}

.task-item.drag-over {
  opacity: 0.55;
  transform: translateY(10px) scale(0.99);
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px rgba(79, 111, 82, 0.18);
}

.task-item.done {
  grid-template-columns: 52px minmax(0, 1fr) 34px;
  border-color: var(--green);
  background: var(--soft);
  color: var(--green-dark);
}

.task-item.done .task-text {
  text-decoration: line-through;
}

.task-item.next-step {
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  align-items: start;
  border-color: var(--green);
  background: var(--soft);
  padding: 14px;
  box-shadow: 0 12px 28px rgba(79, 111, 82, 0.16);
}

.task-item.next-step .task-text {
  display: grid;
  gap: 5px;
  font-size: 1.08rem;
  font-weight: 850;
}

.task-body {
  display: grid;
  gap: 10px;
  cursor: pointer;
}

.task-item.expanded .task-body {
  cursor: default;
}

.subtask-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.subtask {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 22px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.subtask.done span {
  color: var(--green-dark);
  text-decoration: line-through;
}

.subtask-check,
.subtask-delete {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  line-height: 1;
}

.subtask-check {
  border: 1px solid var(--line);
  background: #fffdf7;
}

.subtask.done .subtask-check {
  background: var(--green);
  border-color: var(--green);
}

.subtask.done .subtask-check::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

.subtask-delete {
  background: transparent;
  color: var(--danger);
  font-weight: 650;
}

.subtask-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.subtask-form input {
  min-height: 34px;
}

.subtask-form button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--green-dark);
  font-weight: 800;
}

.task-badge {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--green);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.check-button,
.delete-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  line-height: 1;
  background: var(--soft);
  color: var(--green-dark);
  font-weight: 650;
  font-size: 0.82rem;
}

.delete-button {
  background: var(--danger-bg);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px rgba(155, 73, 56, 0.12);
}

.task-item.pop {
  animation: task-pop 520ms ease;
}

.task-item.pop::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 20px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(79, 111, 82, 0.22);
  animation: ripple 520ms ease-out;
}

.exam-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.exam-card {
  border: 1px solid var(--line);
  border-left: 7px solid var(--yellow);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  background: #fff8e8;
}

.exam-card strong {
  display: block;
  font-size: 1.35rem;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.exam-card time,
.exam-card span {
  color: var(--muted);
  font-size: 0.87rem;
}

.calendar-panel,
.time-tracker-panel,
.habits-panel {
  grid-column: 1 / -1;
  display: none;
}

.calendar-panel {
  position: relative;
}

.time-tracker-panel {
  overflow: hidden;
}

.time-tracker-heading,
.time-lane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.time-tracker-heading h3 {
  font-size: 2rem;
}

.ideal-week-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: end;
  margin: 18px -18px 0;
  padding: 14px 18px;
  border-block: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.72);
}

.ideal-week-controls > div:first-child {
  display: grid;
  gap: 7px;
}

.ideal-week-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.ideal-week-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(44px, 1fr));
  gap: 5px;
}

.ideal-week-days button {
  min-height: 38px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.ideal-week-days button:hover,
.ideal-week-days button.active {
  background: var(--soft);
  color: var(--green-dark);
}

.sleep-routine-card {
  display: inline-grid;
  grid-template-columns: auto max-content max-content auto auto;
  gap: 7px;
  align-items: center;
  width: auto;
  max-width: 100%;
  margin: 12px 0 0;
  padding: 8px;
  border: 1px solid rgba(102, 112, 111, 0.24);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.86);
}

.sleep-trend-open {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(102, 112, 111, 0.12);
  color: #4e5958;
  font-size: 0.78rem;
  font-weight: 850;
}

.sleep-routine-card label {
  display: grid;
  grid-template-columns: auto 118px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.sleep-routine-card input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: #fffdf7;
  color: var(--ink);
  font-size: 0.78rem;
}

.sleep-routine-card .primary-button.compact,
.sleep-routine-card .ghost-button.compact {
  min-width: 74px;
  min-height: 34px;
  border-radius: 11px;
  padding: 0 12px;
}

.time-block-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px 142px 142px auto auto;
  gap: 8px;
  align-items: end;
  padding: 14px 0 18px;
}

.time-block-form input,
.time-block-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fffdf7;
  color: var(--ink);
}

.time-block-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.time-block-repeat {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-block-repeat > span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.time-block-repeat-days {
  display: flex;
  gap: 5px;
}

.time-block-repeat-days button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.time-block-repeat-days button:hover,
.time-block-repeat-days button.active {
  background: var(--green);
  color: #fff;
}

.time-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.time-lane-section {
  min-width: 0;
}

.time-lane-heading {
  min-height: 46px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fffdf7;
}

.time-lane-heading > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-lane-heading > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.time-lane-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.sleep-summary {
  display: flex;
  align-items: center;
  border-radius: 7px;
  background: rgba(102, 112, 111, 0.12);
}

.sleep-summary:empty {
  display: none;
}

.sleep-summary button {
  min-height: 30px;
  background: transparent;
  color: #4e5958;
  font-size: 0.75rem;
  font-weight: 800;
}

.sleep-summary-edit {
  padding: 0 8px;
}

.sleep-summary-delete {
  width: 28px;
  padding: 0;
  opacity: 0.7;
}

.sleep-summary-delete:hover {
  color: var(--danger);
}

.time-lane-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.time-lane-dot.actual {
  background: var(--blue);
}

.time-lane-dot.ideal {
  background: var(--green);
}

.time-lane {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: rgba(255, 253, 247, 0.72);
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}

.time-hour-marker {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  border-top: 1px solid rgba(222, 213, 197, 0.72);
  pointer-events: none;
}

.time-hour-marker span {
  position: absolute;
  top: 4px;
  left: 8px;
  width: 45px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 750;
}

.time-block,
.calendar-time-reference {
  position: absolute;
  left: 58px;
  right: 8px;
  z-index: 2;
  min-height: 22px;
  border: 1px solid color-mix(in srgb, var(--block-color, var(--blue)) 62%, white);
  border-left: 5px solid var(--block-color, var(--blue));
  border-radius: 6px;
  padding: 2px 28px 4px 9px;
  background: color-mix(in srgb, var(--block-color, var(--blue)) 15%, #fffdf7);
  color: var(--ink);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.time-block:hover {
  box-shadow: 0 7px 18px rgba(61, 50, 34, 0.14);
}

.time-block.moving {
  z-index: 6;
  opacity: 0.72;
  cursor: grabbing;
  box-shadow: 0 12px 28px rgba(61, 50, 34, 0.2);
}

.time-block.overnight {
  cursor: pointer;
}

.time-block.overnight .time-resize-handle {
  display: none;
}

.time-block.instant {
  left: 58px;
  right: auto;
  width: min(210px, calc(100% - 74px));
  min-height: 24px;
  border-left-width: 8px;
  border-radius: 999px;
  padding: 2px 24px 2px 9px;
  cursor: grab;
}

.time-block.beside-instant {
  right: calc(50% + 4px);
}

.time-block.instant.instant-shifted {
  left: calc(50% + 4px);
  right: 8px;
  width: auto;
  z-index: 3;
}

.time-block.instant .time-resize-handle {
  display: none;
}

.time-block.instant .time-block-line {
  gap: 6px;
}

.time-block.instant .time-block-line strong {
  flex: 0 1 auto;
  max-width: 104px;
  font-size: 0.78rem;
}

.time-block.instant .time-block-category {
  display: none;
}

.time-block.instant .time-block-delete {
  top: 3px;
  right: 5px;
  width: 16px;
  height: 16px;
}

.time-block-line {
  height: 100%;
  min-height: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.time-block-line strong,
.time-block-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-block-line strong {
  flex: 1 1 auto;
  font-size: 0.86rem;
}

.time-block-time,
.time-block-category {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 750;
}

.time-block-category {
  max-width: 28%;
}

.time-block-delete {
  position: absolute;
  top: 1px;
  right: 4px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.time-block-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.time-resize-handle {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 0;
  height: 7px;
  border-bottom: 2px solid color-mix(in srgb, var(--block-color) 55%, transparent);
  cursor: ns-resize;
}

.calendar-time-reference {
  left: 62px;
  right: 12px;
  z-index: 1;
  border-color: rgba(117, 111, 100, 0.25);
  border-left-color: rgba(117, 111, 100, 0.45);
  background: repeating-linear-gradient(135deg, rgba(117, 111, 100, 0.07) 0 6px, rgba(255, 253, 247, 0.72) 6px 12px);
  color: var(--muted);
  cursor: default;
}

.calendar-time-reference span,
.calendar-time-reference strong {
  display: block;
  font-size: 0.7rem;
}

.today-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 88px 38px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.calendar-month-strip {
  min-height: 38px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 3px;
  align-items: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.68);
}

.calendar-month-strip button {
  min-height: 30px;
  border-radius: 7px;
  padding: 0 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.calendar-month-strip button.active {
  background: var(--ink);
  color: #fff;
}

.icon-button.quiet {
  background: var(--soft);
  color: var(--green-dark);
  font-size: 1rem;
}

.calendar-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.calendar-title {
  grid-column: 1 / -1;
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.calendar-day-name {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.calendar-cell {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 8px;
  position: relative;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.event-range-edge {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 18px;
  border: 0;
  background: var(--range-strong, var(--blue));
  opacity: 0.9;
  z-index: 3;
  cursor: pointer;
}

.event-range-edge.edge-start {
  left: -1px;
  border-radius: 8px 0 0 8px;
}

.event-range-edge.edge-end {
  right: -1px;
  border-radius: 0 8px 8px 0;
}

.event-range-edge:hover,
.event-range-edge:focus-visible {
  width: 22px;
  opacity: 1;
  outline: none;
}

.calendar-cell:hover,
.calendar-cell:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 10px 22px rgba(91, 111, 156, 0.14);
  outline: none;
}

.calendar-cell.muted {
  opacity: 0.45;
}

.calendar-cell.today {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

.calendar-cell.range-day {
  --range-soft: rgba(138, 111, 159, 0.18);
  --range-strong: rgba(138, 111, 159, 0.72);
  --range-border: rgba(138, 111, 159, 0.35);
  background: linear-gradient(90deg, rgba(255, 253, 247, 0.55), var(--range-soft));
  border-color: var(--range-border);
}

.calendar-cell.range-color-0 {
  --range-soft: rgba(138, 111, 159, 0.2);
  --range-strong: rgba(138, 111, 159, 0.75);
  --range-border: rgba(138, 111, 159, 0.38);
}

.calendar-cell.range-color-1 {
  --range-soft: rgba(91, 111, 156, 0.2);
  --range-strong: rgba(91, 111, 156, 0.78);
  --range-border: rgba(91, 111, 156, 0.38);
}

.calendar-cell.range-color-2 {
  --range-soft: rgba(79, 111, 82, 0.2);
  --range-strong: rgba(79, 111, 82, 0.78);
  --range-border: rgba(79, 111, 82, 0.38);
}

.calendar-cell.range-color-3 {
  --range-soft: rgba(217, 164, 65, 0.24);
  --range-strong: rgba(159, 98, 53, 0.78);
  --range-border: rgba(159, 98, 53, 0.38);
}

.calendar-cell.range-color-4 {
  --range-soft: rgba(189, 101, 79, 0.2);
  --range-strong: rgba(155, 73, 56, 0.76);
  --range-border: rgba(155, 73, 56, 0.38);
}

.calendar-cell.range-color-5 {
  --range-soft: rgba(54, 93, 126, 0.2);
  --range-strong: rgba(54, 93, 126, 0.78);
  --range-border: rgba(54, 93, 126, 0.38);
}

.calendar-cell.range-start {
  box-shadow: none;
}

.calendar-cell.range-end {
  box-shadow: none;
}

.calendar-cell.range-start.range-end {
  box-shadow: none;
}

.calendar-cell.selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px var(--blue), 0 12px 26px rgba(91, 111, 156, 0.16);
}

.calendar-date {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.calendar-chip {
  display: block;
  width: 100%;
  margin-top: 4px;
  border-radius: 6px;
  padding: 4px 6px 4px 14px;
  background: var(--soft);
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-chip.exam {
  background: #faebbd;
  color: #6f4d0f;
}

.calendar-chip.event {
  background: #eee8f1;
  color: #553d62;
  cursor: pointer;
}

.event-color-0 {
  --range-soft: rgba(138, 111, 159, 0.2);
  --range-strong: rgba(138, 111, 159, 0.75);
  --range-border: rgba(138, 111, 159, 0.38);
}

.event-color-1 {
  --range-soft: rgba(91, 111, 156, 0.2);
  --range-strong: rgba(91, 111, 156, 0.78);
  --range-border: rgba(91, 111, 156, 0.38);
}

.event-color-2 {
  --range-soft: rgba(79, 111, 82, 0.2);
  --range-strong: rgba(79, 111, 82, 0.78);
  --range-border: rgba(79, 111, 82, 0.38);
}

.event-color-3 {
  --range-soft: rgba(217, 164, 65, 0.24);
  --range-strong: rgba(159, 98, 53, 0.78);
  --range-border: rgba(159, 98, 53, 0.38);
}

.event-color-4 {
  --range-soft: rgba(189, 101, 79, 0.2);
  --range-strong: rgba(155, 73, 56, 0.76);
  --range-border: rgba(155, 73, 56, 0.38);
}

.event-color-5 {
  --range-soft: rgba(54, 93, 126, 0.2);
  --range-strong: rgba(54, 93, 126, 0.78);
  --range-border: rgba(54, 93, 126, 0.38);
}

.calendar-chip.event[class*="event-color-"] {
  background: var(--range-soft);
  color: var(--ink);
}

.calendar-chip.habit {
  background: var(--soft);
  color: var(--green-dark);
}

.calendar-chip.habit-missed {
  background: var(--danger-bg);
  color: var(--danger);
}

.today-grid h4 {
  margin: 0 0 10px;
}

.day-planner {
  position: fixed;
  right: clamp(18px, 5vw, 72px);
  top: clamp(86px, 12vh, 150px);
  z-index: 20;
  width: min(560px, calc(100vw - 36px));
  max-height: min(760px, calc(100vh - 120px));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fffdf7;
  box-shadow: 0 24px 70px rgba(61, 50, 34, 0.22);
}

.day-planner-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.day-planner-heading h4 {
  margin: 0;
}

.event-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1;
}

.event-close:hover,
.event-close:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(155, 73, 56, 0.2);
  outline: none;
}

.event-composer {
  display: grid;
  gap: 10px;
}

.event-style-picker {
  display: grid;
  gap: 7px;
}

.event-category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.event-category-row button {
  min-height: 28px;
  border: 1px solid rgba(222, 213, 197, 0.82);
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(255, 253, 247, 0.72);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.event-category-row button.active {
  border-color: rgba(79, 111, 82, 0.28);
  background: rgba(237, 243, 234, 0.92);
  color: var(--green-dark);
}

.event-color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.event-color-palette button {
  width: 20px;
  height: 20px;
  min-height: 20px;
  border: 2px solid rgba(255, 253, 247, 0.95);
  border-radius: 999px;
  padding: 0;
  background: var(--range-strong);
  box-shadow: 0 0 0 1px rgba(32, 35, 31, 0.14);
}

.event-color-palette button.active {
  box-shadow: 0 0 0 2px rgba(54, 93, 126, 0.35);
  transform: scale(1.08);
}

.event-composer label,
.customize-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.event-composer > button {
  min-height: 42px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.segmented.compact {
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}

.event-dates {
  grid-template-columns: 1fr 1fr;
}

.event-time-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.time-wheel {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  min-height: 104px;
  padding: 6px;
  border: 1px solid rgba(222, 213, 197, 0.72);
  border-radius: 8px;
  background: rgba(237, 243, 234, 0.46);
}

.time-wheel-column {
  height: 92px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
  padding: 30px 2px;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.time-wheel-column::-webkit-scrollbar {
  display: none;
}

.time-wheel-column button {
  min-height: 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 760;
}

.time-wheel-column button.active {
  background: rgba(91, 111, 156, 0.12);
  color: var(--green-dark);
  box-shadow: none;
}

.study-list,
.habit-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.habit-new-form {
  grid-template-columns: auto minmax(180px, 340px) auto;
  width: fit-content;
  max-width: 100%;
  margin-top: 14px;
  padding: 8px;
  border: 1px dashed rgba(222, 213, 197, 0.9);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.52);
}

.habit-new-label {
  align-self: center;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  white-space: nowrap;
}

.habit-new-form input {
  min-height: 34px;
  border-radius: 7px;
  background: rgba(255, 253, 247, 0.82);
  font-size: 0.84rem;
}

.habit-new-form button {
  min-height: 34px;
  border-radius: 7px;
  padding-inline: 12px;
}

.study-card,
.habit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf7;
}

.study-card {
  cursor: pointer;
}

.study-card[class*="event-color-"] {
  border-left: 5px solid var(--range-strong);
  background: linear-gradient(90deg, var(--range-soft), #fffdf7 42%);
}

.habit-card.done {
  border-color: var(--green);
  background: var(--soft);
}

.habit-card.done strong {
  color: var(--green-dark);
}

.habit-card[draggable="true"] {
  cursor: grab;
}

.habit-card.dragging {
  opacity: 0;
}

.habit-card.drag-over {
  border-color: var(--green);
  background: var(--soft);
  transform: translateY(2px);
  opacity: 0.72;
}

.study-card strong,
.habit-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.study-card span,
.habit-card span {
  color: var(--muted);
  font-size: 0.87rem;
}

.study-card button,
.habit-card button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--soft-blue);
  color: var(--green-dark);
  font-weight: 900;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.study-timer {
  margin-top: 12px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft-blue);
  color: var(--green-dark);
  font-weight: 900;
}

.customize-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.color-preview {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  color: var(--muted);
  font-size: 0.82rem;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(32, 35, 31, 0.18);
  background: var(--green);
}

.content-grid[data-app-view="calendar"] .calendar-panel,
.content-grid[data-app-view="habits"] .habits-panel {
  display: block;
}

.empty {
  min-height: 82px;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: 0.72;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 27, 0.28);
  z-index: 30;
}

.modal {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.draggable-modal {
  position: relative;
}

.modal-handle {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  cursor: move;
  user-select: none;
}

.modal-handle span {
  color: var(--muted);
  font-weight: 900;
  letter-spacing: 0.12em;
}

.modal h3 {
  margin: 4px 0 16px;
  font-size: 1.35rem;
}

.modal-copy {
  margin: -6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.sleep-trend-modal {
  width: min(620px, 100%);
}

.sleep-trend-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sleep-trend-range {
  margin: 2px 0 12px;
}

.sleep-trend-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.sleep-trend-stats span {
  display: grid;
  gap: 2px;
  min-height: 52px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.8);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.sleep-trend-stats strong {
  color: var(--ink);
  font-size: 0.98rem;
}

.sleep-trend-chart {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.sleep-trend-row {
  display: grid;
  grid-template-columns: 64px minmax(90px, 1fr) 64px 126px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.sleep-trend-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(102, 112, 111, 0.14);
  overflow: hidden;
}

.sleep-trend-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #66706f, #365d7e);
}

.sleep-trend-row strong {
  color: var(--ink);
}

.sleep-trend-row small {
  color: var(--muted);
  font-size: 0.74rem;
  text-align: right;
}

.sleep-empty {
  min-height: 110px;
}

.danger-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--danger);
  color: #fff;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 18px);
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  box-shadow: var(--shadow);
  z-index: 20;
}

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

.celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  animation: confetti-fall 920ms ease-out forwards;
}

@keyframes task-pop {
  0% { transform: scale(1); }
  48% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

@keyframes ripple {
  from {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -50%) scale(18);
    opacity: 0;
  }
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(86vh) rotate(640deg);
    opacity: 0;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .content-grid,
  .overview-grid,
  .today-grid,
  .calendar-month,
  .brain-board {
    grid-template-columns: 1fr;
  }

  .content-grid[data-focus-panel] .folder-panel,
  .content-grid[data-focus-panel] .task-panel,
  .content-grid[data-focus-panel] .notes-panel {
    grid-column: auto;
  }

  .calendar-day-name {
    display: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .time-block-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sleep-routine-card {
    grid-template-columns: repeat(3, max-content);
    border-radius: 18px;
  }

  .time-block-form > input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1180px) and (min-width: 941px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr) minmax(170px, 0.42fr);
  }

  .notes-panel {
    padding: 14px;
  }

  .content-grid[data-focus-panel="notes"]:not(.subject-mode) .notes-editor {
    min-height: 300px;
  }
}

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

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  body[data-app-view="life"] .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-app-view="life"] .folder-grid,
  body[data-app-view="life"] .content-grid.folder-focus .folder-grid,
  body[data-app-view="life"] .content-grid.subject-mode .folder-grid {
    grid-template-columns: 1fr;
  }

  .inline-form,
  .exam-form,
  .sleep-routine-card,
  .time-block-form,
  .time-board {
    grid-template-columns: 1fr;
  }

  .ideal-week-controls {
    grid-template-columns: 1fr;
  }

  .time-lane-heading,
  .time-lane-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .ideal-week-days {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .time-block-form > input {
    grid-column: auto;
  }

  .sleep-routine-card {
    display: grid;
    grid-template-columns: 1fr;
    border-radius: 8px;
  }

  .habit-new-form {
    width: 100%;
  }

  .sleep-routine-card label {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .sleep-trend-stats,
  .sleep-trend-row {
    grid-template-columns: 1fr;
  }

  .sleep-trend-row small {
    text-align: left;
  }

  .calendar-toolbar,
  .event-dates,
  .day-planner .date-row {
    grid-template-columns: 1fr;
  }

  .day-planner {
    inset: 76px 14px auto;
    width: auto;
    max-height: calc(100vh - 94px);
  }
}
