/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  color-scheme: dark;

  /* shell layers */
  --shell:   #090c09;
  --rail:    #060806;
  --panel:   #131610;
  --panel-2: #0d0f0b;
  --panel-3: #1b1f18;

  /* borders */
  --line:       rgba(255, 255, 255, 0.07);
  --line-hover: rgba(168, 255, 69, 0.20);

  /* text */
  --text:  #f0f2e8;
  --soft:  #d0d2c8;
  --muted: #7a7c74;

  /* accents */
  --lime:       #a8ff45;
  --lime-2:     #d4ff90;
  --lime-dim: rgba(168, 255, 69, 0.10);
  --orange:   #ff9f24;

  /* radii */
  --r-panel: 14px;
  --r-card:   10px;
  --r-pill:   999px;

  /* type */
  --font:    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Arial Narrow", "Roboto Condensed", Impact, Haettenschweiler, sans-serif;

}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--shell);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; background: transparent; color: inherit; }
h1, h2, h3, h4 { margin: 0; }

svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

/* ─── App shell ──────────────────────────────────────────── */
.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  background: var(--shell);
  overflow: hidden;
}

/* ─── Icon rail ──────────────────────────────────────────── */
.icon-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 11px;
  background: var(--rail);
  border-right: 1px solid var(--line);
}

.rail-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  transition: color 140ms, background 140ms, transform 140ms;
  position: relative;
}

.rail-button:hover {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.rail-button.active {
  color: var(--lime);
  background: var(--lime-dim);
}

.rail-button.active::before {
  content: "";
  position: absolute;
  left: -11px;
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--lime);
}

/* ─── Workspace ──────────────────────────────────────────── */
.workspace {
  min-width: 0;
  height: 100%;
  padding: 22px 26px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0;
}

/* ─── Top bar ────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-shrink: 0;
}

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

/* pill nav button */
.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.04);
  transition: color 140ms, background 140ms;
}

.nav-pill svg { opacity: 0.7; }

.nav-pill:hover {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.07);
}

.nav-pill.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.10);
}

.nav-pill.active svg { opacity: 1; }

/* round icon button (nav, icon-button, control-button) */
.nav-icon,
.icon-button,
.control-button,
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-icon,
.icon-button,
.control-button {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  transition: color 140ms, background 140ms;
}

.nav-icon:hover,
.icon-button:hover,
.control-button:hover {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.09);
}

/* profile area */
.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.profile > div {
  text-align: right;
}

.profile strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--soft);
}

.profile span {
  display: block;
  font-size: 0.70rem;
  color: var(--muted);
  margin-top: 2px;
}

.avatar {
  background: linear-gradient(140deg, #e8e4d0, #8a8b80);
  color: #111310;
  font-weight: 800;
  font-size: 0.85rem;
  position: relative;
}

/* ─── Hero row ───────────────────────────────────────────── */
.hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

h2 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

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

/* custom dropdowns */
.custom-select {
  position: relative;
}

.select-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  min-width: 118px;
  padding: 0 10px 0 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  transition: background 140ms, border-color 140ms, transform 140ms;
}

.select-trigger:hover,
.custom-select.open .select-trigger {
  background: rgba(255, 255, 255, 0.09);
}

.select-trigger:active {
  transform: translateY(1px);
}

.select-trigger span {
  color: var(--muted);
}

.select-trigger strong {
  min-width: 0;
  max-width: 105px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 800;
}

.select-trigger svg {
  width: 15px;
  height: 15px;
  margin-left: auto;
  color: var(--muted);
  transition: transform 160ms ease, color 140ms;
}

.custom-select.open .select-trigger svg {
  color: var(--lime);
  transform: rotate(180deg);
}

.select-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 150px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #151812;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms;
}

.custom-select.open .select-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.select-option {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--soft);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease, transform 130ms ease;
}

.select-option:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.select-option:active {
  transform: translateX(1px);
}

.select-option.active {
  background: rgba(168, 255, 69, 0.13);
  color: var(--lime);
}

/* ─── Content grid ───────────────────────────────────────── */
.content-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(248px, 300px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

/* ─── Panels ─────────────────────────────────────────────── */
.panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  overflow: hidden;
}

.library-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.meta-panel {
  padding: 16px;
  overflow: auto;
  display: none;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.panel-header > div { min-width: 0; }

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

.panel-header span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: 0.04em;
}

