:root {
  --paper: #fbfaf7;
  --surface: #ffffff;
  --surface-soft: #f2f7f5;
  --ink: #1f2937;
  --muted: #667085;
  --line: #d9e2df;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #2f855a;
  --coral: #df6b57;
  --amber: #b7791f;
  --shadow: 0 16px 40px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

@supports not (overflow: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}

body.dark-mode {
  --paper: #151a23;
  --surface: #1f2633;
  --surface-soft: #263445;
  --ink: #edf2f7;
  --muted: #a8b3c2;
  --line: #3a4658;
  --blue: #60a5fa;
  --blue-dark: #93c5fd;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.app-shell,
.site-header,
.main-wrap,
.panel,
.write-controls,
.cornell-note,
.markdown-body {
  max-width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(217, 226, 223, 0.9);
  background: rgba(251, 250, 247, 0.94);
  backdrop-filter: blur(14px);
  transition: transform 180ms ease;
  will-change: transform;
}

.site-header.site-header-hidden {
  transform: translateY(calc(-100% - 2px));
}

.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
  color: var(--coral);
  font-weight: 900;
}

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

.nav-link,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 700;
  line-height: 1;
}

.language-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 8px 6px 10px;
  font-size: 0.86rem;
  font-weight: 800;
}

.language-control select {
  min-width: 88px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  outline: none;
}

.button.primary,
.nav-link.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.button.primary:hover,
.nav-link.primary:hover {
  background: var(--blue-dark);
}

.button.ghost,
.nav-link.ghost {
  background: transparent;
}

.button.danger {
  border-color: rgba(223, 107, 87, 0.35);
  color: #b83224;
}

.button.danger.reset-note-button {
  margin-left: auto;
  border-color: #dc2626;
  background: #dc2626;
  color: white;
}

.button.danger.reset-note-button:hover {
  background: #b91c1c;
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.86rem;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.user-box {
  position: relative;
}

.avatar-button {
  display: block;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  padding: 0;
}

.avatar-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  min-width: 190px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
  box-shadow: var(--shadow);
}

.main-wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.worktop {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 24px;
  align-items: start;
}

.write-wrap,
.write-form {
  display: grid;
  gap: 20px;
}

.write-heading {
  display: grid;
  gap: 4px;
}

.write-controls {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.05);
}

.page-band {
  display: grid;
  gap: 20px;
}

.page-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profile-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: end;
}

.profile-panel h2 {
  margin-bottom: 6px;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.profile-panel-copy p:last-child {
  margin-bottom: 0;
}

.profile-form {
  display: grid;
  gap: 10px;
}

.profile-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.compact-status {
  min-height: 18px;
  margin-bottom: 0;
  font-size: 0.86rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 3rem;
  line-height: 1.02;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.metadata-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.45fr);
  gap: 12px;
}

.markdown-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  align-self: start;
  min-width: 0;
  padding: 8px 8px 6px;
}

.markdown-toolbar .button.small {
  min-height: 34px;
  border-color: var(--line);
  background: var(--surface);
  padding: 7px 11px;
  line-height: 1;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 7px;
}

.field-label-row,
.editor-section-title {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.field label,
.section-label {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.field input,
.field textarea,
.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 12px;
  line-height: 1.5;
  outline: none;
}

fieldset.field {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.field textarea {
  min-height: 118px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.field-hint {
  color: var(--muted);
  font-size: 0.84rem;
}

.visibility-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.visibility-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  font-weight: 700;
}

.visibility-option span {
  white-space: nowrap;
}

.visibility-option:has(input:checked) {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: #eff6ff;
}

body.dark-mode .visibility-option:has(input:checked) {
  background: rgba(96, 165, 250, 0.12);
}

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

.anonymous-password-fields {
  display: grid;
  gap: 8px;
}

.modal-dialog {
  width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0;
}

.modal-dialog::backdrop {
  background: rgba(15, 23, 42, 0.44);
}

.modal-dialog:not([open]):not(.is-open) {
  display: none;
}

.modal-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin-bottom: 6px;
  font-size: 1.2rem;
}

.modal-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.password-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.search-form {
  width: min(560px, 100%);
}

.list-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: min(760px, 100%);
  flex-wrap: wrap;
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 8px 6px 12px;
  font-size: 0.9rem;
  font-weight: 800;
}

