/* NoteDeck — mesa de trabalho noturna: índigo profundo, luminária âmbar */

:root {
  --ink: #12141f;
  --panel: #191c2a;
  --panel-2: #202538;
  --raise: #272c43;
  --line: #2f3450;
  --text: #e8e9f3;
  --muted: #8b90b4;
  --amber: #f0b429;
  --amber-dim: rgba(240, 180, 41, 0.14);
  --iris: #8090ff;
  --green: #4ec9a5;
  --red: #ff6b6b;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --prose: "Inter", system-ui, sans-serif;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--iris); }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ------------------------------------------------------- topo */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 54px;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
  font-size: 17px;
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber);
  align-self: center;
}

.topnav {
  display: flex;
  gap: 4px;
  margin-left: 10px;
}

.topnav a {
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.topnav a:hover { color: var(--text); background: var(--panel-2); }
.topnav a.active { color: var(--ink); background: var(--amber); font-weight: 600; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.topbar-right .who { font-family: var(--mono); }

/* ------------------------------------------------------- botões */

.btn {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 13px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.08s;
  white-space: nowrap;
}

.btn:hover { background: var(--raise); border-color: #3b4166; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #17130a; font-weight: 600; }
.btn.primary:hover { background: #ffc542; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }

/* ------------------------------------------------------- layout notas */

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 54px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.search {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.search::placeholder { color: #616790; }
.search:focus { border-color: var(--amber); outline: none; }

.note-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px;
  min-height: 0;
}

.note-item {
  padding: 10px 11px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.note-item:hover { background: var(--panel-2); }

.note-item.active {
  background: var(--panel-2);
  border-color: var(--line);
  box-shadow: inset 3px 0 0 var(--amber);
}

.note-item h4 {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item .pin { color: var(--amber); }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ------------------------------------------------------- editor */

.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.title-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  padding: 4px 0;
}

.title-input:focus { outline: none; }
.title-input::placeholder { color: #565b82; }

.tags-input {
  width: 150px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.tags-input:focus { outline: none; border-color: var(--amber); color: var(--text); }

.dropdown { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 208px;
  padding: 5px;
  display: none;
  z-index: 60;
}

.menu.open { display: block; }

.menu a, .menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  background: none;
  border: none;
  font-family: var(--sans);
  cursor: pointer;
}

.menu a:hover, .menu button:hover { background: var(--raise); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 3px; }
.menu .label {
  padding: 7px 11px 4px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
}

.editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.pane {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow: hidden;
}

.pane.hidden { display: none; }

.gutter {
  width: 52px;
  padding: 16px 8px 16px 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: #4a4f75;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
  user-select: none;
  white-space: pre;
}

#editor {
  flex: 1;
  background: var(--ink);
  color: var(--text);
  border: none;
  resize: none;
  padding: 16px 20px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  tab-size: 2;
  caret-color: var(--amber);
}

#editor:focus { outline: none; }

.preview {
  flex: 1;
  overflow-y: auto;
  padding: 26px 34px 60px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  font-family: var(--prose);
  font-size: 15px;
}

.preview.solo { border-left: none; }

/* ------------------------------------------------------- assinatura: régua de status */

.statusline {
  display: flex;
  align-items: center;
  gap: 0;
  height: 26px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
}

.statusline .seg {
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.statusline .seg.mode {
  background: var(--amber);
  color: #17130a;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-right: none;
}

.statusline .seg.state[data-state="salvo"] { color: var(--green); }
.statusline .seg.state[data-state="salvando"] { color: var(--amber); }
.statusline .seg.state[data-state="erro"] { color: var(--red); }
.statusline .spacer { flex: 1; border: none; }

/* ------------------------------------------------------- prosa renderizada */

.preview h1, .preview h2, .preview h3, .preview h4 {
  font-family: var(--sans);
  letter-spacing: -0.02em;
  margin: 1.6em 0 0.5em;
  line-height: 1.25;
}

.preview h1 { font-size: 27px; }
.preview h2 { font-size: 21px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.preview h3 { font-size: 17px; }
.preview > :first-child { margin-top: 0; }
.preview p { margin: 0 0 1em; }
.preview ul, .preview ol { padding-left: 1.35em; margin: 0 0 1em; }
.preview li { margin-bottom: 0.3em; }
.preview li::marker { color: var(--amber); }

.preview blockquote {
  margin: 0 0 1em;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--amber);
  color: var(--muted);
}

.preview code {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--raise);
  padding: 2px 5px;
  border-radius: 4px;
  color: #ffd97d;
}

.preview pre {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 1em;
}

.preview pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.6;
}

.preview .code-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 -0.6em;
  padding-left: 3px;
}

.preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 1em;
  font-size: 14px;
}

.preview th, .preview td {
  border: 1px solid var(--line);
  padding: 7px 11px;
  text-align: left;
}

.preview th { background: var(--panel-2); font-family: var(--sans); }
.preview hr { border: none; border-top: 1px solid var(--line); margin: 1.8em 0; }
.preview img { max-width: 100%; border-radius: 8px; }
.preview mark { background: var(--amber-dim); color: var(--text); padding: 1px 3px; }

/* ------------------------------------------------------- kanban */

.board-shell {
  height: calc(100vh - 54px);
  display: flex;
  flex-direction: column;
}

.board-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.board-head h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.board-select {
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: var(--sans);
  font-size: 13.5px;
}

.board {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 16px 18px 22px;
  overflow-x: auto;
  align-items: flex-start;
  min-height: 0;
}

.list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 296px;
  flex: 0 0 296px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

.list-head .name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--sans);
  padding: 2px 0;
}

.list-head .name:focus { outline: none; border-bottom: 1px solid var(--amber); }

.count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 2px 8px;
}

