:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f0e8;
  --side: #e8e2d5;
  --side-rail: #ded6c7;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --surface-soft: #f7f2e8;
  --line: #d8cfbe;
  --line-strong: #bfb4a2;
  --text: #24211d;
  --muted: #746d62;
  --muted-strong: #514b43;
  --teal: #17736d;
  --teal-soft: #dceee8;
  --berry: #a43b62;
  --gold: #b47b12;
  --shadow: 0 16px 40px rgba(55, 45, 28, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a18;
  --side: #20241f;
  --side-rail: #1b1f1c;
  --surface: #111412;
  --surface-strong: #1c211e;
  --surface-soft: #242922;
  --line: #343b35;
  --line-strong: #4d564e;
  --text: #ece7dc;
  --muted: #aaa398;
  --muted-strong: #d5cec2;
  --teal: #4eb6aa;
  --teal-soft: #153732;
  --berry: #e17b9d;
  --gold: #d6a54f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: default;
  opacity: 0.58;
}

.shell {
  --side-width: 372px;
  --inspector-width: 420px;
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns 180ms ease;
}

.shell.sidebar-collapsed {
  --side-width: 58px;
}

.side-panel {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  min-width: 0;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--side);
}

.side-toggle {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 9px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 19px;
  font-weight: 760;
}

.side-toggle.active {
  border-color: var(--teal);
  color: var(--teal);
}

.side-rail {
  display: flex;
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border-right: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: var(--side-rail);
  padding: 60px 8px 10px;
}

.rail-actions {
  display: grid;
  gap: 10px;
}

.rail-bottom {
  display: grid;
  gap: 10px;
  transition: opacity 120ms ease;
}

.rail-button,
.account-chip {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
  font-size: 18px;
  font-weight: 760;
}

.rail-button:hover,
.account-chip:hover {
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
}

.account-chip {
  border-color: color-mix(in srgb, var(--teal) 55%, var(--line));
  background: var(--teal);
  color: #fff;
  font-size: 14px;
  transition: opacity 120ms ease;
}

.shell:not(.sidebar-collapsed) .rail-bottom {
  opacity: 0;
  pointer-events: none;
}

.sidebar {
  display: grid;
  min-width: 0;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px 18px 16px;
  opacity: 1;
  transition: opacity 120ms ease;
}

.shell.sidebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
}

.brand {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.search {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 10px;
}

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

.search input,
.title-input,
.tags-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.folder-create {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 8px;
}

.folder-icon-input {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  outline: 0;
}

.folder-create-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 10px;
}

.folder-create-field span {
  color: var(--muted);
}

.folder-create-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.tag-filter-panel {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.tag-filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.tag-clear-button {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.tag-filter-list {
  display: flex;
  min-width: 0;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tag-filter {
  display: inline-grid;
  min-width: 0;
  height: 30px;
  grid-template-columns: minmax(0, auto) auto;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--muted-strong);
  padding: 0 9px;
  font-size: 12px;
}

.tag-filter.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 760;
}

.tag-filter small {
  color: var(--muted);
  font-size: 10px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  font-weight: 700;
}

.icon-button.subtle {
  background: transparent;
}

.memo-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.folder-group {
  margin-bottom: 6px;
}

.folder-group:last-child {
  margin-bottom: 0;
}

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease;
  list-style: none;
}

.folder-header::-webkit-details-marker {
  display: none;
}

.folder-header:hover {
  background: color-mix(in srgb, var(--surface-strong) 80%, transparent);
}

.folder-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

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

.folder-toggle {
  display: inline-block;
  width: 14px;
  text-align: center;
  transition: transform 150ms ease;
  color: var(--muted);
  font-size: 14px;
}

.folder-drag-handle,
.memo-drag-handle {
  display: grid;
  width: 22px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
  font-size: 13px;
  line-height: 1;
}

.folder-drag-handle:hover,
.memo-drag-handle:hover {
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
  color: var(--teal);
}

.folder-icon-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-strong) 62%, transparent);
  font-size: 15px;
  line-height: 1;
}

.folder-group:not([open]) .folder-toggle {
  transform: rotate(-90deg);
}

