:root {
  color-scheme: dark;
  --bg: #1e1e24;
  --sidebar: #24242c;
  --sidebar-2: #2b2b34;
  --panel: #26262f;
  --panel-soft: #30303a;
  --ink: #ececf1;
  --muted: #a8a8b3;
  --line: #3b3b46;
  --brand: #8b7cf6;
  --brand-2: #6f62d9;
  --accent: #d0a85c;
  --danger: #d56b6b;
  --normal: #5ba97a;
  --important: #6f8edb;
  --priority: #e07aa8;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.booting .auth-view,
.booting .app-shell {
  visibility: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

button {
  cursor: pointer;
}

.auth-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(139, 124, 246, 0.14), transparent 32%),
    radial-gradient(circle at 70% 15%, rgba(208, 168, 92, 0.1), transparent 30%),
    var(--bg);
}

.auth-form {
  display: grid;
  gap: 22px;
  width: min(560px, 100%);
  min-width: 0;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(38, 38, 47, 0.92);
  box-shadow: var(--shadow);
}

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

.mobile-menu-button {
  display: none;
}

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

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

.brand > div:last-child {
  min-width: 0;
}

.auth-brand {
  padding-bottom: 4px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(139, 124, 246, 0.34), rgba(208, 168, 92, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.logo-brain {
  fill: rgba(139, 124, 246, 0.95);
}

.logo-brain-line,
.logo-base,
.logo-rays {
  fill: none;
  stroke: #ececf1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.logo-bulb {
  fill: rgba(208, 168, 92, 0.95);
}

.brand strong,
.brand span,
.account-panel strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span,
.muted,
.eyebrow,
.account-panel p,
.note-meta {
  color: var(--muted);
}

.brand span,
.note-meta,
.account-panel p {
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

h3 {
  margin-bottom: 0;
  font-size: 15px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

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

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

textarea {
  resize: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(139, 124, 246, 0.28);
  outline-offset: 2px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.primary-link {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 13px;
  border: 1px solid transparent;
  color: var(--ink);
  font-weight: 750;
}

.primary-button,
.primary-link {
  display: inline-grid;
  place-items: center;
  background: var(--brand);
  text-decoration: none;
}

.primary-button:hover,
.primary-link:hover {
  background: var(--brand-2);
}

.ghost-button {
  background: var(--panel-soft);
  border-color: var(--line);
}

.icon-tool {
  display: grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.danger-button {
  background: rgba(213, 107, 107, 0.12);
  border-color: rgba(213, 107, 107, 0.42);
  color: #ffd6d6;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--panel-soft);
  border-color: var(--line);
  font-size: 24px;
  line-height: 1;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
}

.note-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.folder-group {
  display: grid;
  gap: 5px;
}

.folder-group.drag-over {
  outline: 2px solid rgba(139, 124, 246, 0.45);
  outline-offset: 2px;
  border-radius: 8px;
}

.folder-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.folder-toggle:hover {
  background: var(--sidebar-2);
  color: var(--ink);
}

.folder-toggle strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-notes {
  display: grid;
  gap: 5px;
}

.folder-group.collapsed .folder-notes {
  display: none;
}

.note-item {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.note-item.dragging {
  opacity: 0.55;
}

.note-item:hover,
.note-item.active {
  background: var(--sidebar-2);
  border-color: var(--line);
}

.note-item strong,
.note-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item span {
  color: var(--muted);
  font-size: 12px;
}

.account-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.account-panel p {
  margin: 0;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.title-group {
  min-width: 0;
}

.note-title-input {
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 34px;
  font-weight: 850;
  line-height: 1.1;
}

.note-title-input:focus {
  outline: none;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 20px;
  margin-top: 2px;
}

.folder-select-label {
  display: grid;
  grid-template-columns: auto 150px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.folder-select-label span {
  color: var(--accent);
}

.folder-select-label select {
  min-height: 30px;
}

.note-meta strong {
  color: var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.editor-panel {
  min-height: 0;
  padding-top: 18px;
}

.text-editor {
  min-height: calc(70vh - 132px);
  padding: 20px;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.65;
}

.fold-preview {
  display: grid;
  gap: 10px;
  max-width: 900px;
}

.note-text-block,
.fold-textarea {
  min-height: 76px;
  padding: 14px;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
}

.note-text-block:focus,
.fold-textarea:focus {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.fold-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.fold-block summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 800;
}

.fold-arrow {
  width: 18px;
  color: var(--accent);
}

.fold-textarea {
  min-height: 140px;
  padding: 0 14px 14px;
  border: 0;
  border-radius: 0;
  width: 100%;
}

.text-editor:focus {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.list-editor {
  display: grid;
  gap: 8px;
  max-width: 900px;
}

.list-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
}

.list-check {
  width: 20px;
  min-height: 20px;
  accent-color: var(--brand);
}

.list-text {
  min-height: 44px;
  border-color: transparent;
  background: transparent;
}

.list-text:focus {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.list-row:has(.list-check:checked) .list-text {
  color: var(--muted);
  text-decoration: line-through;
}

.planner-editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 12px;
  align-items: start;
  min-height: calc(100vh - 150px);
  overflow-x: auto;
}

.planner-column {
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto;
  gap: 10px;
  min-height: calc(100vh - 160px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.planner-column.drag-over {
  border-color: var(--brand);
  background: rgba(139, 124, 246, 0.1);
}

.planner-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.planner-column header span {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.planner-cards {
  display: grid;
  align-content: start;
  gap: 8px;
}

.planner-card {
  display: grid;
  gap: 8px;
  padding: 0;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  cursor: grab;
}

.planner-card.dragging {
  opacity: 0.55;
}

.planner-card.priority-normal {
  border-left-color: var(--normal);
}

.planner-card.priority-important {
  border-left-color: var(--important);
}

.planner-card.priority-priority {
  border-left-color: var(--priority);
}

.planner-card-summary {
  display: grid;
  width: 100%;
  min-height: 52px;
  padding: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: grab;
  text-align: left;
}

.planner-card-title {
  overflow-wrap: anywhere;
}

.planner-card-details {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.priority-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.priority-pill {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.priority-pill.active {
  border-color: transparent;
}

.priority-pill.priority-normal.active {
  background: rgba(91, 169, 122, 0.35);
}

.priority-pill.priority-important.active {
  background: rgba(111, 142, 219, 0.38);
}

.priority-pill.priority-priority.active {
  background: rgba(224, 122, 168, 0.4);
}

.planner-card-text {
  min-height: 38px;
}

.planner-card-details .ghost-button,
.planner-card-details .danger-button {
  min-height: 34px;
}

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

.empty-state {
  align-self: center;
  justify-self: center;
  width: min(520px, 100%);
  padding: 34px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  text-align: center;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(11, 11, 14, 0.72);
  backdrop-filter: blur(8px);
}

.dialog {
  display: grid;
  gap: 18px;
  width: min(720px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.type-card {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sidebar-2);
  color: var(--ink);
  text-align: left;
}

.type-card:hover {
  border-color: var(--brand);
  background: rgba(139, 124, 246, 0.12);
}

.type-card strong {
  font-size: 18px;
}

.type-card span {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 1080px) {
  .planner-editor {
    grid-template-columns: repeat(4, minmax(240px, 1fr));
  }
}

@media (max-width: 940px) {
  body {
    width: 100%;
  }

  .auth-view {
    width: 100%;
    min-height: 100dvh;
    place-items: stretch;
    padding: 12px;
  }

  .auth-form {
    align-self: center;
    width: 100%;
    max-width: 100%;
    padding: 18px;
  }

  .auth-brand {
    align-items: flex-start;
  }

  .auth-brand .brand-mark {
    width: 44px;
    height: 44px;
  }

  .auth-brand .brand-mark svg {
    width: 34px;
    height: 34px;
  }

  .auth-brand span {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.35;
  }

  .auth-brand strong {
    white-space: normal;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(86vw, 340px);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .app-shell.menu-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.menu-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.45);
  }

  .app-shell.menu-open .mobile-menu-button {
    z-index: 30;
  }

  .mobile-menu-button {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 9;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    font-size: 22px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-left: 52px;
  }

  .text-editor {
    min-height: 62vh;
    padding: 12px 0;
    font-size: 16px;
  }

  .planner-editor {
    min-height: 54vh;
  }

  .workspace {
    width: 100vw;
    padding: 14px;
  }

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

  h1,
  .note-title-input {
    font-size: 26px;
  }

  .note-title-input {
    min-height: 38px;
  }

  .note-meta {
    gap: 6px;
  }

  .folder-select-label {
    grid-template-columns: auto minmax(86px, 120px);
    width: auto;
  }

  .folder-select-label select {
    min-height: 34px;
    padding: 0 8px;
  }

  .toolbar {
    align-self: start;
    justify-content: flex-end;
    gap: 6px;
  }

  .icon-tool {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
  }
}