.sort-control select {
  min-width: 148px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  outline: none;
}

.list-controls .search-form {
  flex: 1 1 420px;
}

.search-input {
  flex: 1 1 260px;
}

.status {
  min-height: 24px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.status[data-tone="error"] {
  color: #b83224;
}

.status[data-tone="success"] {
  color: var(--green);
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 16px;
}

.note-card {
  display: grid;
  grid-template-rows: auto minmax(2.95em, 2.95em) minmax(0, 1fr) auto auto;
  gap: 12px;
  height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.06);
}

.note-card h3 {
  min-width: 0;
  margin-bottom: 0;
  font-size: 1.12rem;
  line-height: 1.3;
}

.note-card h3 a {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-card-fields {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.note-card p {
  margin-bottom: 0;
}

.note-card-field {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  min-width: 0;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.note-card-field-label {
  display: block;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.note-card-field-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.public {
  border-color: rgba(47, 133, 90, 0.25);
  color: var(--green);
}

.pill.private {
  border-color: rgba(183, 121, 31, 0.28);
  color: var(--amber);
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: auto;
}

.cornell-note {
  display: grid;
  grid-template-columns: minmax(170px, 0.38fr) minmax(0, 1fr);
  overflow: hidden;
  border: 2px solid #253245;
  border-radius: 8px;
  background:
    linear-gradient(#ffffff 31px, rgba(37, 50, 69, 0.05) 32px),
    #ffffff;
  background-size: 100% 32px;
  box-shadow: var(--shadow);
}

.cornell-note,
.cornell-title,
.cornell-section,
.cornell-side,
.cornell-main,
.cornell-bottom,
.markdown-field-shell,
.markdown-field-preview {
  min-width: 0;
}

.cornell-editor {
  grid-template-columns: minmax(220px, 0.34fr) minmax(0, 1fr);
  min-height: 760px;
}

.cornell-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2px solid #253245;
  background: #f7fbff;
  padding: 14px 16px;
}

.cornell-editor-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  align-items: end;
  column-gap: 24px;
  padding-right: clamp(28px, 4vw, 56px);
}

.cornell-title-field input {
  min-height: 48px;
  font-size: 1.32rem;
  font-weight: 800;
}

.cornell-editor-meta {
  align-items: end;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.55fr);
}

.cornell-title h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.cornell-metadata {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.cornell-side {
  display: grid;
  align-content: start;
  border-right: 2px solid #253245;
}

.cornell-main {
  min-height: 390px;
}

.cornell-editor .cornell-main {
  min-height: 520px;
}

.cornell-bottom {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 2px solid #253245;
}

.cornell-section {
  min-height: 150px;
  padding: 16px;
}

.cornell-editor .cornell-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.editor-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.editor-section-heading label,
.editor-section-title label {
  color: var(--blue-dark);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.editor-section-heading span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-align: right;
}

.field-help {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  line-height: 1;
}

.field-help summary {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 1px solid rgba(37, 99, 235, 0.28);
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue-dark);
  font-size: 0;
  font-weight: 900;
  line-height: 1;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.field-help summary::before {
  content: "?";
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--blue-dark);
  font-size: 0.78rem;
  line-height: 1;
  transform: translateY(1px);
}

.field-help summary::-webkit-details-marker {
  display: none;
}

.field-help summary::marker {
  font-size: 0;
}

.field-help[open] summary {
  border-color: var(--blue);
  background: rgba(37, 99, 235, 0.14);
}

.field-help-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 14;
  width: min(320px, calc(100vw - 48px));
  max-width: calc(100vw - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 12px;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-align: left;
  text-transform: none;
}

.editor-section-heading > .editor-section-title .field-help-panel {
  left: 0;
}

.field-help-panel p {
  margin-bottom: 8px;
}

.field-help-panel p:last-child {
  margin-bottom: 0;
}

.field-help-example {
  color: var(--muted);
}

.field-help-example span:last-child {
  color: var(--ink);
  font-weight: 800;
}

.cornell-editor textarea {
  min-height: 160px;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 6px 8px 8px;
  resize: vertical;
  line-height: 1.65;
  outline: none;
}

.markdown-field-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 160px;
  height: 100%;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
}

.markdown-field-shell:focus-within {
  border-color: var(--blue);
  background: rgba(37, 99, 235, 0.05);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.24);
}

