:root {
  --bg: #f5f2ee;
  --surface: #fdfaf7;
  --surface-2: #efe9e1;
  --text: #2c2420;
  --muted: #8a7e74;
  --line: #ddd5cb;
  --line-strong: #b8ada2;
  --ink: #3a3028;
  --ink-soft: #5c4f42;
  --shadow: 0 10px 24px rgba(60, 48, 36, 0.08);
  --accent: #6b8f71;
  --accent-hover: #5a7d60;
  --danger: #a65555;
}

body.dark-mode {
  --bg: #1a1714;
  --surface: #221f1a;
  --surface-2: #2d2822;
  --text: #ede8e2;
  --muted: #a39888;
  --line: #3d362e;
  --line-strong: #5a5147;
  --ink: #ede8e2;
  --ink-soft: #c9bfb2;
  --shadow: 0 14px 26px rgba(0, 0, 0, 0.42);
  --accent: #7daa83;
  --accent-hover: #6b9971;
  --danger: #cc7777;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  background: linear-gradient(120deg, var(--bg), var(--surface-2) 60%, var(--bg));
  background-attachment: fixed;
  font-family: "Noto Sans KR", sans-serif;
  letter-spacing: 0.01em;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Outfit", "Noto Sans KR", sans-serif;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 9px 13px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: var(--accent-hover);
}

.btn:disabled,
.icon-btn:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  display: block;
  margin: auto;
}

#themeToggleBtn {
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  line-height: 0;
}

#themeToggleBtn .icon-moon,
#themeToggleBtn .icon-sun {
  display: block;
  width: 18px;
  height: 18px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 0;
  margin: 0;
}

#themeToggleBtn .icon-moon::before,
#themeToggleBtn .icon-moon::after,
#themeToggleBtn .icon-sun::before,
#themeToggleBtn .icon-sun::after {
  content: none;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-header {
  margin-bottom: 18px;
}

.auth-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.password-rules {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
}

.password-rule-summary {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.password-rules ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.password-rules li {
  font-size: 12px;
  color: var(--muted);
}

.password-rules li.ok {
  color: var(--accent);
}

.password-rules li.bad {
  color: var(--danger);
}

.auth-form label {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.auth-foot {
  margin: 14px 0 0;
  color: var(--muted);
}

.auth-foot a {
  color: var(--accent);
  font-weight: 700;
}

.auth-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--ink-soft);
}

.auth-message[data-error="1"] {
  color: var(--danger);
}

