:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-soft: #eef4ef;
  --ink: #20231f;
  --muted: #6e756c;
  --line: #dce2d8;
  --accent: #16645a;
  --accent-strong: #0f493f;
  --accent-soft: #d9ebe6;
  --warning: #b25a39;
  --shadow: 0 20px 45px rgba(40, 54, 46, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111412;
  --surface: #191f1c;
  --surface-soft: #202923;
  --ink: #f1f5ef;
  --muted: #a4afa7;
  --line: #314039;
  --accent: #61c7b7;
  --accent-strong: #8edbcf;
  --accent-soft: #1e3935;
  --warning: #ff9b73;
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width, 340px) 18px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 34px minmax(0, 1fr);
}

.app-shell.focus-mode {
  grid-template-columns: minmax(0, 1fr);
}

.history-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  overflow: hidden;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-collapsed .history-panel {
  padding-right: 0;
  padding-left: 0;
  border-right: 0;
}

.sidebar-control {
  position: relative;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.sidebar-toggle {
  z-index: 2;
  width: 30px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(40, 54, 46, 0.08);
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.sidebar-resizer {
  position: absolute;
  inset: 0;
  cursor: col-resize;
}

.sidebar-resizer:focus-visible {
  outline: 3px solid rgba(22, 100, 90, 0.2);
  outline-offset: -3px;
}

.sidebar-collapsed .sidebar-resizer {
  display: none;
}

.focus-mode .history-panel,
.focus-mode .sidebar-control,
.focus-mode .editor-toolbar,
.focus-mode .note-meta-panel,
.focus-mode .format-toolbar,
.focus-mode .outline-panel,
.focus-mode .status-bar {
  display: none;
}

body.resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

.panel-header,
.editor-toolbar,
.history-meta,
.status-bar,
.toolbar-actions,
.panel-actions,
.view-tabs,
.filter-row,
.history-actions,
.note-meta-panel,
.note-actions {
  display: flex;
  align-items: center;
}

.panel-header,
.editor-toolbar,
.history-meta,
.status-bar {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--accent);
  text-transform: uppercase;
}

.panel-actions {
  flex-shrink: 0;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.theme-button {
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 20px;
}

.changelog-button {
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 20px;
  font-weight: 900;
}

.search-box,
.filter-row label,
.tag-editor {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input,
.filter-row select,
.tag-editor input,
.title-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
}

.search-box input {
  padding: 12px 14px;
}

.filter-row {
  gap: 10px;
}

.filter-row label {
  flex: 1;
}

.filter-row select,
.tag-editor input {
  padding: 11px 12px;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stats-panel div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.stats-panel strong,
.stats-panel span {
  display: block;
}

.stats-panel strong {
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1.1;
}

.stats-panel span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.storage-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.storage-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.storage-row strong {
  color: var(--accent-strong);
}

.storage-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.storage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.storage-panel.warning {
  border-color: rgba(178, 90, 57, 0.5);
  background: rgba(178, 90, 57, 0.08);
}

.storage-panel.warning .storage-bar span {
  background: var(--warning);
}

.storage-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.search-box input:focus,
.filter-row select:focus,
.tag-editor input:focus,
.title-input:focus,
.editor-surface:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 100, 90, 0.14);
}

.history-meta {
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
}

.history-actions {
  gap: 8px;
}

.history-meta button,
.ghost-button,
.tab-button,
.export-select select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 9px 13px;
}

.history-meta button:hover,
.ghost-button:hover,
.tab-button:hover,
.export-select select:hover {
  color: var(--ink);
  border-color: #bac5b6;
}

.export-select {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.export-select select {
  min-width: 118px;
  height: 38px;
  outline: none;
}

.export-select select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 100, 90, 0.14);
}

.view-tabs {
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tab-button {
  min-width: 54px;
  padding: 7px 10px;
  border-color: transparent;
  background: transparent;
}

.tab-button.active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 5px 16px rgba(40, 54, 46, 0.08);
}

.history-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  gap: 10px;
  width: 100%;
  min-height: 94px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.history-item:hover,
.history-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.history-item.archived {
  opacity: 0.72;
}