.markdown-field-shell > textarea,
.markdown-field-shell > .markdown-field-preview {
  grid-area: 2 / 1;
}

.markdown-field-preview {
  min-height: 160px;
  overflow: auto;
  border-radius: 0;
  padding: 6px 8px 8px;
  background: transparent;
  cursor: text;
}

.markdown-field-preview.hidden {
  display: none;
}

.markdown-field-preview.empty::before {
  content: attr(data-empty-label);
  color: var(--muted);
}

.keyword-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-content: flex-start;
}

.keyword-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue-dark);
  padding: 4px 9px;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cornell-editor textarea.hidden {
  display: none;
}

.cornell-editor .markdown-body {
  font-size: 0.98rem;
}

.cornell-editor .cornell-main textarea {
  min-height: 456px;
}

.cornell-editor .cornell-main .markdown-field-shell,
.cornell-editor .cornell-main .markdown-field-preview {
  min-height: 456px;
}

.cornell-editor .cornell-side textarea {
  min-height: 210px;
}

.cornell-editor .cornell-side .markdown-field-shell,
.cornell-editor .cornell-side .markdown-field-preview {
  min-height: 210px;
}

.cornell-editor .cornell-bottom textarea {
  min-height: 178px;
}

.cornell-editor .cornell-bottom .markdown-field-shell,
.cornell-editor .cornell-bottom .markdown-field-preview {
  min-height: 178px;
}

.cornell-editor textarea:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.cornell-section + .cornell-section {
  border-top: 1px solid var(--line);
}

.cornell-bottom .cornell-section + .cornell-section {
  border-top: 0;
  border-left: 2px solid #253245;
}

.cornell-section h3 {
  margin-bottom: 10px;
  color: var(--blue-dark);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cornell-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.cornell-section-header h3 {
  margin-bottom: 0;
}

.section-collapsed .markdown-body {
  display: none;
}

.section-collapsed {
  min-height: auto;
}

.markdown-body {
  color: var(--ink);
  line-height: 1.65;
  overflow-wrap: break-word;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre,
.markdown-body blockquote,
.markdown-body table {
  margin-bottom: 12px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.35rem;
}

.markdown-body li + li {
  margin-top: 4px;
}

.markdown-body blockquote {
  margin-left: 0;
  border-left: 4px solid var(--coral);
  border-radius: 0 8px 8px 0;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 10px 12px;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 18px 0 8px;
  font-size: 1rem;
}

.markdown-body code {
  border-radius: 6px;
  background: #edf2f7;
  padding: 2px 5px;
}

.markdown-body pre {
  position: relative;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: #101827;
  color: #e5edf7;
  padding: 14px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 24px rgba(15, 23, 42, 0.12);
  line-height: 1.7;
}

.markdown-code-block {
  scrollbar-color: rgba(148, 163, 184, 0.7) rgba(15, 23, 42, 0.32);
}

.markdown-body pre[data-language] {
  padding-top: 38px;
}

.markdown-body pre[data-language]::before {
  content: attr(data-language);
  position: absolute;
  top: 9px;
  right: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.84);
  color: #cbd5e1;
  padding: 2px 8px;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.4;
  pointer-events: none;
  text-transform: lowercase;
}

.markdown-body pre code {
  display: block;
  width: max-content;
  min-width: 100%;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
  line-height: inherit;
  white-space: pre;
  tab-size: 2;
}

.mermaid-diagram,
.math-block {
  width: 100%;
  margin-bottom: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.mermaid-diagram svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.mermaid-diagram pre {
  margin-bottom: 0;
}

.math-inline {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: -0.08em;
}

.math-block {
  display: block;
  text-align: center;
}

.math-block .katex-display {
  margin: 0;
}

.youtube-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101827;
  margin-bottom: 12px;
}

.youtube-embed iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.markdown-render-error {
  border-color: rgba(223, 107, 87, 0.4);
  background: rgba(223, 107, 87, 0.08);
  color: #b83224;
  font-weight: 800;
}

.markdown-body img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(70vh, 720px);
  object-fit: contain;
  border-radius: 6px;
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.94rem;
}

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

