:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffdf8;
  --panel-soft: rgba(255, 253, 248, 0.78);
  --text: #171717;
  --muted: #68645d;
  --border: #ded8cc;
  --accent: #2f6fed;
  --accent-soft: rgba(47, 111, 237, 0.12);
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  --blur-shadow: 0 12px 36px rgba(28, 25, 23, 0.16);
}

:root[data-theme="dark"],
:root[data-theme="auto"][data-resolved-theme="dark"] {
  color-scheme: dark;
  --bg: #11100f;
  --panel: #1b1a18;
  --panel-soft: rgba(27, 26, 24, 0.74);
  --text: #f4f1eb;
  --muted: #aaa39a;
  --border: #35312c;
  --accent: #8bb4ff;
  --accent-soft: rgba(139, 180, 255, 0.15);
  --danger: #ffb4ab;
  --shadow: none;
  --blur-shadow: 0 16px 40px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 0.18em;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0;
  gap: 12px;
}

.app-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 44px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--text);
  font-weight: 780;
  letter-spacing: -0.035em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.06);
  color: var(--accent);
  flex: 0 0 auto;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note-row {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.note-url {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.96rem;
}

.save-status {
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.save-status[data-state="error"] {
  color: var(--danger);
}

.save-status--mobile {
  display: none;
  margin-left: auto;
  text-align: right;
}

.action-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.action-button,
.theme-button,
.mobile-action-button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 999px;
  padding: 7px 13px;
  white-space: nowrap;
}

.action-button:hover,
.theme-button:hover,
.mobile-action-button:hover {
  border-color: var(--accent);
}

.action-icon {
  color: var(--accent);
  font-weight: 700;
}

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

.editor {
  width: 100%;
  height: 100%;
  min-height: 60vh;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 24px;
  line-height: 1.6;
  outline: none;
}

.editor:focus {
  border-color: var(--accent);
}

.site-footer {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2px 0 4px;
}

.footer-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: color-mix(in srgb, var(--panel) 74%, transparent);
}

.theme-button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
}

.theme-button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
}

.mobile-action-bar {
  display: none;
}

.page-shell {
  width: min(820px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
}

.page-header {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}

.content-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 26px;
  line-height: 1.65;
}

.content-card h1 {
  margin-top: 0;
  letter-spacing: -0.04em;
}

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

.page-footer {
  margin-top: 18px;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    min-height: 100dvh;
    padding: 10px 0 calc(88px + env(safe-area-inset-bottom));
    gap: 10px;
  }

  .app-header {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .brand {
    font-size: 1rem;
  }

  .brand-icon {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .note-row {
    width: 100%;
  }

  .note-url {
    font-size: 0.9rem;
  }

  .save-status--mobile {
    display: block;
    flex: 0 0 auto;
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .desktop-actions,
  .save-status--desktop {
    display: none;
  }

  .editor {
    min-height: 67dvh;
    border-radius: 16px;
    padding: 18px;
  }

  .footer-topline {
    justify-content: center;
  }

  .footer-links {
    justify-content: center;
    text-align: center;
    gap: 8px 12px;
  }

  .mobile-action-bar {
    position: fixed;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, minmax(72px, 1fr));
    gap: 8px;
    width: min(340px, calc(100% - 28px));
    transform: translateX(-50%);
    border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
    border-radius: 26px;
    padding: 8px;
    background: var(--panel-soft);
    box-shadow: var(--blur-shadow);
    backdrop-filter: blur(18px) saturate(1.35);
    -webkit-backdrop-filter: blur(18px) saturate(1.35);
  }

  .mobile-action-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    border-radius: 19px;
    background: color-mix(in srgb, var(--panel) 58%, transparent);
    font-size: 0.78rem;
    color: var(--text);
  }

  .mobile-action-icon {
    color: var(--accent);
    font-size: 1rem;
    line-height: 1;
  }
}

@media (max-width: 390px) {
  .brand-text {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .note-url {
    font-size: 0.84rem;
  }

  .theme-button {
    padding-inline: 8px;
  }
}


.product-hero {
  display: grid;
  gap: 14px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.product-hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.075em;
}

.lead {
  max-width: 66ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 999px;
  padding: 8px 15px;
  text-decoration: none;
}

.primary-link {
  background: var(--accent);
  color: #fff;
}

.secondary-link {
  border: 1px solid var(--border);
  background: var(--panel);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.feature-grid article,
.content-section {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  padding: 18px;
}

.feature-grid h2,
.content-section h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  letter-spacing: -0.025em;
}

.feature-grid p,
.content-section p {
  margin: 0;
  color: var(--muted);
}

.content-section {
  margin-top: 12px;
}

.content-section ol {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
}

.content-section li + li {
  margin-top: 6px;
}

code {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--accent-soft);
  padding: 0.08em 0.35em;
  color: var(--text);
  font-size: 0.92em;
}

