:root {
  color-scheme: light;
  --bg: #edf1ef;
  --surface: #ffffff;
  --surface-soft: #f6f8f7;
  --surface-raised: #ffffff;
  --ink: #14231f;
  --ink-soft: #60706b;
  --ink-faint: #8d9a96;
  --line: #dbe3e0;
  --line-strong: #cbd6d2;
  --green: #126b52;
  --green-hover: #0c5944;
  --green-soft: #e6f2ed;
  --green-pale: #f1f8f5;
  --amber: #bd7b19;
  --danger: #b64343;
  --shadow: 0 18px 45px rgba(26, 48, 41, 0.08);
  --shadow-small: 0 8px 24px rgba(24, 45, 38, 0.12);
  --radius: 16px;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  --font-editor: "Noto Sans TC", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111916;
  --surface: #18231f;
  --surface-soft: #1d2a25;
  --surface-raised: #202e29;
  --ink: #e7efec;
  --ink-soft: #a6b6b0;
  --ink-faint: #7f918a;
  --line: #30413b;
  --line-strong: #40534c;
  --green: #4fb792;
  --green-hover: #66c6a3;
  --green-soft: #203d33;
  --green-pale: #1a3028;
  --amber: #e5a849;
  --danger: #ef7d7d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  --shadow-small: 0 8px 26px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 12% -10%, rgba(61, 144, 113, 0.08), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

button,
input {
  border: 0;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 28%, transparent);
  outline-offset: 2px;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.topbar {
  align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 72px;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--green);
  border-radius: 11px;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--green) 24%, transparent);
  display: flex;
  height: 40px;
  justify-content: center;
  position: relative;
  width: 40px;
}

.brand-lock {
  border: 2px solid white;
  border-radius: 3px;
  height: 14px;
  margin-top: 7px;
  position: relative;
  width: 18px;
}

.brand-lock::before {
  border: 2px solid white;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  content: "";
  height: 9px;
  left: 3px;
  position: absolute;
  top: -10px;
  width: 8px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.brand small {
  color: var(--ink-faint);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
  margin-top: 5px;
}

.topbar-actions,
.toolbar-actions,
.file-identity,
.document-stats,
.privacy-note {
  align-items: center;
  display: flex;
}

.topbar-actions {
  gap: 14px;
}

.connection-pill {
  align-items: center;
  background: var(--green-pale);
  border: 1px solid color-mix(in srgb, var(--green) 16%, var(--line));
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  gap: 7px;
  padding: 7px 11px;
}

.connection-pill.offline {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 20%, var(--line));
  color: var(--danger);
}

.status-dot {
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 15%, transparent);
  height: 7px;
  width: 7px;
}

.icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  padding: 0;
  transition: background 150ms ease, border-color 150ms ease;
  width: 38px;
}

.icon-button:hover {
  background: var(--surface-soft);
  border-color: var(--line);
}

.icon-button svg {
  height: 19px;
  width: 19px;
}

.moon-icon,
html[data-theme="dark"] .sun-icon {
  display: none;
}

html[data-theme="dark"] .moon-icon {
  display: block;
}

.workspace {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) 292px;
  margin: 0 auto;
  max-width: 1520px;
  min-height: calc(100vh - 72px);
  padding: 28px clamp(20px, 4vw, 56px) 36px;
}

.document-panel,
.security-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.document-panel {
  display: grid;
  grid-template-rows: auto minmax(480px, 1fr) auto;
  min-height: calc(100vh - 136px);
  overflow: hidden;
}

.document-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 22px;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 18px 14px 20px;
}

.file-identity {
  min-width: 180px;
}

.file-icon {
  align-items: center;
  background: var(--green-soft);
  border-radius: 9px;
  color: var(--green);
  display: flex;
  flex: 0 0 auto;
  height: 38px;
  justify-content: center;
  margin-right: 11px;
  width: 38px;
}

.file-icon svg {
  height: 21px;
  width: 21px;
}

.filename-wrap label {
  color: var(--ink-faint);
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  margin: 0 0 3px 3px;
  text-transform: uppercase;
}

.filename-wrap input {
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 680;
  max-width: 220px;
  min-width: 120px;
  padding: 3px;
  width: min(18vw, 220px);
}

.filename-wrap input:hover,
.filename-wrap input:focus {
  background: var(--surface-soft);
}