.history-item.trashed {
  opacity: 0.78;
  border-style: dashed;
}

.history-item.locked {
  border-style: dashed;
}

.history-item.pinned {
  border-color: var(--accent);
}

.history-restore {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.delete-note,
.restore-note {
  width: 34px;
  height: 34px;
  align-self: start;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.delete-note:hover {
  border-color: rgba(178, 90, 57, 0.28);
  background: rgba(178, 90, 57, 0.14);
  color: var(--warning);
}

.restore-note:hover {
  border-color: rgba(22, 100, 90, 0.28);
  background: rgba(22, 100, 90, 0.14);
  color: var(--accent-strong);
}

.history-item strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item .preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-item .tagline {
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.history-item .search-highlight {
  border-radius: 4px;
  background: rgba(255, 214, 102, 0.72);
  color: var(--ink);
  padding: 0 2px;
}

:root[data-theme="dark"] .history-item .search-highlight {
  background: rgba(255, 214, 102, 0.34);
  color: var(--ink);
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  min-width: 0;
  padding: 30px;
}

.focus-mode .editor-panel {
  min-height: 100vh;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: clamp(14px, 3vw, 42px);
}

.editor-toolbar {
  min-width: 0;
}

.title-input {
  min-width: 0;
  padding: 14px 16px;
  font-size: 24px;
  font-weight: 800;
}

.toolbar-actions {
  flex-shrink: 0;
  gap: 10px;
}

.note-meta-panel {
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tag-editor {
  flex: 1;
}

.note-actions {
  flex-shrink: 0;
  gap: 10px;
}

.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.format-toolbar button {
  min-width: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.format-toolbar button:hover,
.format-toolbar button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.ghost-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button:disabled,
input:read-only,
textarea:read-only {
  cursor: not-allowed;
}

button:disabled {
  opacity: 0.58;
}

.note-locked .editor-surface {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.note-locked .note-input,
.note-locked .title-input,
.note-locked .tag-editor input {
  color: var(--muted);
}

.note-locked .current-line-highlight {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 230px);
  gap: 16px;
  min-height: 0;
}

.workspace[data-view="split"] {
  grid-template-columns: minmax(0, var(--editor-fr, 50fr)) 14px minmax(0, var(--preview-fr, 50fr)) minmax(190px, 230px);
  gap: 0 16px;
}

.workspace[data-view="preview"] {
  grid-template-columns: minmax(0, 1fr) minmax(190px, 230px);
  gap: 16px;
}

.split-resizer {
  display: none;
}

.workspace[data-view="split"] .split-resizer {
  position: relative;
  display: block;
  cursor: col-resize;
}

.workspace[data-view="split"] .split-resizer::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 2px;
  border-radius: 999px;
  background: var(--line);
  content: "";
  transform: translateX(-50%);
}

.workspace[data-view="split"] .split-resizer:hover::before,
.workspace[data-view="split"] .split-resizer:focus-visible::before {
  background: var(--accent);
}

.split-resizer:focus-visible {
  outline: 3px solid rgba(22, 100, 90, 0.16);
  outline-offset: -4px;
}

body.resizing-split {
  cursor: col-resize;
  user-select: none;
}

.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 11px 18px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.primary-button:hover,
.icon-button:hover {
  background: var(--accent-strong);
}

.editor-surface,
.preview-panel {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.7;
  outline: none;
  box-shadow: var(--shadow);
}

.editor-surface {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  overflow: hidden;
}

.editor-surface.is-dragging-image {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(22, 100, 90, 0.14), var(--shadow);
}

.focus-mode .workspace,
.focus-mode .editor-surface,
.focus-mode .note-input {
  min-height: calc(100vh - clamp(28px, 6vw, 84px));
}

.focus-mode .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.note-input {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 420px;
  padding: 24px;
  border: 0;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(4ch - 1px),
    rgba(22, 100, 90, 0.08) calc(4ch - 1px),
    rgba(22, 100, 90, 0.08) 4ch
  );
  background-position: 24px 0;
  background-size: 4ch 100%;
  color: var(--ink);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 16px;
  line-height: 1.7;
  outline: none;
  resize: none;
}

.line-gutter {
  position: relative;
  z-index: 3;
  overflow: hidden;
  padding: 24px 10px 24px 8px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 2.09;
  text-align: right;
  user-select: none;
}

.line-gutter span {
  display: block;
  height: 2.09em;
}

.line-gutter .active-line {
  color: var(--accent-strong);
  font-weight: 900;
}

.current-line-highlight {
  position: absolute;
  right: 0;
  left: 54px;
  z-index: 1;
  background: rgba(22, 100, 90, 0.08);
  pointer-events: none;
}

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

.outline-panel {
  position: sticky;
  top: 30px;
  align-self: start;
  max-height: calc(100vh - 60px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.outline-header {
  margin-bottom: 10px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.outline-section {
  display: grid;
  gap: 10px;
}

.outline-section + .outline-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.outline-list {
  display: grid;
  gap: 4px;
}

.outline-link {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 8px;
  text-align: left;
}

.outline-link:hover,
.outline-link:focus-visible {
  background: var(--surface-soft);
  outline: none;
}

.outline-link span {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-link small,
.outline-empty {
  color: var(--muted);
  font-size: 12px;
}

.outline-link.level-2 {
  padding-left: 18px;
}

.outline-link.level-3 {
  padding-left: 30px;
}

.outline-empty {
  margin: 0;
  line-height: 1.6;
}

.knowledge-group {
  display: grid;
  gap: 7px;
}

.knowledge-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.knowledge-list {
  display: grid;
  gap: 6px;
}

.knowledge-link {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 8px 9px;
  text-align: left;
}

.knowledge-link:hover,
.knowledge-link:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.knowledge-link span {
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-link small {
  color: var(--muted);
  font-size: 11px;
}

.knowledge-link.missing {
  border-style: dashed;
  background: transparent;
}

.knowledge-graph {
  position: relative;
  height: 240px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: radial-gradient(circle at center, var(--surface-soft), var(--surface));
}

.knowledge-graph svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.knowledge-graph line {
  stroke: var(--line);
  stroke-width: 2;
}

.graph-node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
}

.graph-node:hover,
.graph-node:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(22, 100, 90, 0.16);
}

.graph-node.active {
  width: 54px;
  height: 54px;
  background: var(--accent);
  color: #fff;
}

.graph-node.missing {
  border-style: dashed;
  color: var(--muted);
}

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

.workspace[data-view="edit"] .preview-panel,
.workspace[data-view="edit"] .split-resizer,
.workspace[data-view="preview"] .split-resizer,
.workspace[data-view="preview"] .editor-surface {
  display: none;
}

.preview-panel h1,
.preview-panel h2,
.preview-panel h3 {
  margin: 0 0 14px;
  line-height: 1.22;
}

.preview-panel h1 {
  font-size: 30px;
}

.preview-panel h2 {
  font-size: 24px;
}

.preview-panel h3 {
  font-size: 20px;
}

.preview-panel p,
.preview-panel ul,
.preview-panel pre,
.preview-panel .table-wrap {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.75;
}

.preview-panel ul {
  padding-left: 22px;
}

.preview-panel code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--accent-strong);
}

.preview-panel .code-block {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.preview-panel .code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.preview-panel .code-toolbar button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.preview-panel .code-toolbar button:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.preview-panel .code-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.preview-panel .code-note {
  color: var(--muted);
  font-weight: 700;
}

.preview-panel pre {
  overflow: auto;
  padding: 16px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface-soft);
}

.preview-panel pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
}

.preview-panel .code-line {
  display: block;
  min-height: 1.65em;
  padding: 0 4px;
  border-radius: 4px;
}

.preview-panel .code-line.source-line-highlight {
  background: rgba(22, 100, 90, 0.16);
}

.preview-panel .code-output {
  min-height: 38px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.preview-panel .code-output:empty {
  display: none;
}

.preview-panel .code-output.error {
  color: var(--warning);
}

.preview-panel .code-output iframe {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-panel img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.preview-panel .table-wrap {
  overflow: auto;
}

.preview-panel table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.preview-panel th,
.preview-panel td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.preview-panel th {
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.preview-panel a {
  color: var(--accent-strong);
  font-weight: 700;
}

.preview-panel .wiki-link {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 2px 9px;
  font-weight: 900;
  vertical-align: baseline;
}

.preview-panel .wiki-link:hover,
.preview-panel .wiki-link:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.preview-panel .wiki-link.missing {
  border-style: dashed;
  background: transparent;
  color: var(--muted);
}

.preview-panel .source-highlight {
  outline: 3px solid rgba(22, 100, 90, 0.22);
  outline-offset: 4px;
  transition: outline-color 0.2s ease;
}

.preview-panel .code-line.source-highlight {
  outline-offset: 1px;
}

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

.status-bar {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.focus-exit-button[hidden] {
  display: none;
}

.focus-exit-button {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 15;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.focus-exit-button:hover,
.focus-exit-button:focus-visible {
  background: var(--accent-strong);
  outline: none;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 20, 18, 0.52);
}

.changelog-modal {
  width: min(720px, 100%);
  max-height: min(82vh, 720px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal-header,
.changelog-entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.modal-header h2,
.changelog-entry h3 {
  margin: 0;
  line-height: 1.2;
}

.modal-header h2 {
  font-size: 28px;
}

.modal-copy {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

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

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

.danger-button:hover,
.danger-button:focus-visible {
  background: #8f4329;
}

.changelog-list {
  display: grid;
  gap: 14px;
}

.changelog-entry {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.changelog-entry h3 {
  font-size: 18px;
}

.changelog-entry time {
  flex-shrink: 0;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.changelog-entry ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.changelog-entry li + li {
  margin-top: 6px;
}

.version-list {
  display: grid;
  gap: 12px;
}

.version-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.version-item h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.version-item time {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.version-item p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.version-actions {
  display: flex;
  gap: 8px;
}

.version-diff {
  margin-top: 12px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.version-diff[hidden] {
  display: none;
}

.diff-summary {
  display: grid;
  gap: 4px;
}

.diff-line {
  padding: 5px 7px;
  border-radius: 6px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.diff-line.added {
  background: rgba(22, 100, 90, 0.12);
  color: var(--accent-strong);
}

.diff-line.removed {
  background: rgba(178, 90, 57, 0.12);
  color: var(--warning);
}

.import-preview-list {
  display: grid;
  gap: 10px;
  max-height: 340px;
  overflow: auto;
}

.import-preview-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.import-preview-item h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.import-preview-item p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.5;
}

.import-preview-item small {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .app-shell.focus-mode {
    grid-template-columns: 1fr;
  }

  .history-panel {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 20px;
  }

  .sidebar-control {
    display: none;
  }

  .sidebar-collapsed .history-panel {
    display: flex;
    padding: 20px;
    border-bottom: 1px solid var(--line);
  }

  .editor-panel {
    min-height: 58vh;
    padding: 20px;
  }

  .focus-mode .editor-panel {
    min-height: 100vh;
    padding: 12px;
  }

  .editor-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .note-meta-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .note-actions button {
    flex: 1;
  }

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

  .toolbar-actions > button {
    flex: 1;
  }

  .export-select {
    flex: 1 1 150px;
  }

  .export-select select {
    width: 100%;
  }

  .view-tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  .title-input {
    font-size: 20px;
  }

  .workspace[data-view="split"] {
    grid-template-columns: minmax(0, var(--editor-fr, 50fr)) 14px minmax(0, var(--preview-fr, 50fr));
    gap: 0;
  }

  .outline-panel {
    display: none;
  }

  .workspace[data-view="split"] .split-resizer {
    position: relative;
    display: block;
    cursor: col-resize;
  }

  .editor-surface,
  .preview-panel {
    min-height: 48vh;
  }

  .note-input,
  .preview-panel {
    font-size: 16px;
  }

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

  .modal-backdrop {
    align-items: end;
    padding: 12px;
  }

  .changelog-modal {
    max-height: 86vh;
    padding: 18px;
  }

  .modal-header,
  .changelog-entry-header {
    align-items: stretch;
    flex-direction: column;
  }
}
