:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #1e1e1e;
  --muted: #6b6b6b;
  --line: #d9d9d9;
  --accent: #1769aa;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 1rem;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
}

h1 {
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1.4rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.app-header-actions {
  display: flex;
  gap: 0.5rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 20%) minmax(0, 80%);
  gap: 1rem;
  align-items: start;
}

.left-column,
.right-column {
  min-width: 0;
}

.stack {
  display: grid;
  gap: 0.55rem;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
}

.tags-field {
  position: relative;
}

.tag-suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.3rem;
  display: grid;
  gap: 0.25rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.tag-suggestions[hidden] {
  display: none;
}

.tag-suggestion {
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
}

.tag-suggestion:hover {
  background: #f3f7fc;
}

.tag-suggestion.active {
  background: #e8f1fb;
  border-color: #c9dff5;
}

.editor-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 0.4rem;
  padding: 0.45rem;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
  flex-wrap: wrap;
}

.editor {
  min-height: 180px;
  padding: 0.7rem;
  outline: none;
}

.editor:empty::before {
  content: "Write notes...";
  color: #9a9a9a;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font-size: 0.92rem;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button.danger {
  color: var(--danger);
  border-color: #f1c4c0;
  background: #fff9f8;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

.search {
  display: grid;
  gap: 0.4rem;
}

ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  cursor: grab;
}

li:last-child {
  border-bottom: 0;
}

li.dragging {
  opacity: 0.45;
}

li.drop-target {
  border-top: 2px solid var(--accent);
}

li.active {
  background: #f3f8ff;
  border-radius: 6px;
}

.todo-content {
  min-width: 0;
  width: 100%;
}

.todo-title {
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
  overflow-wrap: anywhere;
}

.todo-notes {
  overflow-wrap: anywhere;
}

.todo-notes p {
  margin: 0.35rem 0;
}

.empty {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.muted {
  color: var(--muted);
}

.todo-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
}

.tag {
  font-size: 0.78rem;
  line-height: 1;
  padding: 0.3rem 0.45rem;
  border-radius: 999px;
  background: #e8f1fb;
  color: #124775;
  border: 1px solid #c9dff5;
}

.confirm-dialog {
  width: min(420px, calc(100% - 2rem));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.confirm-text {
  margin: 0 0 0.9rem;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

@media (max-width: 860px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

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