@media (max-width: 760px) {
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .product-hero h1 {
    font-size: clamp(2rem, 13vw, 3rem);
  }

  .lead {
    font-size: 1rem;
  }
}

/* Product UI update */
.editor-wrap {
  position: relative;
  min-height: 0;
}

.editor,
.editor-preview {
  width: 100%;
  height: 100%;
  min-height: 60vh;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 24px;
  line-height: 1.6;
  outline: none;
}

.editor-preview {
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}

.editor-preview a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
}

.editor-preview.is-empty::before {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
  content: attr(data-placeholder);
}

.editor-wrap[data-mode="edit"] .editor-preview,
.editor-wrap[data-mode="preview"] .editor {
  display: none;
}

.note-stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: -2px;
}

.note-stats strong {
  color: var(--text);
  font-weight: 650;
}

.footer-links {
  justify-content: center;
  text-align: center;
}

.page-footer .footer-topline {
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .app-shell {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .editor,
  .editor-preview {
    min-height: 67dvh;
    border-radius: 16px;
    padding: 18px;
  }

  .note-stats {
    justify-content: center;
    gap: 6px 10px;
    font-size: 0.76rem;
  }

  .page-footer .footer-topline {
    justify-content: flex-end;
  }

  .mobile-action-bar {
    grid-template-columns: repeat(3, minmax(54px, 1fr));
    gap: 5px;
    width: min(270px, calc(100% - 34px));
    border-radius: 22px;
    padding: 6px;
    background: color-mix(in srgb, var(--panel-soft) 72%, transparent);
    border-color: color-mix(in srgb, var(--border) 64%, transparent);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(24px) saturate(1.45);
    -webkit-backdrop-filter: blur(24px) saturate(1.45);
  }

  .mobile-action-button {
    min-height: 38px;
    border-radius: 16px;
    border-color: color-mix(in srgb, var(--border) 36%, transparent);
    background: color-mix(in srgb, var(--panel) 36%, transparent);
    font-size: 0.69rem;
    line-height: 1.1;
  }

  .mobile-action-icon {
    font-size: 0.86rem;
  }
}

/* Browser-native feature update */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  clip-path: inset(50%) !important;
}

.drop-overlay {
  position: absolute;
  inset: 14px;
  z-index: 10;
  display: none;
  place-items: center;
  border: 1.5px dashed var(--accent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-soft) 84%, transparent);
  color: var(--accent);
  font-weight: 760;
  letter-spacing: -0.02em;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

.editor-wrap[data-dragging="true"] .drop-overlay {
  display: grid;
}

.action-button[data-install-app]:not([hidden]),
.mobile-action-button[data-install-app]:not([hidden]) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
}

@media (max-width: 760px) {
  .mobile-action-bar {
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    width: min(326px, calc(100% - 30px));
  }

  .mobile-action-button {
    min-width: 0;
    padding-inline: 4px;
  }
}

@media print {
  :root,
  :root[data-theme="dark"],
:root[data-theme="auto"][data-resolved-theme="dark"] {
    color-scheme: light;
    --bg: #fff;
    --panel: #fff;
    --text: #000;
    --muted: #444;
    --border: #ddd;
    --shadow: none;
  }

  body {
    background: #fff;
  }

  .app-shell,
  .page-shell {
    width: 100%;
    min-height: auto;
    padding: 0;
  }

  .app-header,
  .site-footer,
  .mobile-action-bar,
  .note-stats,
  .drop-overlay,
  .theme-switch,
  .action-group {
    display: none !important;
  }

  .editor-wrap {
    display: block;
  }

  .editor,
  .editor-wrap[data-mode="edit"] .editor {
    display: none !important;
  }

  .editor-preview,
  .editor-wrap[data-mode="edit"] .editor-preview,
  .editor-wrap[data-mode="preview"] .editor-preview {
    display: block !important;
    min-height: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    overflow: visible;
    color: #000;
    background: #fff;
    white-space: pre-wrap;
  }

  .content-card {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }
}


/* Theme/status/mobile action refinements */
.note-stats {
  justify-content: flex-start;
}