.markdown-body th {
  background: var(--surface-soft);
  font-weight: 800;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(360px, 1.08fr);
  gap: 24px;
  align-items: start;
}

.compact-preview {
  transform-origin: top center;
}

.full-screen-mode .site-header,
.full-screen-mode .write-heading,
.full-screen-mode .preview-band {
  display: none;
}

.full-screen-mode .worktop {
  grid-template-columns: 1fr;
}

.full-screen-mode .main-wrap {
  width: min(1380px, calc(100% - 24px));
  padding-top: 12px;
}

.full-screen-mode .write-controls {
  position: sticky;
  bottom: 12px;
  z-index: 12;
}

body.dark-mode .cornell-note {
  border-color: #8ea8c8;
  background:
    linear-gradient(var(--surface) 31px, rgba(142, 168, 200, 0.16) 32px),
    var(--surface);
  background-size: 100% 32px;
}

body.dark-mode .cornell-title {
  border-bottom-color: #8ea8c8;
  background: #253044;
}

body.dark-mode .cornell-side {
  border-right-color: #8ea8c8;
}

body.dark-mode .cornell-bottom {
  border-top-color: #8ea8c8;
}

body.dark-mode .cornell-bottom .cornell-section + .cornell-section {
  border-left-color: #8ea8c8;
}