.dirty-indicator {
  background: var(--amber);
  border: 2px solid var(--surface);
  border-radius: 50%;
  height: 9px;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 150ms ease;
  width: 9px;
}

.dirty-indicator.visible {
  opacity: 1;
}

.toolbar-actions {
  gap: 7px;
  position: relative;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 680;
  gap: 7px;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button svg {
  height: 17px;
  width: 17px;
}

.button-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.button-ghost:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
  color: var(--ink);
}

.button-primary {
  background: var(--green);
  box-shadow: 0 5px 14px color-mix(in srgb, var(--green) 18%, transparent);
  color: #fff;
}

.button-primary:hover {
  background: var(--green-hover);
}

.button:disabled {
  cursor: wait;
  opacity: 0.66;
}

.menu-button {
  color: var(--ink-soft);
}

.more-menu {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-small);
  min-width: 172px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 10;
}

.more-menu button {
  align-items: center;
  background: transparent;
  border-radius: 7px;
  display: flex;
  font-size: 13px;
  gap: 9px;
  padding: 9px 10px;
  text-align: left;
  width: 100%;
}

.more-menu button:hover {
  background: var(--surface-soft);
}

.more-menu svg {
  color: var(--ink-soft);
  height: 17px;
  width: 17px;
}

.editor-wrap {
  min-height: 0;
  position: relative;
}

#editor {
  background: var(--surface);
  border: 0;
  color: var(--ink);
  font-family: var(--font-editor);
  font-size: 16px;
  height: 100%;
  letter-spacing: 0.01em;
  line-height: 1.85;
  outline: 0;
  padding: clamp(30px, 5vw, 66px) clamp(30px, 8vw, 110px);
  resize: none;
  width: 100%;
}

#editor::placeholder {
  color: var(--ink-faint);
  opacity: 0.72;
}

.drop-overlay {
  align-items: center;
  background: color-mix(in srgb, var(--green-pale) 91%, transparent);
  border: 2px dashed var(--green);
  display: flex;
  inset: 16px;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transform: scale(0.99);
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 5;
}

.drop-overlay.visible {
  opacity: 1;
  transform: scale(1);
}

.drop-overlay div {
  align-items: center;
  color: var(--green);
  display: flex;
  flex-direction: column;
}

.drop-overlay svg {
  height: 38px;
  margin-bottom: 12px;
  width: 38px;
}

.drop-overlay strong {
  font-size: 16px;
}

.drop-overlay span {
  color: var(--ink-soft);
  font-size: 12px;
  margin-top: 5px;
}

.editor-statusbar {
  align-items: center;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  display: flex;
  font-size: 11px;
  justify-content: space-between;
  min-height: 39px;
  padding: 0 20px;
}

.document-stats {
  gap: 10px;
}

.status-divider {
  background: var(--line-strong);
  height: 12px;
  width: 1px;
}

.privacy-note {
  color: var(--green);
  font-weight: 650;
  gap: 5px;
}

.privacy-note svg {
  height: 15px;
  width: 15px;
}

.security-panel {
  align-self: start;
  padding: 24px 22px 21px;
}

.security-heading {
  align-items: center;
  display: flex;
  gap: 12px;
}

