:root {
  --page: #1c1b22;
  --panel: #23222b;
  --panel-hover: #2f2e38;
  --selected: #3a3550;
  --border: #3a3944;
  --text: #fbfbfe;
  --muted: #8f8f9d;
  --empty-page: #6b6b78;
  --accent: #a68cff;
  --checked: #2ea44f;
  --warning: #f5c518;
  --highlight: rgba(245, 197, 24, 0.45);
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

button {
  background: var(--accent);
  color: #1c1b22;
  border: 0;
  border-radius: 6px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

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

input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

.hint {
  color: var(--muted);
  padding: 0 16px;
}

.quiet-link {
  color: var(--muted);
  text-decoration: none;
}

.quiet-link:hover {
  color: var(--text);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

.brand-row img {
  width: 28px;
  height: 28px;
}

/* ---- login and the notebook list ---- */

body.centered {
  display: flex;
  justify-content: center;
  padding: 48px 16px;
}

.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 320px;
}

.login-logo {
  width: 160px;
  height: 160px;
}

.login .brand {
  font-size: 32px;
  margin: 12px 0 24px 0;
}

.card-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.card-form label {
  color: var(--muted);
  font-size: 14px;
}

.card-form button {
  margin-top: 8px;
}

.form-error {
  color: var(--danger);
  margin: 4px 0;
}

.notebooks {
  width: 480px;
  max-width: 100%;
}

.notebooks .brand {
  font-size: 22px;
}

.notebooks h2 {
  font-size: 16px;
  color: var(--muted);
  margin: 32px 0 8px 0;
}

.notebook-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.notebook-list li {
  display: flex;
  align-items: center;
  border-radius: 6px;
  background: var(--panel);
  margin-bottom: 6px;
}

.notebook-list li:hover {
  background: var(--panel-hover);
}

.notebook-list a {
  flex: 1;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
}

.trash-button {
  display: flex;
  background: none;
  color: var(--muted);
  padding: 8px 12px;
}

.trash-button:hover {
  color: var(--danger);
}

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

.modal-note {
  color: var(--muted);
  font-size: 14px;
}

.modal-input {
  width: 100%;
  margin-bottom: 16px;
}

.inline-form {
  flex-direction: row;
}

.inline-form input {
  flex: 1;
}

.inline-form button {
  margin-top: 0;
}

.notebooks .quiet-link {
  display: inline-block;
  margin-top: 40px;
}

/* ---- the notebook itself ---- */

body.workspace {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

/* ---- the menu bar ---- */

.menu-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.menu {
  position: relative;
}

.menu-button {
  background: none;
  color: var(--muted);
  font-weight: 500;
  padding: 6px 12px;
}

.menu-button:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.menu-arrow {
  font-size: 11px;
}

.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 200px;
  padding: 4px 0;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.dropdown[hidden] {
  display: none;
}

.dropdown-item {
  display: block;
  padding: 6px 14px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: var(--selected);
}

.dropdown-item.current {
  font-weight: 700;
}

.dropdown-item.current::before {
  content: "\2713  ";
}

.dropdown-separator {
  margin: 4px 0;
  border-top: 1px solid var(--border);
}

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

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.save-status[data-state=""] .status-dot {
  display: none;
}

.save-status[data-state="saved"] .status-dot {
  background: var(--checked);
}

.save-status[data-state="unsaved"] .status-dot {
  background: var(--warning);
}

.save-status[data-state="failed"] .status-dot {
  background: var(--danger);
}

.panels {
  flex: 1;
  display: flex;
  min-height: 0;
}

.pages-panel {
  position: relative;
  width: 20%;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 8px 0;
}

.page-tree,
.page-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-tree ul {
  padding-left: 16px;
}

.page-row {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.page-row:hover {
  background: var(--panel-hover);
}

.page-row.selected {
  background: var(--selected);
}

/* A page with nothing written in it yet, like one made by typing a link to it. */
.page-row.empty .page-row-title {
  color: var(--empty-page);
}

.page-row.heading .page-row-title {
  color: var(--text);
  font-weight: 700;
}

/* Where a dragged page will land: between two rows, or one level in as the last child of a row. */
.drop-line {
  position: absolute;
  right: 8px;
  height: 2px;
  margin-top: -1px;
  background: var(--accent);
  pointer-events: none;
}

.drop-line[hidden] {
  display: none;
}

.page-row.dragging {
  opacity: 0.4;
}

.page-row-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 2px;
  flex-shrink: 0;
  border-radius: 4px;
  color: var(--muted);
  font-family: monospace;
  font-size: 18px;
  font-weight: 700;
  transition: transform 0.1s;
}

.toggle:not(:empty):hover {
  color: var(--text);
  background: var(--selected);
}

.toggle.open {
  transform: rotate(90deg);
}

.editor-panel {
  width: 80%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.page-title {
  margin: 0;
  padding: 16px 24px 12px 24px;
  font-size: 26px;
  user-select: text;
}

.editor {
  flex: 1;
  min-height: 0;
}

.editor[hidden] {
  display: none;
}

.toastui-editor-dark .toastui-editor-ww-container,
.toastui-editor-dark.toastui-editor-defaultUI .toastui-editor-toolbar,
.toastui-editor-dark .toastui-editor-defaultUI-toolbar {
  background-color: var(--page);
}

.toastui-editor-dark.toastui-editor-defaultUI {
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
}

.toastui-editor-contents {
  font-size: 15px;
}

/* A click on a link follows it, so it looks clickable even though the editor is editable text. */
.toastui-editor-contents a {
  cursor: pointer;
}

/* Headings are told apart by size alone, without the full width rule the editor draws under them. */
.toastui-editor-dark .toastui-editor-contents h1,
.toastui-editor-dark .toastui-editor-contents h2 {
  border-bottom: none;
  padding-bottom: 0;
}

.toastui-editor-dark .toastui-editor-contents .task-list-item.checked::before {
  background-color: var(--checked);
  border-radius: 3px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18'><path d='M4.5 9.5l3 3 6-6.5' stroke='white' stroke-width='2.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

/* Follows the pointer over a link in the editor, saying where the link goes. */
.link-tooltip {
  position: fixed;
  z-index: 150;
  max-width: 60vw;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.link-tooltip[hidden] {
  display: none;
}

/* ---- right click menu and the confirm box ---- */

.context-menu {
  position: fixed;
  z-index: 100;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  min-width: 170px;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.context-menu[hidden],
.context-menu li[hidden] {
  display: none;
}

.context-menu li {
  padding: 6px 14px;
  cursor: pointer;
}

.context-menu li:hover {
  background: var(--selected);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  min-width: 320px;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-buttons button:not(.danger) {
  background: var(--panel-hover);
  color: var(--text);
}

/* ---- page list warnings ---- */

.warning-icon {
  display: inline-flex;
  flex-shrink: 0;
  margin-right: 4px;
  color: var(--warning);
  cursor: help;
}

/* ---- search, tasks and emoji ---- */

/* Search and task matches, marked by the browser's highlight api rather than by changing the editor's html. */
::highlight(search-match) {
  background-color: var(--highlight);
  color: var(--text);
}

.search-modal {
  width: 640px;
  max-width: calc(100vw - 32px);
}

.search-modal .modal-input {
  margin-bottom: 8px;
}

/* A fixed height, so the box does not jump around while typing. */
.result-list {
  height: 360px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.result {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.result:hover {
  background: var(--panel-hover);
}

.result-heading {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.result-title {
  font-weight: 600;
}

.result-where,
.result-count {
  color: var(--muted);
  font-size: 13px;
}

.result-count {
  margin-left: auto;
}

.result-snippet {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tasks-modal {
  width: 80vw;
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.tasks-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.tasks-heading {
  font-size: 18px;
  font-weight: 700;
}

.tasks-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.tasks-filters select {
  background: var(--panel-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
}

.tasks-filters .modal-note {
  margin: 0 0 0 auto;
}

.task-list {
  flex: 1;
  overflow-y: auto;
  padding-top: 8px;
}

.task-group {
  margin: 14px 0 4px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.task-row:hover {
  background: var(--panel-hover);
}

/* A plain dot rather than a box, since a task is ticked off in its page and not here. */
.task-box {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin: 0 4px;
  border-radius: 50%;
  background: var(--muted);
}

.task-row.done .task-box {
  background: var(--checked);
}

.task-row.done .task-text {
  color: var(--muted);
}

.task-text {
  flex: 1;
}

.badge {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
}

.estimate-badge {
  background: var(--selected);
}

.estimate-slot {
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
  width: 48px;
}

.context-badge {
  color: var(--accent);
  border: 1px solid var(--accent);
}

.page-badge {
  color: var(--muted);
  border: 1px solid var(--border);
}

.emoji-popup {
  position: fixed;
  z-index: 150;
  max-height: 260px;
  min-width: 220px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: var(--panel-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.emoji-popup[hidden] {
  display: none;
}

.emoji-popup li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 14px;
}

.emoji-popup li.chosen,
.emoji-popup li:hover {
  background: var(--selected);
}

.emoji-character {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.deadline-badge {
  border: 1px solid var(--border);
}

.deadline-badge.soon {
  color: var(--warning);
  border-color: var(--warning);
}

.deadline-badge.overdue {
  color: white;
  background: var(--danger);
  border-color: var(--danger);
}

.bad-deadline-badge {
  color: var(--warning);
  border: 1px dashed var(--warning);
}

/* Drawn by deadlines.js just left of the "]" of a "[d:" that is not a whole, real date. */
.inline-warning {
  display: inline-flex;
  vertical-align: -1px;
  margin: 0 1px;
  color: var(--warning);
  cursor: help;
}

.deadline-slot {
  display: flex;
  flex-shrink: 0;
  width: 96px;
}

.page-slot {
  display: flex;
  flex-shrink: 0;
  width: 160px;
}

.page-slot .page-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