@media print {
  .site-header,
  .panel,
  .write-heading,
  .write-controls,
  .markdown-toolbar,
  .preview-band,
  .page-band > div:first-child {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .main-wrap {
    width: 100%;
    padding: 0;
  }

  .cornell-note {
    box-shadow: none;
    break-inside: avoid;
  }
}

@media (max-width: 860px) {
  .nav-shell,
  .page-title-row,
  .profile-panel,
  .home-layout,
  .worktop {
    grid-template-columns: 1fr;
  }

  .nav-shell {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-actions,
  .auth-area {
    justify-content: flex-start;
  }

  .list-controls {
    justify-content: flex-start;
    width: 100%;
  }

  .list-controls .search-form {
    flex-basis: 100%;
  }

  h1 {
    font-size: 2.2rem;
  }

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

  .cornell-note .cornell-record {
    order: 1;
    border-bottom: 2px solid #253245;
  }

  .cornell-note .cornell-side {
    order: 2;
  }

  .cornell-note .cornell-bottom {
    order: 3;
    border-top: 0;
  }

  body.dark-mode .cornell-note .cornell-record {
    border-bottom-color: #8ea8c8;
  }

  .cornell-editor {
    min-height: auto;
  }

  .cornell-editor .cornell-editor-record {
    order: 1;
  }

  .cornell-editor .cornell-editor-side {
    order: 2;
  }

  .cornell-editor .cornell-editor-bottom {
    order: 3;
  }

  .cornell-editor-title,
  .cornell-editor-meta {
    grid-template-columns: 1fr;
  }

  .cornell-side {
    border-right: 0;
    border-bottom: 2px solid #253245;
  }

  body.dark-mode .cornell-side {
    border-bottom-color: #8ea8c8;
  }

  .cornell-editor .cornell-main {
    border-bottom: 2px solid #253245;
  }

  body.dark-mode .cornell-editor .cornell-main {
    border-bottom-color: #8ea8c8;
  }

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

  .cornell-editor .cornell-bottom {
    border-top: 0;
  }

  .cornell-bottom .cornell-section + .cornell-section {
    border-left: 0;
    border-top: 2px solid #253245;
  }

  body.dark-mode .cornell-bottom .cornell-section + .cornell-section {
    border-top-color: #8ea8c8;
  }

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

  .cornell-editor .cornell-main,
  .cornell-editor .cornell-main .markdown-field-shell,
  .cornell-editor .cornell-main .markdown-field-preview,
  .cornell-editor .cornell-main textarea,
  .cornell-editor .cornell-side .markdown-field-shell,
  .cornell-editor .cornell-side .markdown-field-preview,
  .cornell-editor .cornell-side textarea,
  .cornell-editor .cornell-bottom .markdown-field-shell,
  .cornell-editor .cornell-bottom .markdown-field-preview,
  .cornell-editor .cornell-bottom textarea {
    min-height: 190px;
  }

  .form-actions,
  .visibility-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  }

  .button,
  .nav-link {
    min-width: 0;
    white-space: normal;
  }

  .field-help-panel {
    width: min(300px, calc(100vw - 40px));
  }
}

@media (max-width: 520px) {
  .nav-shell {
    position: relative;
    width: min(100% - 26px, 100%);
    gap: 12px;
    padding: 12px 0;
  }

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

  .nav-actions > .nav-link,
  .nav-actions > .language-control,
  .nav-actions > .auth-area {
    width: 100%;
    min-width: 0;
  }

  body.is-authenticated .nav-shell {
    padding-right: 50px;
  }

  body.is-authenticated .nav-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.is-authenticated .nav-actions > .user-box,
  body.is-authenticated .nav-actions > .auth-area {
    position: absolute;
    top: 12px;
    right: 0;
    width: 38px;
  }

  body.is-authenticated .nav-actions > .language-control {
    display: none;
  }

  body.is-authenticated .auth-area {
    display: block;
  }

  body.is-authenticated .auth-area .user-box {
    display: block;
  }

  .nav-actions > .nav-link,
  .form-actions .button,
  .search-form .button {
    white-space: nowrap;
  }

  .language-control {
    justify-content: space-between;
    gap: 6px;
    padding-inline: 8px;
    font-size: 0.78rem;
  }

  .language-control select {
    min-width: 70px;
    width: min(76px, 50%);
  }

  .auth-area {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .auth-area .button {
    width: 100%;
    min-width: 0;
  }

  .user-menu {
    right: 0;
    min-width: min(230px, calc(100vw - 26px));
  }

  .user-menu .language-control {
    display: flex;
    width: 100%;
    margin-bottom: 2px;
    justify-content: space-between;
  }

  .cornell-title {
    flex-direction: column;
    gap: 10px;
  }

  .cornell-title .pill {
    align-self: flex-start;
  }

  .form-actions,
  .search-form {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .form-actions .button,
  .search-form .button {
    width: 100%;
  }

  .list-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sort-control {
    width: 100%;
    justify-content: space-between;
  }

  .sort-control select {
    min-width: 0;
    width: min(170px, 58%);
  }

  .field-help-panel {
    width: min(300px, calc(100vw - 96px));
    max-width: calc(100vw - 32px);
  }

  .markdown-body pre {
    overflow-x: hidden;
  }

  .markdown-body pre code {
    width: auto;
    min-width: 0;
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .markdown-body th,
  .markdown-body td {
    overflow-wrap: anywhere;
  }

  .search-input {
    min-width: 0;
    flex-basis: auto;
  }
}