.security-emblem {
  align-items: center;
  background: var(--green-soft);
  border-radius: 11px;
  color: var(--green);
  display: flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.security-emblem svg {
  height: 24px;
  width: 24px;
}

.security-heading p,
.security-heading h2 {
  margin: 0;
}

.security-heading p {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.security-heading h2 {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.security-copy {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.75;
  margin: 18px 0 19px;
}

.encryption-stack {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.encryption-stack::before {
  background: var(--line);
  content: "";
  height: calc(100% - 34px);
  left: 15px;
  position: absolute;
  top: 17px;
  width: 1px;
}

.encryption-stack li {
  align-items: center;
  display: flex;
  gap: 11px;
  margin-bottom: 14px;
  position: relative;
}

.encryption-stack li > span {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green);
  display: flex;
  font-size: 8px;
  font-weight: 750;
  height: 31px;
  justify-content: center;
  width: 31px;
  z-index: 1;
}

.encryption-stack strong,
.encryption-stack small {
  display: block;
}

.encryption-stack strong {
  font-size: 12px;
  margin-bottom: 3px;
}

.encryption-stack small {
  color: var(--ink-faint);
  font-size: 10px;
}

.local-card {
  align-items: center;
  background: var(--green-pale);
  border: 1px solid color-mix(in srgb, var(--green) 12%, var(--line));
  border-radius: 10px;
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding: 11px;
}

.local-icon {
  align-items: center;
  color: var(--green);
  display: flex;
}

.local-icon svg {
  height: 21px;
  width: 21px;
}

.local-card strong,
.local-card div span {
  display: block;
}

.local-card strong {
  color: var(--green);
  font-size: 11px;
  margin-bottom: 3px;
}

.local-card div span {
  color: var(--ink-faint);
  font-size: 9px;
}

.shortcut-hint {
  color: var(--ink-faint);
  font-size: 10px;
  margin: 18px 0 0;
  text-align: center;
}

kbd {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--line-strong);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 9px;
  margin-right: 3px;
  padding: 2px 5px;
}

.password-dialog {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
  color: var(--ink);
  max-width: calc(100vw - 32px);
  padding: 0;
  width: 440px;
}

.password-dialog::backdrop {
  background: rgba(7, 17, 13, 0.54);
  backdrop-filter: blur(4px);
}

.password-dialog[open] {
  animation: dialog-in 160ms ease-out;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.password-dialog form {
  padding: 28px;
}

.dialog-icon {
  align-items: center;
  background: var(--green-soft);
  border-radius: 12px;
  color: var(--green);
  display: flex;
  height: 48px;
  justify-content: center;
  margin-bottom: 16px;
  width: 48px;
}

.dialog-icon svg {
  height: 26px;
  width: 26px;
}

.dialog-heading p,
.dialog-heading h2,
.dialog-heading span {
  display: block;
  margin: 0;
}

.dialog-heading p {
  color: var(--green);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.11em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.dialog-heading h2 {
  font-size: 21px;
  letter-spacing: -0.025em;
}

.dialog-heading span {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
  margin: 7px 0 21px;
}

.selected-file {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  gap: 10px;
  margin: -3px 0 19px;
  padding: 10px 12px;
}

.selected-file[hidden] {
  display: none;
}

.selected-file svg {
  color: var(--green);
  height: 21px;
  width: 21px;
}

.selected-file strong,
.selected-file span {
  display: block;
}

.selected-file strong {
  font-size: 11px;
  max-width: 310px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file span {
  color: var(--ink-faint);
  font-size: 9px;
  margin-top: 2px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 680;
  margin: 0 0 7px 2px;
}

.password-field {
  position: relative;
}

.password-field input {
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 14px;
  height: 44px;
  padding: 0 44px 0 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  width: 100%;
}

.password-field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 12%, transparent);
  outline: 0;
}

.password-toggle {
  align-items: center;
  background: transparent;
  color: var(--ink-faint);
  display: flex;
  height: 40px;
  justify-content: center;
  position: absolute;
  right: 2px;
  top: 2px;
  width: 40px;
}

.password-toggle:hover {
  color: var(--ink);
}

.password-toggle svg {
  height: 18px;
  width: 18px;
}

.confirm-field {
  margin-top: 15px;
}

.confirm-field[hidden] {
  display: none;
}

.password-meter {
  margin: 12px 2px 0;
}

.password-meter[hidden] {
  display: none;
}

.meter-bars {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
}

.meter-bars i {
  background: var(--line);
  border-radius: 9px;
  height: 3px;
  transition: background 150ms ease;
}

.password-meter[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.password-meter[data-score="2"] i:nth-child(-n+2) { background: var(--amber); }
.password-meter[data-score="3"] i:nth-child(-n+3) { background: #5c9c72; }
.password-meter[data-score="4"] i:nth-child(-n+4) { background: var(--green); }

.password-meter > span {
  color: var(--ink-faint);
  display: block;
  font-size: 9px;
  margin-top: 6px;
}

.field-error {
  color: var(--danger);
  font-size: 11px;
  min-height: 15px;
  margin: 9px 2px 0;
}

.dialog-actions {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr 1.55fr;
  margin-top: 6px;
}

.dialog-submit.loading svg {
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.dialog-footnote {
  color: var(--ink-faint);
  font-size: 9px;
  margin: 12px 0 0;
  text-align: center;
}

.toast-region {
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
  position: fixed;
  right: 24px;
  z-index: 100;
}

.toast {
  align-items: center;
  animation: toast-in 180ms ease-out;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-small);
  color: var(--ink);
  display: flex;
  font-size: 12px;
  gap: 9px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
}

.toast::before {
  background: var(--green);
  border-radius: 50%;
  content: "";
  height: 8px;
  width: 8px;
}

.toast.error::before {
  background: var(--danger);
}

.toast.leaving {
  opacity: 0;
  transform: translateY(5px);
  transition: opacity 160ms ease, transform 160ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 250px;
  }

  .button.compact-label span {
    display: none;
  }

  .button.compact-label {
    padding: 0 11px;
  }
}

@media (max-width: 900px) {
  .workspace {
    display: block;
  }

  .document-panel {
    min-height: calc(100vh - 128px);
  }

  .security-panel {
    display: none;
  }

  .button.compact-label span {
    display: inline;
  }
}

@media (max-width: 680px) {
  .topbar {
    height: 62px;
    padding: 0 14px;
  }

  .brand small,
  .connection-label {
    display: none;
  }

  .connection-pill {
    padding: 8px;
  }

  .workspace {
    min-height: calc(100vh - 62px);
    padding: 10px;
  }

  .document-panel {
    border-radius: 12px;
    grid-template-rows: auto minmax(390px, 1fr) auto;
    min-height: calc(100vh - 82px);
  }

  .document-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 11px;
    padding: 12px;
  }

  .filename-wrap {
    flex: 1;
  }

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

  .toolbar-actions {
    display: grid;
    grid-template-columns: auto 1fr 1.25fr auto;
  }

  .toolbar-actions .button {
    padding: 0 9px;
  }

  .button.compact-label span {
    display: none;
  }

  #editor {
    font-size: 15px;
    padding: 28px 22px;
  }

  .editor-statusbar {
    padding: 0 12px;
  }

  #wordCount,
  #wordCount + .status-divider,
  .privacy-note {
    display: none;
  }

  .toast-region {
    bottom: 14px;
    left: 16px;
    right: auto;
  }
}

/* Expanded editing viewport */
.topbar {
  height: 60px;
  padding-inline: clamp(16px, 2.4vw, 34px);
}

.workspace {
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 244px;
  max-width: none;
  min-height: calc(100dvh - 60px);
  padding: 12px;
}

.document-panel {
  height: calc(100dvh - 84px);
  min-height: 560px;
}

.document-toolbar {
  min-height: 64px;
  padding-block: 10px;
}

.editor-wrap {
  min-height: 0;
}

#editor {
  padding: clamp(24px, 3vw, 46px) clamp(24px, 5vw, 72px);
}

.security-panel {
  padding: 19px 17px 17px;
}

@media (max-width: 1180px) {
  .workspace {
    display: block;
  }

  .security-panel {
    display: none;
  }
}

@media (max-width: 680px) {
  .workspace {
    min-height: calc(100dvh - 60px);
    padding: 7px;
  }

  .document-panel {
    height: calc(100dvh - 74px);
    min-height: 500px;
  }

  #editor {
    padding: 22px 18px;
  }
}

