:root {
  color-scheme: dark;
  --space-s: clamp(10px, 2vw, 20px);
  --space-m: clamp(20px, 3vw, 50px);
  --space-l: clamp(36px, 5vw, 90px);
  --ink: #d1d8db;
  --muted: #858e93;
  --line: #4b5155;
  --panel: #111416;
  --panel-soft: #161a1d;
  --page: #0c0e0f;
  --accent: #5a20cb;
  --accent-next: #00a6ed;
  --warn: #ff6b4a;
  --focus: #00c853;
  --transition: 0.28s ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Montserrat, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  padding-top: 66px;
}

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

button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

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

.primary,
.ghost {
  width: fit-content;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.primary::after,
.ghost::after {
  content: "›";
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-size: 22px;
  line-height: 1;
  transition: background var(--transition), transform var(--transition);
}

.primary:hover,
.ghost:hover {
  color: var(--accent-next);
}

.primary:hover::after,
.ghost:hover::after {
  background: var(--accent-next);
  transform: translateX(2px);
}

.ghost {
  color: var(--ink);
}

.ghost#deleteButton,
.icon-button {
  color: var(--warn);
}

.ghost#deleteButton::after,
.icon-button::after {
  background: var(--warn);
}

.sidebar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 66px;
  padding: 12px var(--space-l);
  display: grid;
  grid-template-columns: minmax(190px, auto) minmax(280px, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 14, 15, 0.96);
  backdrop-filter: blur(14px);
}

.sidebar > div:first-child {
  min-width: 190px;
}

.eyebrow {
  display: none;
}

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

h1 {
  position: relative;
  margin-bottom: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  color: #fff;
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 400;
  line-height: 1;
}

h3 {
  margin-bottom: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

nav + form {
  margin: 0;
}

.nav-button {
  min-height: 30px;
  width: fit-content;
  position: relative;
  justify-content: flex-start;
  text-align: left;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.nav-button::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width var(--transition), background var(--transition);
}

.nav-button:hover,
.nav-button.active {
  color: #fff;
}

.nav-button:hover::after,
.nav-button.active::after {
  width: 100%;
}

.totals {
  min-width: 360px;
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.totals div {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.totals div:last-child {
  border-right: 0;
}

.totals span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.totals strong {
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}

.workspace {
  height: calc(100vh - 66px);
  min-width: 0;
  overflow: hidden;
  padding: 32px var(--space-l) 74px;
  display: flex;
  flex-direction: column;
}

.toolbar {
  margin-bottom: 24px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.toolbar > div {
  position: relative;
  max-width: 720px;
}

.content-grid {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: var(--space-m);
  align-items: stretch;
}

.list-panel,
.editor-panel,
.preview {
  border: 1px solid var(--line);
  background: var(--panel);
}

.list-panel,
.editor-panel {
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  position: relative;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header.tight {
  padding: 0 0 14px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

#searchInput {
  width: min(180px, 48%);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 11px 14px;
  color: #fff;
  background: transparent;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

select {
  color-scheme: dark;
}

select option {
  color: #fff;
  background: var(--panel);
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 32, 203, 0.28);
  outline: none;
}

.item-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
}

.item {
  position: relative;
  display: block;
  width: 100%;
  min-height: 76px;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: transparent;
}

.item::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  opacity: 0;
  transform: translate(-8px, -50%);
  transition: opacity var(--transition), transform var(--transition), background var(--transition);
}

.item:hover,
.item.active {
  background: var(--panel-soft);
}

.item:hover::after,
.item.active::after {
  content: "›";
  opacity: 1;
  transform: translate(0, -50%);
}

.item.active {
  box-shadow: inset 4px 0 0 var(--accent);
}

.item strong,
.item span {
  display: block;
}

.item strong {
  max-width: calc(100% - 34px);
  color: #fff;
}

.item span {
  max-width: calc(100% - 34px);
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
}

.editor-panel {
  padding-bottom: 18px;
}

#formFields {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 20px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.wide {
  grid-column: 1 / -1;
}

.preview,
.milestones-section {
  position: relative;
  padding: 18px;
  background: var(--panel-soft);
}

#markdownPreview {
  min-height: 120px;
  color: var(--ink);
  line-height: 1.6;
}

#markdownPreview h1,
#markdownPreview h2,
#markdownPreview h3 {
  color: #fff;
  font-size: 22px;
}

#markdownPreview :last-child {
  margin-bottom: 0;
}

.milestone {
  display: grid;
  grid-template-columns: 1.3fr 180px 140px 120px 44px;
  gap: 12px;
  align-items: end;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.milestone:first-child {
  border-top: 0;
}

.goal-mode .milestone {
  grid-template-columns: 1.3fr 180px 120px 44px;
}

.check-label {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

.check-label input {
  width: auto;
  accent-color: var(--accent);
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 0;
}

.icon-button::after {
  content: "×";
  width: 34px;
  height: 34px;
  color: #fff;
  font-size: 20px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 75% 16%, rgba(90, 32, 203, 0.2), transparent 28%),
    var(--page);
}

.login-shell {
  width: min(100%, 460px);
}

.login-panel {
  position: relative;
  display: grid;
  gap: 20px;
  padding: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.login-panel h1 {
  font-size: 38px;
}

.login-panel .primary {
  margin-top: 8px;
}

.login-error {
  margin: 0;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line));
  color: #fff;
  background: rgba(255, 107, 74, 0.12);
}

.message-bar {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 46px;
  padding: 13px var(--space-l);
  border-top: 1px solid var(--line);
  color: #fff;
  background: rgba(17, 20, 22, 0.98);
  cursor: pointer;
  box-shadow: 0 -14px 30px rgba(0, 0, 0, 0.26);
}

.message-bar::before {
  content: "";
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 10px;
  background: var(--focus);
}

.message-bar[data-type="error"]::before {
  background: var(--warn);
}

.message-bar[hidden] {
  display: none;
}

@media (max-width: 1180px) {
  html,
  body {
    height: auto;
  }

  body {
    overflow: auto;
    padding-top: 0;
  }

  .sidebar {
    position: static;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .sidebar > div:first-child {
    min-width: 0;
  }

  nav,
  nav + form {
    justify-content: flex-start;
  }

  .totals {
    min-width: 0;
  }
}

@media (max-width: 920px) {
  .workspace {
    height: auto;
    overflow: visible;
  }

  .workspace,
  .sidebar {
    padding: 18px;
  }

  .message-bar {
    padding-inline: 18px;
  }

  nav {
    flex-wrap: wrap;
  }

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

  .list-panel,
  .editor-panel {
    min-height: auto;
    max-height: none;
    overflow: visible;
  }

  .item-list,
  #formFields {
    overflow: visible;
  }
}

@media (max-width: 680px) {
  .toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  #searchInput {
    width: 100%;
  }

  #formFields {
    grid-template-columns: 1fr;
  }

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

  .milestone,
  .goal-mode .milestone {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-wrap: wrap;
  }
}
