@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #f7f3ea;
  --ink: #201a17;
  --muted: #5e5a56;
  --line: rgba(32, 26, 23, 0.12);
  --paper: #fffaf0;
  --panel: rgba(255, 255, 255, 0.76);
  --accent: #f2c97d;
  --accent-strong: #d69b32;
  --mint: #a8d5c2;
  --danger-bg: #fff1ef;
  --danger-line: #d6b6b0;
  --ok-bg: #e9f8f0;
  --error-bg: #ffe0dc;
  --shadow: 0 10px 24px rgba(32, 26, 23, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 249, 230, 0.9), rgba(233, 248, 240, 0.72)),
    var(--bg);
}

a {
  color: var(--ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}

button,
.btn,
.chip,
.icon-btn {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 24px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
}

.brand-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-meta {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;
}

.site-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.site-nav a,
.chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

.note-detail-page .site-nav {
  display: none;
}

.note-detail-page .site-header {
  padding-bottom: 2px;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.shell.narrow {
  max-width: 860px;
}

.page-head {
  margin: 12px 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.75rem;
  font-weight: 600;
}

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

.messages {
  margin: 12px 0;
  padding: 0;
}

.messages li,
.notice,
.empty-state {
  list-style: none;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.notice.ok {
  background: var(--ok-bg);
  border-color: rgba(47, 125, 89, 0.22);
}

.notice.error {
  background: var(--error-bg);
  border-color: rgba(160, 47, 37, 0.2);
}

.panel,
.note-card,
.editor-card,
.table-wrap {
  border: 1px solid rgba(32, 26, 23, 0.08);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.btn,
button.btn,
.search-bar button,
.composer button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  padding: 5px 9px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
}

.btn.primary,
.composer button[type="submit"] {
  background: var(--mint);
}

.btn.accent,
.search-bar button {
  background: var(--accent);
}

.btn.danger,
.btn-danger,
.icon-btn.danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  stroke: #222;
}

.pin-action svg {
  stroke: #4f4a45;
}

.pin-action.pinned {
  border-color: #d6a0a0;
  background: #fff0ee;
}

.pin-action.pinned svg {
  fill: rgba(193, 36, 36, 0.14);
  stroke: #c12424;
  stroke-width: 2.4;
}

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

.toolbar .copy-action {
  margin-right: auto;
}

.copy-check-icon {
  display: none;
}

.copy-action.copied {
  border-color: rgba(47, 125, 89, 0.35);
  background: var(--ok-bg);
}

.copy-action.copied .copy-icon {
  display: none;
}

.copy-action.copied .copy-check-icon {
  display: block;
  stroke: #2f7d59;
}

.field,
input[type="text"],
input[type="search"],
input[type="file"],
textarea {
  color: var(--ink);
}

input[type="text"],
input[type="search"],
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  padding: 9px 10px;
  outline: none;
}

input[type="text"]:focus,
input[type="search"]:focus,
textarea:focus {
  border-color: rgba(47, 125, 89, 0.55);
  box-shadow: 0 0 0 3px rgba(168, 213, 194, 0.45);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: #2f7d59;
}

.search-panel {
  position: sticky;
  top: 0;
  z-index: 8;
  margin: 0 -4px 16px;
  padding: 10px 4px;
  background: rgba(247, 243, 234, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(32, 26, 23, 0.08);
}

.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-bar input {
  flex: 1;
  min-width: 0;
}

.chips {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip.active {
  outline: 2px solid rgba(32, 26, 23, 0.18);
}

.composer {
  padding: 14px;
  margin-bottom: 16px;
}

.composer input[name="title"],
.composer textarea,
.field-title,
.field-body {
  width: 100%;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 6px 0;
}

.field-title,
.composer input[name="title"] {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.45rem;
  font-weight: 600;
}

.composer textarea,
.field-body {
  min-height: 130px;
  resize: vertical;
  line-height: 1.5;
}

.type-row,
.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.type-row {
  margin: 4px 0 8px;
}

.type-row label,
.inline-label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.note-mode {
  display: none;
}

.note-mode.active {
  display: block;
}

.result-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.note-card {
  padding: 14px;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.notes-page .note-card {
  display: flex;
  flex-direction: column;
}

.notes-page .note-card .toolbar {
  margin-top: auto;
  padding-top: 10px;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(32, 26, 23, 0.15);
}

.card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.note-card .tags,
.note-card .toolbar,
.note-card .toolbar a,
.note-card .toolbar button,
.note-card .toolbar form,
.note-card .body a {
  position: relative;
  z-index: 2;
}

.note-card h2,
.note-card h3 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.06rem;
  font-weight: 600;
}

.body,
.checklist-preview {
  color: var(--muted);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.checklist-preview,
.checklist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist-preview li {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
  min-width: 0;
}

.checklist-preview .box {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(32, 26, 23, 0.35);
  border-radius: 4px;
  font-size: 0.7rem;
}

.checked {
  text-decoration: line-through;
  opacity: 0.72;
}

.thumb {
  margin: 10px 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 6px 14px rgba(32, 26, 23, 0.12);
}

.thumb img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(32, 26, 23, 0.1);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 500;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.pin-badge,
.autosave {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  border-radius: 999px;
  background: rgba(32, 26, 23, 0.06);
  padding: 2px 7px;
}

.pin-badge svg {
  width: 14px;
  height: 14px;
  stroke: #c12424;
}

.editor-card {
  padding: 16px;
}

.editor-top {
  margin-bottom: 10px;
}

.editor-top a {
  font-weight: 600;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
}

.checklist-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
}

.checklist-item .item-text {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 5px 0;
  box-shadow: none;
}

.checklist-empty {
  margin: 0;
  color: var(--muted);
}

.editor-meta {
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.autosave.saving {
  background: #fff4cf;
}

.autosave.error {
  background: var(--error-bg);
}

.autosave.ok {
  background: var(--ok-bg);
}

.spinner {
  width: 12px;
  height: 12px;
  display: inline-block;
  border: 2px solid rgba(32, 26, 23, 0.15);
  border-top-color: rgba(32, 26, 23, 0.55);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.check {
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.image {
  margin: 12px 0;
}

.image img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 6px 14px rgba(32, 26, 23, 0.12);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(32, 26, 23, 0.09);
}

th {
  background: rgba(255, 250, 240, 0.85);
}

td form {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}

.swatch {
  width: 20px;
  height: 20px;
  display: inline-block;
  border-radius: 50%;
  border: 1px solid rgba(32, 26, 23, 0.14);
}

.token-box {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #f0d27a;
  border-radius: var(--radius);
  background: #fff7d6;
  overflow-wrap: anywhere;
}

.home-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .site-header {
    padding: 18px 16px 6px;
  }

  .site-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shell {
    padding: 0 16px 30px;
  }

  .page-title {
    font-size: 1.45rem;
  }

  .search-bar,
  .form-row,
  .actions {
    align-items: stretch;
  }

  .search-bar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .search-bar .chip {
    grid-column: 1 / -1;
  }

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

  .composer .form-row,
  .editor-card .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn,
  button.btn,
  .search-bar button,
  .composer button {
    min-height: 38px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }
}

/* Go rewrite: preserve note line breaks when rendering escaped plain text. */
.body {
  white-space: pre-wrap;
}

/* Keep long previews compact on the notes overview. Full content is shown on the detail page. */
.notes-page .note-card .body,
.notes-page .note-card .checklist-preview {
  max-height: 11.5rem;
  overflow: hidden;
}