@media (max-width: 430px) {
  #openButton span {
    font-size: 0;
  }

  #openButton span::after {
    content: "開啟";
    font-size: 13px;
  }

  #saveButton span {
    font-size: 0;
  }

  #saveButton span::after {
    content: "儲存";
    font-size: 13px;
  }

  .password-dialog form {
    padding: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Server-backed editor additions */
.document-panel {
  display: flex;
  flex-direction: column;
}

.filename-wrap strong {
  display: block;
  font-size: 14px;
  line-height: 22px;
}

.logout-button {
  color: var(--ink-soft);
}

.logout-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.search-bar {
  align-items: center;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 48px;
  padding: 6px 16px;
}

.search-bar[hidden] {
  display: none;
}

.search-bar > svg {
  color: var(--ink-faint);
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.search-bar input {
  background: transparent;
  flex: 1;
  font-size: 13px;
  min-width: 80px;
  outline: 0;
}

.search-bar input::-webkit-search-cancel-button {
  display: none;
}

.search-count {
  color: var(--ink-faint);
  font-size: 10px;
  min-width: 48px;
  text-align: right;
}

.search-nav {
  align-items: center;
  background: transparent;
  border-radius: 7px;
  color: var(--ink-soft);
  display: inline-flex;
  height: 30px;
  justify-content: center;
  padding: 0;
  width: 30px;
}

.search-nav:hover {
  background: var(--surface);
  color: var(--ink);
}

.search-nav svg {
  height: 16px;
  width: 16px;
}

.editor-wrap {
  flex: 1 1 auto;
  min-height: 480px;
}

#editor:disabled {
  cursor: default;
  opacity: 0.52;
}

.loading-cover {
  align-items: center;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  position: absolute;
  z-index: 4;
}

.loading-cover[hidden] {
  display: none;
}

.loading-cover strong {
  font-size: 14px;
  margin-top: 14px;
}

.loading-cover > span {
  color: var(--ink-faint);
  font-size: 10px;
  margin-top: 5px;
}

.loading-mark {
  align-items: center;
  background: var(--green-soft);
  border-radius: 13px;
  display: flex;
  height: 52px;
  justify-content: center;
  width: 52px;
}

.loading-mark span {
  border: 2px solid color-mix(in srgb, var(--green) 22%, transparent);
  border-radius: 50%;
  border-top-color: var(--green);
  height: 22px;
  width: 22px;
  animation: spin 800ms linear infinite;
}

.save-state {
  align-items: center;
  color: var(--green);
  display: flex;
  font-weight: 650;
  gap: 6px;
}

.save-state-dot {
  background: currentColor;
  border-radius: 50%;
  height: 6px;
  width: 6px;
}

.save-state.unsaved {
  color: var(--amber);
}

.transport-card {
  align-items: center;
  background: var(--green-pale);
  border: 1px solid color-mix(in srgb, var(--green) 12%, var(--line));
  border-radius: 10px;
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding: 11px;
}

.transport-card strong,
.transport-card div span {
  display: block;
}

.transport-card strong {
  color: var(--green);
  font-size: 11px;
  margin-bottom: 3px;
}

.transport-card div span {
  color: var(--ink-faint);
  font-size: 9px;
}

.transport-card.insecure {
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 22%, var(--line));
}