.app-body {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(253, 250, 247, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

body.dark-mode .app-topbar {
  background: rgba(34, 31, 26, 0.9);
}

.left-group,
.right-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.guest-badge {
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface);
}

.hotkey-hint {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 7px;
  background: var(--surface);
}

.theme-fab {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  z-index: 80;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.theme-fab:hover {
  background: var(--surface-2);
}

.search-input {
  width: min(340px, 42vw);
}

.app-layout {
  display: grid;
  grid-template-areas: "sidebar editor settings";
  grid-template-columns: 240px 1fr 240px;
  gap: 12px;
  padding: 12px;
  flex: 1;
  min-height: 0;
  transition: grid-template-columns 0.28s ease;
}

.sidebar {
  grid-area: sidebar;
}

.editor-section {
  grid-area: editor;
}

.settings-panel {
  grid-area: settings;
}

.app-layout.sidebar-collapsed {
  grid-template-areas: "editor settings";
  grid-template-columns: 1fr 240px;
}

.app-layout.settings-collapsed {
  grid-template-areas: "sidebar editor";
  grid-template-columns: 240px 1fr;
}

.app-layout.sidebar-collapsed.settings-collapsed {
  grid-template-areas: "editor";
  grid-template-columns: 1fr;
}

.sidebar,
.editor-section,
.settings-panel {
  background: linear-gradient(170deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition: width 0.26s ease, padding 0.26s ease, opacity 0.26s ease;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
}

.app-layout.sidebar-collapsed .sidebar {
  display: none;
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.note-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.sidebar-workspace {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.folder-tree {
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  min-height: 88px;
  max-height: 220px;
  overflow: auto;
}

.folder-node {
  --folder-depth: 0;
  margin: 0;
}

.folder-row {
  display: flex;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  padding-left: calc(8px + var(--folder-depth) * 14px);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.folder-row:hover {
  background: var(--surface-2);
}

.folder-node.active .folder-row {
  background: var(--surface-2);
  font-weight: 600;
}

.folder-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-context-menu {
  position: fixed;
  z-index: 180;
  min-width: 200px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 6px;
}

.sidebar-context-menu[hidden] {
  display: none !important;
}

.sidebar-context-menu button {
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.sidebar-context-menu button:hover {
  background: var(--surface-2);
}

.note-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px;
  cursor: pointer;
  display: grid;
  gap: 4px;
}

.note-item.file-entry {
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  padding-left: calc(8px + var(--file-depth) * 14px);
  background: transparent;
}

.note-item.file-entry:hover {
  background: var(--surface-2);
}

.note-item.file-entry.active {
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.file-title {
  font-size: 13px;
  font-weight: 600;
}

.file-meta {
  font-size: 11px;
  color: var(--muted);
}

.note-item strong {
  font-size: 14px;
}

.note-item span {
  font-size: 12px;
  color: var(--muted);
}

.note-item.active {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.note-item.empty {
  cursor: default;
  opacity: 0.8;
}

.editor-section {
  display: flex;
  flex-direction: column;
  padding: 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  transition: transform 0.28s ease;
}

.app-layout.sidebar-collapsed .editor-section {
  transform: translateX(-12px);
}

.editor-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  gap: 8px;
  margin-bottom: 10px;
}

.page-title-row {
  display: flex;
  align-items: center;
  width: 100% !important;
  min-width: 0;
  flex: 0 0 auto;
  min-inline-size: 0;
}

#titleInput {
  display: block;
  flex: 1 1 100% !important;
  width: 100% !important;
  max-width: none;
  min-width: 0;
  min-height: 56px;
  line-height: 1.2;
  white-space: nowrap;
  box-sizing: border-box;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-size: 34px;
  font-weight: 700;
  padding: 8px 0;
  background: transparent;
}

#titleInput:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  margin-bottom: 2px;
}

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

.block-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.chip-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
}

.chip-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

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

.split-row input {
  width: 120px;
}

.editor-content {
  --editor-split: 50%;
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 10px;
  position: relative;
  z-index: 1;
  margin-top: 6px;
}

.editor-pane {
  width: var(--editor-split);
  min-width: 0;
  max-width: calc(100% - 120px);
}

#contentInput,
.preview-panel {
  min-height: 0;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

#contentInput {
  width: 100%;
  resize: none;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.editor-splitter {
  width: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--surface-2), var(--line));
  border: 1px solid var(--line);
  cursor: col-resize;
}

.editor-content.preview-hidden .editor-pane {
  width: 100%;
  max-width: 100%;
}

.editor-content.preview-hidden .preview-panel,
.editor-content.preview-hidden .editor-splitter {
  display: none;
}

.editor-pane.narrow {
  max-width: 900px;
}

.editor-pane.wide {
  max-width: 1200px;
}

.editor-content.reduce-motion * {
  transition: none !important;
  animation: none !important;
}

body.dragging-splitter {
  user-select: none;
  cursor: col-resize;
}

.preview-panel {
  padding: 14px;
  overflow: auto;
}

.preview-panel pre {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.preview-panel h1,
.preview-panel h2,
.preview-panel h3 {
  margin-top: 1.1em;
}

.statusbar {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.settings-panel {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  transition: transform 0.26s ease, opacity 0.26s ease;
}

.settings-panel.closed {
  transform: translateX(108%);
  opacity: 0;
  pointer-events: none;
}

.app-layout.settings-collapsed .settings-panel {
  display: none;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink-soft);
}

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

.setting-inline input[type="number"] {
  width: 84px;
}

#lineHeightNumber {
  width: 84px;
}

.setting-row select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
}

.setting-actions {
  display: grid;
  gap: 8px;
}

.file-btn {
  display: inline-flex;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.tip {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.settings-subtitle {
  margin: 6px 0 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.editor-context-menu {
  position: fixed;
  z-index: 120;
  width: 240px;
  max-height: min(420px, calc(100vh - 20px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 8px;
}

.context-search {
  margin: 0 0 6px;
  border-radius: 8px;
  padding: 8px 9px;
}

.context-title {
  padding: 6px 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.context-subtitle {
  margin: 8px 2px 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.context-recent {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.context-recent-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.context-recent-btn:hover {
  background: var(--surface-2);
}

.editor-context-menu button {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.editor-context-menu button:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.editor-context-menu button.active {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.context-example-tooltip {
  position: fixed;
  z-index: 140;
  max-width: 320px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  white-space: pre-wrap;
  line-height: 1.35;
  font-size: 12px;
  pointer-events: none;
}

.toast-area {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 210px;
  box-shadow: var(--shadow);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-size: 13px;
}

.toast.success {
  border-color: var(--accent);
}

.toast.warn {
  border-color: var(--danger);
}

.toast.hide {
  opacity: 0;
  transform: translateY(10px);
}

body.compact-mode .app-layout {
  gap: 8px;
  padding: 8px;
}

body.compact-mode .sidebar,
body.compact-mode .editor-section,
body.compact-mode .settings-panel {
  border-radius: 12px;
}

body.compact-mode .btn,
body.compact-mode .icon-btn {
  padding-top: 7px;
  padding-bottom: 7px;
}

.public-wrap {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 14px;
}

.public-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

body.dark-mode .btn {
  color: #1a1714;
  background: var(--ink);
  border-color: var(--ink);
}

body.dark-mode .btn:hover {
  background: #fff;
}

body.dark-mode .btn.ghost {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line-strong);
}

body.dark-mode .btn.ghost:hover,
body.dark-mode .icon-btn:hover,
body.dark-mode .editor-context-menu button:hover {
  background: var(--surface);
}

body.dark-mode .auth-message {
  color: var(--muted);
}

.public-card h1 {
  margin-bottom: 14px;
}

.sidebar-organization {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.sidebar-org-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sidebar-org-details summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.sidebar-org-details summary::-webkit-details-marker {
  display: none;
}

.sidebar-org-details summary::before {
  content: "\25B8";
  margin-right: 4px;
  font-size: 10px;
}

.sidebar-org-details[open] summary::before {
  content: "\25BE";
}

.sidebar-org-details > *:not(summary) {
  padding: 0 8px 6px;
}

.sidebar-org-summary button {
  pointer-events: auto;
}

.sidebar-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.sidebar-item:hover {
  background: var(--surface-2);
}

.sidebar-item.active {
  background: var(--surface-2);
  font-weight: 600;
}

.sidebar-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-actions {
  display: flex;
  gap: 4px;
}

.sidebar-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sidebar-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
}

.sidebar-tag:hover {
  background: var(--surface-2);
}

.sidebar-tag.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sidebar-add-form {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sidebar-add-form input {
  flex: 1;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 6px;
}

.icon-btn-sm {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.icon-btn-xs {
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-btn-xs:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-icon {
  padding: 6px 10px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-icon.pinned {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-2);
  font-weight: 600;
}

.btn-icon .pin-svg {
  flex-shrink: 0;
}

.btn-icon.pinned .pin-svg {
  stroke: var(--accent);
  fill: var(--accent);
}

.logo-text {
  font-family: "Outfit", sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.filter-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 500;
  transition: all 0.15s ease;
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.filter-btn:hover:not(.active) {
  background: var(--line);
}

.note-meta {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.note-meta-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.note-meta-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.note-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.meta-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  background: var(--surface);
  color: var(--muted);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.meta-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.meta-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sidebar-head-actions {
  display: flex;
  gap: 4px;
}

.copy-code-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.preview-panel pre:hover .copy-code-btn {
  opacity: 1;
}

.copy-code-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.public-card pre {
  position: relative;
}

.public-card .copy-code-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.public-card pre:hover .copy-code-btn {
  opacity: 1;
}

.icon-hamburger {
  display: inline-block;
  width: 16px;
  height: 12px;
  position: relative;
}

.icon-hamburger::before,
.icon-hamburger::after,
.icon-hamburger span {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.icon-hamburger::before {
  top: 0;
}

.icon-hamburger span {
  top: 5px;
}

.icon-hamburger::after {
  top: 10px;
}

.icon-hamburger span {
  display: none;
}

.icon-refresh {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text);
  border-right-color: transparent;
  border-radius: 50%;
  position: relative;
}

.icon-refresh::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -2px;
  width: 0;
  height: 0;
  border-left: 4px solid var(--text);
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
}

.icon-plus {
  display: inline-block;
  width: 10px;
  height: 10px;
  position: relative;
}

.icon-plus::before,
.icon-plus::after {
  content: "";
  display: block;
  position: absolute;
  background: var(--text);
  border-radius: 1px;
}

.icon-plus::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-50%);
}

.icon-plus::after {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

.icon-pin {
  display: inline-block;
  width: 14px;
  height: 14px;
  position: relative;
}

.icon-pin::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border: 2px solid var(--text);
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.icon-pin::after {
  content: "";
  display: block;
  width: 2px;
  height: 7px;
  background: var(--text);
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.btn-icon.pinned .icon-pin::before {
  background: var(--text);
}

.icon-moon {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text);
  position: relative;
}

.icon-moon::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-radius: 50%;
}

.icon-sun {
  display: inline-block;
  width: 16px;
  height: 16px;
  position: relative;
}

.icon-sun::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border: 2px solid var(--text);
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
}

.icon-sun::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  position: absolute;
  top: 0;
  left: 0;
  background:
    radial-gradient(circle, var(--text) 1px, transparent 1px) 3px 0,
    radial-gradient(circle, var(--text) 1px, transparent 1px) 3px 14px,
    radial-gradient(circle, var(--text) 1px, transparent 1px) 0 3px,
    radial-gradient(circle, var(--text) 1px, transparent 1px) 14px 3px;
}

.note-item.pinned {
  border-left: 3px solid var(--accent);
}

@media (max-width: 1280px) {
  .app-layout {
    grid-template-areas: "sidebar editor";
    grid-template-columns: 260px 1fr;
  }

  .app-layout.sidebar-collapsed {
    grid-template-areas: "editor";
    grid-template-columns: 1fr;
  }

  .app-layout.settings-collapsed .settings-panel {
    position: fixed;
    right: 12px;
    top: 70px;
    width: min(310px, calc(100vw - 24px));
    z-index: 30;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
  }

  .settings-panel.closed {
    transform: translateX(108%);
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
    height: auto;
  }

  .app-body {
    height: auto;
    overflow: auto;
  }

  .app-layout {
    grid-template-areas: "editor";
    grid-template-columns: 1fr;
    height: auto;
  }

  .app-layout.sidebar-collapsed {
    grid-template-areas: "editor";
    grid-template-columns: 1fr;
  }

  .app-layout.settings-collapsed .settings-panel {
    position: fixed;
    right: 12px;
    top: 70px;
    width: min(310px, calc(100vw - 24px));
    z-index: 30;
  }

  .sidebar {
    max-height: 340px;
  }

  .sidebar-organization {
    max-height: 200px;
    overflow-y: auto;
  }

  .app-layout.sidebar-collapsed .editor-section {
    transform: none;
  }

  #contentInput,
  .preview-panel {
    min-height: 280px;
  }

  .editor-content {
    flex-direction: column;
  }

  #titleInput {
    font-size: 26px;
  }

  .editor-pane,
  .editor-pane.narrow,
  .editor-pane.wide {
    width: 100%;
    max-width: 100%;
  }

  .editor-splitter {
    display: none;
  }

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

  .toolbar-actions {
    flex-wrap: wrap;
  }

  .statusbar {
    flex-wrap: wrap;
  }

  .note-meta {
    flex-direction: column;
    gap: 6px;
  }

  .note-meta-chips {
    gap: 3px;
  }

  .search-input {
    width: 100%;
    max-width: none;
  }

  .hotkey-hint {
    display: none;
  }

  .statusbar {
    flex-wrap: wrap;
  }

  .note-meta {
    flex-direction: column;
    gap: 6px;
  }

  .note-meta-chips {
    gap: 3px;
  }
}

@media (max-width: 760px) {
  .app-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
  }

  .left-group,
  .right-group {
    flex-wrap: wrap;
    gap: 6px;
  }

  .right-group {
    justify-content: flex-end;
  }

  .app-layout {
    padding: 8px;
    gap: 8px;
  }

  .app-layout.settings-collapsed .settings-panel {
    right: 8px;
    top: auto;
    bottom: 8px;
    width: calc(100vw - 16px);
    max-height: 60vh;
  }

  .btn {
    padding: 8px 10px;
    font-size: 13px;
  }

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

  .icon-btn-sm {
    width: 26px;
    height: 26px;
  }

  .sidebar {
    padding: 8px;
    border-radius: 12px;
  }

  .sidebar-org-details summary {
    padding: 4px 6px;
    font-size: 11px;
  }

  .editor-section {
    padding: 8px;
    border-radius: 12px;
  }

  .settings-panel {
    padding: 8px;
  }

  #titleInput {
    font-size: 24px;
  }

  .note-meta {
    padding: 6px 0;
  }
}