/* ─── Search ─────────────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 12px;
  margin: 14px 0 12px;
  border-radius: var(--r-pill);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  flex-shrink: 0;
  transition: border-color 140ms;
}

.search-box:focus-within {
  border-color: rgba(168, 255, 69, 0.25);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
}

.search-box input::placeholder { color: #5a5c55; }

/* ─── Folder strip ───────────────────────────────────────── */
.folder-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 10px;
  flex-shrink: 0;
  scrollbar-width: none;
}

.folder-strip::-webkit-scrollbar { display: none; }

.folder-chip {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.70rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: color 140ms, background 140ms, border-color 140ms;
}

.folder-chip:hover {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.08);
}

.folder-chip.active {
  color: #0d0e0b;
  background: var(--lime);
  border-color: var(--lime);
}

/* ─── Document list ──────────────────────────────────────── */
.doc-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.doc-card {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--r-card);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: border-color 140ms, background 140ms;
  flex-shrink: 0;
}

.doc-card:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
}

.doc-card.active {
  background: var(--panel-3);
  border-color: var(--line-hover);
}

.doc-card strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-card > span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
}

.doc-meta span:last-child {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  flex-shrink: 0;
}

.dot.orange { background: var(--orange); }

/* ─── Document panel ─────────────────────────────────────── */
.document-panel {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.document-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  margin-bottom: 16px;
  min-width: 0;
}

.path-line {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
  min-width: 0;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* action buttons */
.secondary-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: opacity 140ms, transform 140ms, background 140ms;
  white-space: nowrap;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.10);
}

.secondary-button.danger-button:hover {
  color: #ff8b76;
  background: rgba(255, 122, 100, 0.10);
}

.primary-button {
  background: linear-gradient(170deg, var(--lime-2) 0%, var(--lime) 100%);
  color: #0c0e09;
}

.primary-button:hover {
  transform: translateY(-1px);
  opacity: 0.93;
}

.primary-button:active { transform: translateY(0); }

.primary-button:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.secondary-button:disabled,
.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

/* ─── Status row ─────────────────────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  flex: 1;
  min-height: 32px;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 3px rgba(168, 255, 69, 0.15);
  flex-shrink: 0;
}

.status-dot.dirty {
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 159, 36, 0.15);
}

.status-separator {
  color: var(--muted);
  opacity: 0.7;
  flex-shrink: 0;
}

/* ─── Viewer / Editor ────────────────────────────────────── */
.viewer-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
}

.markdown-view,
.markdown-editor {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #0c0f0b;
  overflow: auto;
  transition: opacity 170ms ease, transform 170ms ease, border-color 170ms ease;
}

/* ── rendered view ── */
.markdown-view {
  padding: 28px 32px;
  color: #e0e2d8;
  font-size: 0.93rem;
  line-height: 1.75;
  opacity: 1;
  transform: translateY(0);
  z-index: 1;
}

.markdown-view h1 {
  font-family: var(--font);
  font-size: 1.65rem;
  font-weight: 700;
  text-transform: none;
  margin: 0 0 20px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.markdown-view h2 {
  font-family: var(--font);
  font-size: 1.10rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  margin: 28px 0 10px;
  color: var(--text);
}

.markdown-view h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 22px 0 8px;
  color: var(--soft);
}

.markdown-view p { margin: 0 0 12px; }

.markdown-view a {
  color: var(--lime);
  text-decoration: underline;
  text-decoration-color: rgba(168, 255, 69, 0.35);
  text-underline-offset: 3px;
}

.markdown-view a:hover { text-decoration-color: var(--lime); }

.markdown-view code {
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(168, 255, 69, 0.08);
  color: var(--lime-2);
  font-size: 0.88em;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.markdown-view pre {
  overflow: auto;
  padding: 18px;
  border-radius: 10px;
  background: #060807;
  border: 1px solid var(--line);
  margin: 16px 0;
}

.markdown-view pre code {
  padding: 0;
  background: transparent;
  color: #e8eae0;
}

.markdown-view ul,
.markdown-view ol {
  padding-left: 1.4rem;
  margin: 0 0 12px;
}

.markdown-view li { margin-bottom: 4px; }

.markdown-view li input[type="checkbox"] {
  accent-color: var(--lime);
  margin-right: 6px;
}

.markdown-view blockquote {
  margin: 18px 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--lime);
  color: var(--soft);
}

.markdown-view table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 0.87rem;
}

.markdown-view th {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.markdown-view td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  vertical-align: top;
}

/* ── raw editor ── */
.markdown-editor {
  resize: none;
  padding: 24px 28px;
  outline: 0;
  border-color: rgba(168, 255, 69, 0.15);
  color: #e8ebe0;
  line-height: 1.65;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.87rem;
  caret-color: var(--lime);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  z-index: 0;
}