.folder-group:not([open]) .folder-icon-button {
  opacity: 0.68;
}

.folder-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-strong);
  padding: 2px 6px;
  border-radius: 12px;
}

.folder-delete {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-color: color-mix(in srgb, var(--berry) 30%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
  color: var(--berry);
  font-size: 16px;
  line-height: 1;
}

.folder-delete:hover {
  background: color-mix(in srgb, var(--berry) 10%, var(--surface-strong));
}

.folder-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

.folder-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding-left: 10px;
  margin-left: 12px;
  border-left: 2px solid var(--line);
}

.memo-item {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 6px;
  min-height: 84px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  padding: 12px;
  text-align: left;
}

.memo-open {
  display: grid;
  min-width: 0;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.memo-item.active {
  border-color: var(--teal);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.memo-item.pinned {
  border-color: color-mix(in srgb, var(--gold) 62%, transparent);
}

.memo-title-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.memo-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin-indicator {
  color: var(--gold);
  font-size: 13px;
  line-height: 1;
}

.memo-item p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.memo-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.memo-actions button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-strong) 68%, transparent);
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1;
}

.memo-actions .memo-pin {
  color: var(--gold);
}

.memo-actions .memo-delete {
  border-color: color-mix(in srgb, var(--berry) 34%, var(--line));
  color: var(--berry);
  font-size: 18px;
}

.dragging-source {
  opacity: 0.32;
}

.drag-placeholder {
  border: 1px dashed color-mix(in srgb, var(--teal) 70%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--teal-soft) 74%, transparent);
}

.folder-placeholder {
  margin: 0 0 6px;
}

.memo-placeholder {
  min-height: 76px;
}

.drag-ghost {
  position: fixed;
  z-index: 1200;
  margin: 0;
  pointer-events: none;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
  opacity: 0.94;
}

.folder-drag-ghost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 8px 10px;
}

.memo-drag-ghost {
  border-color: var(--teal);
  background: var(--surface-strong);
}

body.is-dragging-list-item,
body.is-dragging-list-item * {
  cursor: grabbing !important;
  user-select: none;
}

.tag {
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  padding: 2px 7px;
  font-size: 11px;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: stretch;
  gap: 8px;
}

.secondary-button,
.export-link {
  display: block;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  text-align: center;
  text-decoration: none;
}

.theme-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 4px;
}

.theme-toggle button {
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.theme-toggle button.active {
  background: var(--teal);
  color: #fff;
  font-weight: 760;
}

.theme-toggle.wide {
  width: 100%;
}

.account-summary {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 8px;
  text-align: left;
}

.settings-button {
  display: grid;
  min-width: 0;
  min-height: 54px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted-strong);
  padding: 6px;
}

.settings-button span {
  font-size: 18px;
  line-height: 1;
}

.settings-button strong {
  overflow: hidden;
  max-width: 100%;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
}

.account-dot {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.account-summary strong,
.account-summary small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-summary small {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6px minmax(280px, var(--inspector-width));
  min-width: 0;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.shell.inspector-collapsed .workspace {
  grid-template-columns: minmax(0, 1fr);
}

.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  padding: 22px;
}

.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--berry) 48%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--berry) 10%, var(--surface));
  color: var(--text);
  padding: 10px 12px;
  line-height: 1.45;
  font-size: 13px;
}

.inline-link {
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 760;
}

.recovery {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid color-mix(in srgb, var(--gold) 65%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--gold) 18%, var(--surface));
  color: var(--text);
  padding: 10px 12px;
}

.recovery div {
  display: flex;
  gap: 8px;
}

.recovery button {
  border-radius: 7px;
  padding: 6px 10px;
}

.hidden {
  display: none !important;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.title-input {
  height: 48px;
  font-size: 28px;
  font-weight: 750;
}

.toolbar-actions {
  display: flex;
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.save-button {
  min-height: 40px;
  border-color: var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
}

.tags-input {
  height: 38px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.meta-inputs {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  margin-bottom: 14px;
}

.meta-inputs .tags-input {
  margin-bottom: 0;
  height: 38px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.folder-picker {
  position: relative;
  min-width: 0;
}

.folder-picker-button {
  display: grid;
  width: 100%;
  height: 40px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-color: var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 92%, transparent), var(--surface));
  padding: 0 11px;
  text-align: left;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--surface-strong) 70%, transparent) inset;
}