.note-stats-save {
  margin-left: auto;
}

.site-footer {
  align-items: stretch;
}

.footer-theme-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.footer-links {
  justify-content: center;
  text-align: center;
}

@media (max-width: 760px) {
  .app-shell {
    padding-bottom: calc(128px + env(safe-area-inset-bottom));
  }

  .note-stats {
    justify-content: center;
  }

  .footer-theme-row {
    justify-content: flex-end;
    padding-bottom: 10px;
  }

  .mobile-action-bar {
    bottom: max(18px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(3, minmax(50px, 1fr));
    width: min(246px, calc(100% - 38px));
    gap: 5px;
    border-radius: 22px;
    padding: 6px;
    background: color-mix(in srgb, var(--panel-soft) 54%, transparent);
    border-color: color-mix(in srgb, var(--border) 46%, transparent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.13);
    backdrop-filter: blur(26px) saturate(1.5);
    -webkit-backdrop-filter: blur(26px) saturate(1.5);
  }

  .mobile-action-button {
    min-height: 38px;
    border-radius: 16px;
    border-color: color-mix(in srgb, var(--border) 30%, transparent);
    background: color-mix(in srgb, var(--panel) 30%, transparent);
    font-size: 0.68rem;
    line-height: 1.08;
    padding: 4px 5px;
  }

  .mobile-action-icon {
    font-size: 0.84rem;
  }
}

/* Editable route, centered theme switch, and New action update */
.note-url-label {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
}

.note-url-input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.96rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
}

.note-url-input:hover,
.note-url-input:focus {
  border-color: color-mix(in srgb, var(--border) 82%, transparent);
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  color: var(--text);
}

.action-button:disabled,
.mobile-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.action-button:disabled:hover,
.mobile-action-button:disabled:hover {
  border-color: var(--border);
}

.footer-theme-row,
.page-footer .footer-theme-row {
  justify-content: center;
}

@media (max-width: 760px) {
  .app-shell {
    padding-bottom: calc(150px + env(safe-area-inset-bottom));
  }

  .note-url-input {
    font-size: 0.9rem;
    padding-left: 0;
  }

  .note-url-input:hover,
  .note-url-input:focus {
    padding-left: 9px;
  }

  .footer-theme-row,
  .page-footer .footer-theme-row {
    justify-content: center;
    padding-bottom: 12px;
  }

  .mobile-action-bar {
    grid-template-columns: repeat(4, minmax(48px, 1fr));
    width: min(318px, calc(100% - 34px));
  }
}


/* Patch: mobile actions, inline route editor, and mobile zoom fixes */
html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

input,
textarea,
select,
button {
  font-size: 16px;
}

.note-url-label {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.note-url-display {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: text;
  font: inherit;
  font-size: 0.96rem;
  padding: 5px 0;
  text-align: left;
  white-space: nowrap;
}

.note-url-display span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-url-display:hover,
.note-url-display:focus-visible {
  color: var(--text);
  outline: none;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 0.18em;
}

.note-url-input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 58%, transparent);
  border-radius: 0;
  padding: 5px 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  box-shadow: none;
}

.note-url-input:hover,
.note-url-input:focus {
  border-color: var(--accent);
  background: transparent;
  color: var(--text);
  padding-left: 0;
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-bottom: calc(118px + env(safe-area-inset-bottom));
  }

  .site-footer {
    margin-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .note-url-display {
    font-size: 16px;
  }

  .note-url-input {
    font-size: 16px;
  }

  .mobile-action-bar {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    transform: none;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: auto;
    max-width: none;
    gap: 6px;
    border-radius: 24px;
    padding: 7px;
    background: color-mix(in srgb, var(--panel-soft) 58%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 48%, transparent);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(28px) saturate(1.45);
    -webkit-backdrop-filter: blur(28px) saturate(1.45);
  }

  .mobile-action-button {
    min-width: 0;
    min-height: 48px;
    border-radius: 18px;
    border-color: color-mix(in srgb, var(--border) 34%, transparent);
    background: color-mix(in srgb, var(--panel) 34%, transparent);
    font-size: 0.78rem;
    line-height: 1.05;
    padding: 5px 3px;
  }

  .mobile-action-icon {
    font-size: 0.96rem;
  }
}


/* Patch: force inline URI editor to leave edit mode after navigation/cache restores */
[data-note-path-input][hidden],
[data-note-path-display][hidden] {
  display: none !important;
}
