:root {
  /* ---- Warm paper palette ---- */
  --bg: oklch(97% 0.012 95);
  --bg-2: oklch(95.5% 0.015 92);
  --surface: oklch(99.4% 0.006 95);
  --surface-2: oklch(96.5% 0.014 92);
  --surface-sunken: oklch(94.5% 0.016 92);
  --ink: oklch(26% 0.021 70);
  --ink-strong: oklch(20% 0.024 70);
  --muted: oklch(52% 0.024 74);
  --faint: oklch(64% 0.02 80);
  --line: oklch(89% 0.014 88);
  --line-soft: oklch(92.5% 0.012 90);
  --line-strong: oklch(84% 0.02 86);
  --accent: oklch(53% 0.104 152);
  --accent-strong: oklch(46% 0.11 152);
  --accent-ink: oklch(34% 0.08 152);
  --accent-soft: color-mix(in oklab, var(--accent) 12%, var(--surface));
  --accent-ring: color-mix(in oklab, var(--accent) 32%, transparent);
  --warn: oklch(56% 0.14 38);

  /* ---- Elevation ---- */
  --shadow-xs: 0 1px 2px color-mix(in oklab, var(--ink) 6%, transparent);
  --shadow-sm:
    0 1px 2px color-mix(in oklab, var(--ink) 5%, transparent),
    0 2px 8px -3px color-mix(in oklab, var(--ink) 8%, transparent);
  --shadow-md:
    0 2px 4px -2px color-mix(in oklab, var(--ink) 8%, transparent),
    0 8px 24px -8px color-mix(in oklab, var(--ink) 14%, transparent);
  --shadow-lg:
    0 4px 12px -6px color-mix(in oklab, var(--ink) 12%, transparent),
    0 32px 64px -20px color-mix(in oklab, var(--ink) 26%, transparent);

  /* ---- Shape & motion ---- */
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-pill: 999px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 180ms;

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

::selection {
  background: color-mix(in oklab, var(--accent) 26%, transparent);
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: ui-sans-serif, "Segoe UI", "Source Han Sans SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in oklab, var(--line-strong) 55%, transparent) 1px, transparent 0),
    radial-gradient(120% 80% at 50% -10%, var(--bg-2), transparent 60%),
    var(--bg);
  background-size: 26px 26px, 100% 100%, 100% 100%;
  background-attachment: fixed;
}

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

button {
  cursor: pointer;
}

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

.note-app {
  display: grid;
  grid-template-columns: minmax(268px, 21vw) minmax(0, 1fr);
  min-height: 100vh;
}

/* ============ Sidebar ============ */

.note-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 22px 32px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand-row strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--ink-strong);
}

.brand-row span {
  display: block;
  margin-top: 9px;
  color: var(--faint);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.icon-svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
    color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.icon-button.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 92%, white), var(--accent-strong));
  box-shadow: var(--shadow-sm), inset 0 1px 0 color-mix(in oklab, white 25%, transparent);
}

.icon-button:hover {
  border-color: color-mix(in oklab, var(--accent) 30%, var(--line));
  background: color-mix(in oklab, var(--surface) 60%, var(--surface-2));
  box-shadow: var(--shadow-sm);
}

.icon-button.primary:hover {
  border-color: transparent;
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 96%, white), var(--accent));
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0) scale(.97);
}

.filter-block {
  padding: 20px 0;
  border-top: 1px solid var(--line-soft);
}

.filter-block:first-of-type {
  border-top: 0;
  padding-top: 4px;
}

.block-head,
.list-head,
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.block-head h2 {
  margin: 0;
  color: var(--faint);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.text-button {
  min-height: 32px;
  border: 0;
  border-radius: var(--r-pill);
  color: var(--muted);
  background: transparent;
  padding: 0 10px;
  font-size: .8125rem;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.text-button:hover {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.native-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

/* ============ Calendar ============ */

.calendar-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  padding: 14px;
}

.calendar-nav {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-nav strong {
  text-align: center;
  color: var(--ink-strong);
  font-size: .9375rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.calendar-nav-button {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.calendar-nav-button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--faint);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
}

.calendar-day {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.calendar-day:hover:not(.is-outside) {
  background: var(--surface-2);
}

.calendar-day.is-outside {
  color: color-mix(in oklab, var(--muted) 38%, transparent);
}

.calendar-day.is-today {
  font-weight: 700;
  color: var(--accent-ink);
}

.calendar-day.is-today::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--accent);
  transform: translateX(-50%);
}

.calendar-day.has-notes {
  background: color-mix(in oklab, var(--accent) 10%, var(--surface));
}

.calendar-day.is-selected,
.calendar-day.is-selected:hover {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}

.calendar-day.is-selected.is-today::after {
  background: #fff;
}

.calendar-day i {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--accent);
  font-size: 0;
  font-style: normal;
  line-height: 0;
  overflow: hidden;
}

.calendar-day.is-selected i {
  background: #fff;
}

/* ============ Chips & collections ============ */

.date-dots,
.chip-list,
.collection-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.chip,
.collection-pill {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--muted);
  background: var(--surface);
  padding: 5px 12px;
  text-align: left;
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.chip:hover,
.collection-pill:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.chip.active,
.collection-pill.active {
  border-color: transparent;
  color: var(--accent-ink);
  background: color-mix(in oklab, var(--accent) 16%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--accent-ring);
}

.collection-pill {
  border-radius: var(--r-sm);
}

/* ============ Main list ============ */

.note-main {
  padding: clamp(26px, 4vw, 60px) clamp(24px, 4vw, 60px) 72px;
}

.list-head {
  margin-bottom: 30px;
  align-items: flex-end;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-ink);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 3.2vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1;
  color: var(--ink-strong);
}