.folder-picker.open .folder-picker-button,
.folder-picker-button:focus-visible {
  border-color: var(--teal);
  outline: 0;
}

.folder-picker-icon,
.folder-picker-option-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-soft);
  font-size: 14px;
  line-height: 1;
}

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

.folder-picker-arrow {
  color: var(--muted);
  font-size: 14px;
  transition: transform 120ms ease;
}

.folder-picker.open .folder-picker-arrow {
  transform: rotate(180deg);
}

.folder-picker-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  max-height: min(280px, 44vh);
  gap: 4px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: 6px;
}

.folder-picker-option {
  display: grid;
  min-width: 0;
  height: 38px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 0 8px;
  text-align: left;
}

.folder-picker-option:hover,
.folder-picker-option.active {
  background: color-mix(in srgb, var(--teal-soft) 70%, transparent);
}

.folder-picker-option span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-picker-option small {
  color: var(--muted);
  font-size: 11px;
}

.folder-icon-popover {
  position: fixed;
  z-index: 1300;
  display: grid;
  width: 148px;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: 8px;
}

.folder-icon-popover-input {
  width: 44px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  outline: 0;
}

.folder-icon-popover-input:focus {
  border-color: var(--teal);
}

.folder-icon-popover-save {
  height: 36px;
  border-color: var(--teal);
  border-radius: 7px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.commit-input {
  flex: 1 1 180px;
  min-width: min(150px, 100%);
  max-width: 280px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.commit-input:focus {
  border-color: var(--teal);
}

#contentInput {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 16px;
  line-height: 1.65;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.inspector {
  display: grid;
  min-width: 0;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, var(--side));
}

.shell.inspector-collapsed .inspector {
  display: none;
}

.inspector-resize {
  width: 6px;
  min-width: 0;
  cursor: col-resize;
  background:
    linear-gradient(
      90deg,
      transparent 0,
      transparent 2px,
      color-mix(in srgb, var(--line) 72%, transparent) 2px,
      color-mix(in srgb, var(--line) 72%, transparent) 4px,
      transparent 4px
    );
}

.inspector-resize:hover,
body.resizing-inspector .inspector-resize {
  background:
    linear-gradient(
      90deg,
      transparent 0,
      transparent 2px,
      var(--teal) 2px,
      var(--teal) 4px,
      transparent 4px
    );
}

.shell.inspector-collapsed .inspector-resize {
  display: none;
}

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

.inspector-header {
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.tabs button {
  height: 36px;
  border-radius: 8px;
  color: var(--muted);
}

.tabs button.active {
  border-color: var(--berry);
  background: color-mix(in srgb, var(--berry) 15%, var(--surface));
  color: var(--berry);
  font-weight: 700;
}

.panel {
  display: none;
  min-height: 0;
  overflow: auto;
  padding: 20px;
}

.panel.active {
  display: block;
}

.preview {
  overflow-wrap: anywhere;
  color: var(--text);
  line-height: 1.65;
}

.preview h1,
.preview h2,
.preview h3 {
  margin: 1.1em 0 0.35em;
  line-height: 1.25;
}

.preview p {
  margin: 0.6em 0;
}

.preview a {
  color: var(--teal);
}

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

.preview pre {
  overflow: auto;
  border-radius: 8px;
  background: #20231f;
  color: #fff9ed;
  padding: 14px;
}

.preview img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.history-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.history-item code {
  color: var(--berry);
  font-size: 12px;
}

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

.history-item button {
  border-radius: 7px;
  padding: 6px 10px;
}

.history-actions {
  display: flex;
  gap: 8px;
  justify-self: start;
}

.history-actions .delete-btn {
  color: var(--berry);
  border-color: color-mix(in srgb, var(--berry) 40%, var(--line));
}

.history-actions .delete-btn:hover {
  background: color-mix(in srgb, var(--berry) 10%, transparent);
}

.account-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 0;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.account-dialog::backdrop {
  background: rgba(18, 16, 12, 0.42);
}

.account-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.account-panel header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  gap: 12px;
}

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

.account-panel header span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-card,
.auth-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  padding: 12px;
}