.transport-card.insecure .local-icon,
.transport-card.insecure strong {
  color: var(--danger);
}

.security-copy code {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  padding: 2px 4px;
}

.insecure-warning {
  align-items: flex-start;
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 22%, var(--line));
  border-radius: 9px;
  color: var(--danger);
  display: flex;
  font-size: 10px;
  gap: 8px;
  line-height: 1.55;
  margin: -4px 0 18px;
  padding: 10px;
}

.insecure-warning[hidden] {
  display: none;
}

.insecure-warning svg {
  flex: 0 0 auto;
  height: 17px;
  margin-top: 1px;
  width: 17px;
}

.auth-submit {
  margin-top: 5px;
  width: 100%;
}

.auth-submit.loading svg,
.saveButton.loading svg,
#saveButton.loading svg {
  animation: spin 800ms linear infinite;
}

@media (max-width: 680px) {
  .editor-wrap {
    min-height: 390px;
  }

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

  .search-bar {
    padding-inline: 10px;
  }

  .save-state span:last-child {
    display: none;
  }
}

/* Final editor sizing and search highlighting overrides. */
.workspace {
  grid-template-columns: minmax(0, 1fr);
}

.document-panel {
  height: calc(100dvh - 84px);
  min-height: 560px;
}

.editor-wrap {
  min-height: 0;
}

.highlight-layer {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-editor);
  font-size: 16px;
  height: 100%;
  inset: 0;
  letter-spacing: 0.01em;
  line-height: 1.85;
  overflow: hidden;
  overflow-wrap: break-word;
  padding: clamp(24px, 3vw, 46px) clamp(24px, 5vw, 72px);
  pointer-events: none;
  position: absolute;
  tab-size: 8;
  white-space: pre-wrap;
  width: 100%;
  z-index: 0;
  user-select: none;
}

.highlight-layer mark {
  background: color-mix(in srgb, #f2c94c 60%, transparent);
  border-radius: 2px;
  color: inherit;
  margin: 0;
  padding: 1px 0;
}

.highlight-layer mark.active {
  background: color-mix(in srgb, #ed9f28 85%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, #b96a08 45%, transparent);
}

#editor {
  position: relative;
  z-index: 1;
}

.editor-wrap.search-active #editor {
  background: transparent;
  caret-color: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

@media (max-width: 680px) {
  .document-panel {
    height: calc(100dvh - 74px);
    min-height: 500px;
  }

  .editor-wrap {
    min-height: 0;
  }

  .highlight-layer {
    padding: 22px 18px;
  }
}