.list-head .custom-select-shell {
  width: 148px;
  flex: 0 0 148px;
}

.list-head .custom-select-menu {
  left: auto;
  right: 0;
}

.note-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(286px, 1fr));
  gap: 18px;
  align-items: start;
}

.note-item {
  display: flex;
  flex-direction: column;
  min-height: 188px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  text-align: left;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

@media (hover: hover) {
  .note-item:hover {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--accent) 22%, var(--line));
    box-shadow: var(--shadow-md);
  }
}

.note-item:active {
  transform: translateY(-1px);
}

.note-type-line {
  margin-bottom: 10px;
  color: var(--accent-ink);
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.note-item h3 {
  margin: 0 0 10px;
  color: var(--ink-strong);
  font-size: 1.1rem;
  font-weight: 620;
  letter-spacing: -0.005em;
  line-height: 1.3;
}

.note-excerpt {
  display: -webkit-box;
  margin: 0 0 auto;
  padding-bottom: 16px;
  overflow: hidden;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.6;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}

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

.mini-tags span,
.detail-tags span {
  border: 1px solid color-mix(in oklab, var(--accent) 16%, var(--line));
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  padding: 3px 9px;
  color: var(--accent-ink);
  font-size: .72rem;
  font-weight: 550;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 84px 0;
  color: var(--faint);
  text-align: center;
  font-size: .95rem;
}

/* ============ Detail overlay (shared) ============ */

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 840px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms var(--ease);
}

.detail-overlay.open {
  pointer-events: auto;
  opacity: 1;
}

.detail-backdrop {
  border: 0;
  background: color-mix(in oklab, var(--ink-strong) 32%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.detail-panel {
  height: 100vh;
  margin: 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(24px);
  transition: transform 260ms var(--ease);
}

.detail-overlay.open .detail-panel {
  transform: translateX(0);
}

.detail-topbar {
  height: 62px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

/* ============ Note detail (centered) ============ */

.note-detail-overlay {
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0 clamp(16px, 4vw, 42px);
}

.note-detail-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.note-detail-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1024px, calc(100vw - 32px));
  height: min(100vh, 1080px);
  max-height: 100vh;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  transform: translateY(12px) scale(.994);
  transition: transform 260ms var(--ease);
}

@media (min-width: 901px) {
  .note-detail-panel {
    height: calc(100vh - 48px);
    border-radius: var(--r-lg);
  }
}

.detail-overlay.open .note-detail-panel {
  transform: translateY(0) scale(1);
}

.note-detail-topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: color-mix(in oklab, var(--surface) 86%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.detail-topbar-status {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.detail-mode-label {
  display: none;
}

.note-detail-scroll {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: clamp(28px, 4vw, 52px) clamp(24px, 5vw, 64px) clamp(40px, 6vw, 72px);
}

.note-detail-scroll > * {
  width: 100%;
  max-width: 720px;
}

.detail-view,
.detail-edit {
  width: 100%;
}

.detail-view-head {
  margin: 8px 0 26px;
}

.detail-view-head h2 {
  margin: 0 0 14px;
  color: var(--ink-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -0.012em;
  font-weight: 500;
}

.view-tags {
  margin-bottom: 0;
}

.detail-content-view {
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.8;
}

.detail-content-view p {
  margin: 0 0 1.1em;
}

.detail-content-view p:last-child {
  margin-bottom: 0;
}

.detail-empty-content,
.detail-form-empty {
  color: var(--faint);
  font-size: .9rem;
}

.detail-form-view {
  display: grid;
  gap: 0;
  margin: 26px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.detail-form-item {
  display: grid;
  gap: 6px;
  padding: 15px 18px;
  border-top: 1px solid var(--line-soft);
}

.detail-form-item:first-child {
  border-top: 0;
}

.detail-form-item > span {
  color: var(--faint);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-form-item p {
  margin: 0;
  line-height: 1.6;
}

.detail-value-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-value-tags span {
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 3px 10px;
  font-size: .8125rem;
}

.detail-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.detail-image-grid img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  object-fit: cover;
}

.save-state {
  margin-left: 0;
  color: var(--faint);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  transition: color var(--dur) var(--ease);
}

.save-state.dirty {
  color: var(--warn);
}

.save-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: #fff;
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 92%, white), var(--accent-strong));
  box-shadow: var(--shadow-xs), inset 0 1px 0 color-mix(in oklab, white 22%, transparent);
  padding: 0 16px;
  font-weight: 550;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.save-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.save-button:active {
  transform: translateY(0);
}

.save-button.ghost {
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface);
  box-shadow: none;
}

.save-button.ghost:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--surface-2);
  transform: none;
  box-shadow: var(--shadow-xs);
}