.account-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.account-card-actions {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.delete-account-link {
  border: 0;
  background: transparent;
  color: var(--berry);
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
}

.login-summary {
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 68px;
  border-color: var(--teal);
}

.login-summary strong {
  font-size: 18px;
}

.login-chip {
  background: var(--berry);
  border-color: var(--berry);
}

.account-identity {
  display: grid;
  min-width: 0;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.provider-badge {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.provider-badge.login-badge {
  background: var(--berry);
}

.delete-account-panel {
  display: grid;
  gap: 10px;
  border: 1px solid color-mix(in srgb, var(--berry) 55%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--berry) 8%, var(--surface));
  padding: 12px;
}

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

.delete-account-panel input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

.delete-account-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.account-identity strong,
.account-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-identity small {
  color: var(--muted);
  font-size: 12px;
}

.auth-fields {
  display: grid;
  gap: 10px;
}

.auth-heading {
  min-height: 42px;
  padding-top: 8px;
}

.auth-heading strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.auth-fields .save-button {
  width: 100%;
  margin-top: 2px;
}

.auth-fields input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

.auth-fields input:focus {
  border-color: var(--teal);
}

.auth-field {
  display: grid;
  gap: 5px;
}

.auth-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  line-height: 1.2;
}

.auth-status.ok {
  color: var(--teal);
}

.auth-status.bad {
  color: var(--berry);
}

.auth-status.pending {
  color: var(--muted);
}

.auth-provider-row {
  display: grid;
}

.google-button {
  display: grid;
  min-height: 40px;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 6px 10px;
  text-decoration: none;
}

.google-button span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: #fff;
  color: #4285f4;
  font-weight: 900;
}

.google-button.disabled {
  opacity: 0.5;
  pointer-events: none;
}

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

.auth-switch {
  margin: -2px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
}

.auth-switch button {
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 12px;
  font-weight: 760;
}

.account-settings-content {
  display: grid;
  gap: 14px;
}

.setting-row,
.field {
  display: grid;
  gap: 8px;
}

.setting-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.field span,
.setting-row span {
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  outline: 0;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.secondary-button.disabled,
.settings-actions .disabled {
  opacity: 0.52;
  pointer-events: none;
}

.secondary-link {
  color: var(--teal);
  text-decoration: none;
}

.secondary-link.disabled {
  color: var(--muted);
  cursor: default;
}

.secondary-button.danger {
  color: var(--berry);
  border-color: color-mix(in srgb, var(--berry) 42%, var(--line));
}

.app-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(260px, calc(100vw - 16px));
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-strong) 92%, var(--text));
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  padding: 6px 9px;
  pointer-events: none;
  transform: translateY(2px);
  transition:
    opacity 70ms ease,
    transform 70ms ease;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.app-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .shell,
  .shell.sidebar-collapsed {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .side-panel {
    position: fixed;
    z-index: 10;
    inset: 0 auto 0 0;
    width: min(372px, 100vw);
    box-shadow: var(--shadow);
  }

  .shell.sidebar-collapsed .side-panel {
    width: 58px;
  }

  .workspace,
  .shell.inspector-collapsed .workspace {
    grid-column: 2;
    width: calc(100vw - 58px);
    max-width: calc(100vw - 58px);
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shell.inspector-collapsed .workspace {
    overflow: hidden;
  }

  .inspector-resize {
    display: none;
  }

  .inspector {
    height: auto;
    min-height: 420px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .shell.inspector-collapsed .inspector {
    display: none;
  }

  #contentInput {
    min-height: 52vh;
  }

  .editor-pane {
    height: auto;
    min-height: 100dvh;
  }
}

@media (max-width: 620px) {
  .editor-pane {
    padding: 14px;
  }

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

  .toolbar-actions {
    justify-content: flex-end;
  }

  .commit-input {
    max-width: none;
  }

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

  .account-card,
  .auth-fields {
    grid-template-columns: 1fr;
  }

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