.editing .markdown-editor {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  z-index: 2;
}

.editing .markdown-view {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
}

/* ─── Meta panel ─────────────────────────────────────────── */
.metric-card {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--r-card);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.mini-timeline {
  margin-top: 16px;
  display: grid;
  gap: 11px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.mini-timeline div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mini-timeline span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.mini-timeline .lime   { background: var(--lime); }
.mini-timeline .orange { background: var(--orange); }

/* ─── New document dialog ────────────────────────────────── */
.new-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  color: var(--text);
  background: #141712;
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.65);
  padding: 0;
}

.new-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
}

.new-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.new-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.new-dialog input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  outline: 0;
  color: var(--text);
  background: var(--panel-2);
  font-size: 0.9rem;
  font-weight: 400;
  transition: border-color 140ms;
}

.new-dialog input:focus { border-color: rgba(168, 255, 69, 0.30); }

.dialog-message {
  margin: 0;
  color: var(--soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ─── Compact layout (meta panel visible) ────────────────── */
.compact .meta-panel { display: block; }

.compact .content-grid {
  grid-template-columns: minmax(240px, 290px) minmax(0, 1fr) minmax(185px, 230px);
}

/* ─── Loading state ──────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.viewer-shell.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(12, 15, 11, 0.7);
  border-radius: var(--r-card);
  z-index: 1;
}

.viewer-shell.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 2px solid rgba(168, 255, 69, 0.15);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  z-index: 2;
}

/* ─── Todo panel ─────────────────────────────────────────── */
.todo-panel {
  flex: 1;
  min-height: 0;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.todo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  margin-bottom: 16px;
  min-height: 24px;
}

.todo-header > span:first-child {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.todo-save-status {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.todo-add-form {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  margin-bottom: 16px;
  max-width: 680px;
}

.todo-add-form input {
  flex: 1;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 0 18px;
  outline: 0;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.87rem;
  transition: border-color 140ms;
}

.todo-add-form input:focus { border-color: rgba(168, 255, 69, 0.25); }
.todo-add-form input::placeholder { color: #5a5c55; }

.todo-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
  max-width: 680px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  flex-shrink: 0;
  transition: border-color 140ms, background 140ms;
}

.todo-item:hover {
  border-color: var(--line-hover);
  background: var(--panel-3);
}

.todo-toggle {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.todo-check {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--muted);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background 140ms, border-color 140ms;
}

.todo-item.done .todo-check {
  background: var(--lime);
  border-color: var(--lime);
}

.todo-item.done .todo-check::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #0c0e09;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.todo-text {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.todo-item.done .todo-text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: rgba(122, 124, 116, 0.5);
}

.todo-edit-input {
  display: none;
  flex: 1;
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(168, 255, 69, 0.18);
  border-radius: 8px;
  padding: 0 10px;
  outline: 0;
  background: #090b08;
  color: var(--text);
  font-size: 0.9rem;
}

.todo-item.editing .todo-text {
  display: none;
}

.todo-item.editing .todo-edit-input {
  display: block;
}

.todo-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 140ms;
}

.todo-item:hover .todo-actions,
.todo-item.editing .todo-actions {
  opacity: 1;
}

.todo-icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--muted);
  transition: color 140ms, background 140ms;
}

.todo-icon-button:hover {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.07);
}

.todo-icon-button.danger:hover {
  color: #ff7a64;
  background: rgba(255, 122, 100, 0.10);
}

.todo-empty {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 8px 2px;
  margin: 0;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .content-grid,
  .compact .content-grid {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  }

  .meta-panel { display: none !important; }
}

@media (max-width: 768px) {
  .app-shell {
    height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    box-shadow: none;
  }

  .icon-rail {
    flex-direction: row;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-button.active::before { display: none; }

  .workspace {
    height: 0;
    flex: 1;
    padding: 14px 16px 16px;
    overflow: hidden;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
  }

  .hero-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
  }

  h1 { font-size: 1.7rem; }

  .content-grid,
  .compact .content-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
    gap: 12px;
  }

  .library-panel {
    max-height: 280px;
  }

  .document-panel { min-height: 0; }

  .document-top {
    flex-direction: column;
    gap: 12px;
  }

  .action-row { width: 100%; }

  .secondary-button,
  .primary-button {
    flex: 1;
    justify-content: center;
  }

  .markdown-view,
  .markdown-editor {
    min-height: 400px;
  }
}

@media (max-width: 480px) {
  .nav-pill span { display: none; }
  .nav-pill { padding: 0 12px; }
}