.cards {
  padding: 9px;
  overflow-y: auto;
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cards.dragover { background: var(--amber-dim); }

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: grab;
}

.card:hover { border-color: #454b73; }
.card.dragging { opacity: 0.35; }

.card h5 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}

.card p {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .chip {
  display: inline-block;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-dim);
  border-radius: 4px;
  padding: 2px 6px;
}

.list-foot { padding: 8px 9px 10px; }

.add-card {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 8px 11px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
}

.add-card:hover { color: var(--amber); border-color: var(--amber); }

.add-list {
  flex: 0 0 268px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: none;
  color: var(--muted);
  padding: 15px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13.5px;
}

.add-list:hover { color: var(--amber); border-color: var(--amber); }

/* ------------------------------------------------------- modal */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 15, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}

.overlay.open { display: flex; }

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
}

.modal h3 { margin: 0 0 14px; font-size: 17px; letter-spacing: -0.02em; }

.field { margin-bottom: 13px; }

.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 6px;
}

.field input, .field textarea, .field select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.field textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--amber); }

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

.modal-actions .left { margin-right: auto; }

/* ------------------------------------------------------- login */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(680px 340px at 50% -8%, rgba(240, 180, 41, 0.10), transparent 70%),
    var(--ink);
}

.gate-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.gate-card .brand { font-size: 22px; margin-bottom: 4px; }

.gate-card .lede {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 22px;
}

.gate-card .field input { font-size: 14px; padding: 11px; }
.gate-card .btn { width: 100%; padding: 11px; font-size: 14.5px; margin-top: 6px; }

.gate-foot {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.alert {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert.error { color: var(--red); border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.08); }
.alert.ok { color: var(--green); border-color: rgba(78, 201, 165, 0.4); background: rgba(78, 201, 165, 0.08); }

/* ------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translate(-50%, 14px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 90;
}

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

/* ------------------------------------------------------- responsivo */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.show { display: flex; position: fixed; inset: 54px 0 0; z-index: 50; }
  .mobile-toggle { display: inline-block !important; }
  .gutter { display: none; }
  .preview { padding: 20px; }
  .tags-input { display: none; }
}

.mobile-toggle { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