/* ============ Detail (legacy scroll base) ============ */

.detail-scroll {
  height: calc(100vh - 62px);
  overflow: auto;
  padding: clamp(24px, 5vw, 56px);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  color: var(--faint);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.detail-meta > span {
  position: relative;
}

.detail-meta > span + span::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: var(--r-pill);
  background: color-mix(in oklab, var(--faint) 60%, transparent);
  transform: translateY(-50%);
}

.detail-title {
  margin: 14px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.012em;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.reader-card {
  margin: 26px 0 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--accent) 5%, var(--surface));
  padding: 18px 20px;
}

.reader-card blockquote {
  margin: 0 0 12px;
  color: var(--ink-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  line-height: 1.5;
}

.reader-card p {
  margin: 0;
  color: var(--muted);
  font-size: .8125rem;
}

.editor-label {
  display: block;
  margin-bottom: 8px;
  color: var(--faint);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.content-editor {
  width: 100%;
  min-height: 46vh;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  padding: 18px 20px;
  font-size: 1.02rem;
  line-height: 1.8;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.content-editor:focus {
  outline: none;
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ============ Responsive ============ */

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

  .note-sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .detail-backdrop {
    display: none;
  }

  .detail-panel {
    width: 100%;
  }

  .note-detail-overlay {
    padding: 0;
  }

  .note-detail-backdrop {
    display: block;
  }

  .note-detail-panel {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border: 0;
  }
}

@media (max-width: 620px) {
  .note-main {
    padding: 22px 20px 56px;
  }

  .list-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .list-head .custom-select-shell {
    width: 100%;
    flex-basis: auto;
  }
}

.hidden {
  display: none !important;
}

/* ============ Custom select ============ */

.custom-select-shell {
  position: relative;
  width: 100%;
  min-width: 0;
}

.custom-select-trigger {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 0 13px;
  text-align: left;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.custom-select-trigger:hover {
  border-color: var(--line-strong);
}

.custom-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-caret {
  width: 20px;
  height: 20px;
  color: var(--faint);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}

.custom-select-caret .icon-svg {
  width: 15px;
  height: 15px;
}

.custom-select-shell.is-open .custom-select-trigger {
  border-color: var(--accent-ring);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.custom-select-shell.is-open .custom-select-caret {
  color: var(--ink);
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  z-index: 45;
  display: grid;
  gap: 2px;
  min-width: 100%;
  width: max-content;
  max-width: min(320px, 80vw);
  max-height: min(280px, 42vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  padding: 6px;
}

.custom-select-option {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.custom-select-option-label {
  min-width: 0;
  white-space: nowrap;
}

.custom-select-option:hover:not(:disabled),
.custom-select-option:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.custom-select-option.is-selected {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 550;
}

.custom-select-option.is-disabled .custom-select-option-label {
  color: var(--faint);
}

.custom-select-option-lock,
.custom-select-option-check {
  width: 16px;
  height: 16px;
  color: var(--faint);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  margin-left: auto;
}

.custom-select-option-lock .icon-svg,
.custom-select-option-check .icon-svg {
  width: 14px;
  height: 14px;
}

.custom-select-option.is-selected .custom-select-option-check {
  color: var(--accent);
}

.custom-select-empty {
  padding: 10px 12px;
  color: var(--faint);
  font-size: .8125rem;
}

/* ============ Types ============ */

.note-type-line {
  margin-bottom: 10px;
}

.type-create-block .custom-select-shell {
  margin-top: 12px;
}

.type-list,
.type-field-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.type-pill,
.type-field-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  font-size: .8125rem;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.type-field-chip:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.type-pill small,
.type-field-chip small {
  color: var(--faint);
  font-size: .72rem;
}

.type-pill.custom {
  border-color: color-mix(in oklab, var(--accent) 30%, var(--line));
  background: color-mix(in oklab, var(--accent) 7%, var(--surface));
}

.compact-input,
.form-text-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  padding: 8px 12px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.compact-input:focus,
.form-text-input:focus {
  outline: none;
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.compact-input::placeholder,
.form-text-input::placeholder {
  color: var(--faint);
}

.type-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 8px;
}

.type-panel {
  display: flex;
  flex-direction: column;
}

.type-panel-topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
}

.type-panel-title {
  color: var(--ink-strong);
  font-size: .9375rem;
  font-weight: 650;
  text-align: center;
}

.type-panel-scroll {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  padding: 28px clamp(22px, 4vw, 44px) 24px;
}

.type-form-section {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.type-form-section + .type-form-section {
  padding-top: 2px;
}

.type-form-label {
  color: var(--faint);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.type-panel .compact-input,
.type-panel .custom-select-trigger {
  min-height: 42px;
}

.type-panel .custom-select-shell {
  width: 100%;
}

.type-inline-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

.type-inline-actions .save-button {
  min-height: 36px;
  padding: 0 14px;
}

.type-field-list:empty {
  display: none;
}

.type-panel-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 92%, var(--surface-2));
  padding: 16px clamp(18px, 3vw, 28px);
}

.type-panel-footer .save-button {
  min-width: 128px;
  width: auto;
}

/* ============ Title / tag editors ============ */

.title-edit-block {
  display: grid;
  gap: 6px;
  margin: 12px 0 24px;
}

.title-editor,
.tags-editor {
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ink-strong);
  padding: 6px 2px;
  outline-offset: 2px;
  transition: border-color var(--dur) var(--ease);
}

.title-editor {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.2;
}

.tags-editor {
  color: var(--muted);
  font-size: .9rem;
}

.title-editor:hover,
.tags-editor:hover {
  border-bottom-color: var(--line);
}

.title-editor:focus,
.tags-editor:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.title-editor::placeholder,
.tags-editor::placeholder {
  color: var(--faint);
}

/* ============ Form editor / metadata ============ */

.form-editor,
.metadata-card {
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  padding: 18px;
}

.form-field {
  display: grid;
  gap: 9px;
  margin-bottom: 18px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field > span,
.metadata-head {
  color: var(--faint);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--muted);
  padding: 5px 13px;
  font-size: .875rem;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

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

.choice-button.active {
  border-color: transparent;
  color: var(--accent-ink);
  background: color-mix(in oklab, var(--accent) 16%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--accent-ring);
}

.image-input {
  width: 100%;
  color: var(--muted);
  font-size: .8125rem;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.image-preview {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
  padding: 0;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.metadata-card pre {
  max-height: 220px;
  margin: 10px 0 0;
  overflow: auto;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.form-empty {
  color: var(--faint);
  font-size: .9rem;
}

[data-note-runtime="online"] body:has(.duobit-online-activation-screen) {
  min-height: 100vh;
  background: #f6f7f8;
  color: #1f252d;
}

.duobit-online-activation-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.duobit-online-activation-panel {
  width: min(680px, 100%);
  display: grid;
  gap: 24px;
  padding: 28px;
  border: 1px solid rgba(35, 44, 56, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 48px rgba(32, 40, 52, 0.10);
}

.duobit-online-activation-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: #6b7280;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.duobit-online-activation-brand strong {
  color: #202833;
  font-size: 17px;
  letter-spacing: 0;
  text-transform: none;
}

.duobit-online-activation-copy {
  display: grid;
  gap: 10px;
}

.duobit-online-activation-copy h1 {
  margin: 0;
  font-family: ui-sans-serif, "Segoe UI", "Source Han Sans SC", system-ui, sans-serif;
  font-size: 30px;
  line-height: 1.18;
  font-weight: 720;
  letter-spacing: 0;
}

.duobit-online-activation-copy p {
  max-width: 560px;
  margin: 0;
  color: #596273;
  font-size: 15px;
  line-height: 1.65;
}

.duobit-online-activation-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid rgba(35, 44, 56, 0.14);
}

.duobit-online-activation-status div {
  min-width: 0;
  padding: 16px 16px 16px 0;
  display: grid;
  gap: 8px;
}

.duobit-online-activation-status span {
  color: #7b8492;
  font-size: 12px;
}

.duobit-online-activation-status strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #202833;
  font-size: 14px;
  font-weight: 650;
}

.duobit-online-activation-primary {
  justify-self: start;
  height: 40px;
  border: 1px solid #202833;
  border-radius: 8px;
  padding: 0 16px;
  background: #202833;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

@media (max-width: 720px) {
  .duobit-online-activation-screen {
    place-items: stretch;
    align-content: center;
  }

  .duobit-online-activation-copy h1 {
    font-size: 26px;
  }

  .duobit-online-activation-status {
    grid-template-columns: 1fr;
  }

  .duobit-online-activation-status div {
    padding-right: 0;
    border-bottom: 1px solid rgba(35, 44, 56, 0.10);
  }

  .duobit-online-activation-status div:last-child {
    border-bottom: 0;
  }
}
