/* Notepad page styles. Loaded after site.css; every rule is scoped under
   .notepad-app so nothing leaks into other pages. Light palette reuses the
   site.css custom properties; the dark palette below themes the editor
   surface only (card, tabs, textarea, status bar) via .notepad-dark. */

.notepad-app {
  margin: 0 0 1rem;
}

.notepad-app h1 {
  margin-bottom: 0.35rem;
}

.notepad-app .notepad-lead {
  margin: 0 0 0.9rem;
}

.notepad-app .notepad-surface {
  padding: 0;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Row 1: pad tabs ─────────────────────────────────────────────── */

.notepad-app .notepad-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0.2rem;
  padding: 0.5rem 0.6rem 0;
  background: #f4f2ff;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.notepad-app .notepad-tab {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 220px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 9px 9px 0 0;
  background: transparent;
}

.notepad-app .notepad-tab.active {
  background: var(--card);
  border-color: var(--border);
  position: relative;
  top: 1px;
}

.notepad-app .notepad-tab-label {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.5rem 0.8rem 0.55rem;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 9px 9px 0 0;
}

.notepad-app .notepad-tab:not(.active) .notepad-tab-label:hover {
  color: var(--primary-dark);
  background: rgba(91, 92, 226, 0.08);
}

.notepad-app .notepad-tab.active .notepad-tab-label {
  color: var(--primary);
  padding-right: 0.3rem;
}

.notepad-app .notepad-tab-close {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  margin-right: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.notepad-app .notepad-tab-close:hover {
  background: var(--primary-ghost);
  color: var(--primary-dark);
}

.notepad-app .notepad-tab-new {
  appearance: none;
  cursor: pointer;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin: 0 0.15rem 0.35rem;
  border-radius: 8px;
  border: 1px solid #d6d1fa;
  background: #f1efff;
  color: #5146c5;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notepad-app .notepad-tab-new:hover {
  background: #e3defe;
}

/* ── Row 2: title ────────────────────────────────────────────────── */

.notepad-app .notepad-titlebar {
  padding: 0.8rem 1.1rem 0.15rem;
}

.notepad-app .notepad-title-input {
  width: 100%;
  min-height: 2.3rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 0.1rem 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: inherit;
}

.notepad-app .notepad-title-input:focus-visible {
  outline: none;
  border-bottom-color: var(--focus);
}

.notepad-app .notepad-title-input::placeholder {
  color: #9aa5b1;
  font-weight: 600;
}

/* ── Row 3: the editor ───────────────────────────────────────────── */

.notepad-app .notepad-editor {
  display: block;
  width: 100%;
  min-height: 60vh;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0.85rem 1.1rem 1.1rem;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.6;
  resize: vertical;
}

.notepad-app .notepad-editor:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--focus);
}

.notepad-app .notepad-editor::placeholder {
  color: #9aa5b1;
}

/* ── Row 4: status bar ───────────────────────────────────────────── */

.notepad-app .notepad-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--border);
  background: #fafaff;
}

.notepad-app .notepad-status-left {
  display: flex;
  align-items: baseline;
  gap: 0.35rem 0.9rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.88rem;
  min-width: 0;
}

.notepad-app .notepad-count,
.notepad-app .notepad-save {
  margin: 0;
}

.notepad-app .notepad-save {
  font-weight: 600;
}

.notepad-app .notepad-status-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.notepad-app .notepad-status-actions .btn {
  min-height: 34px;
  min-width: 0;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  border-radius: 7px;
}

.notepad-app .notepad-dark-toggle {
  appearance: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid #d6d1fa;
  background: #f1efff;
  color: #5146c5;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notepad-app .notepad-dark-toggle:hover {
  background: #e3defe;
}

/* ── Share result row ────────────────────────────────────────────── */

.notepad-app .notepad-share-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.1rem;
  border-top: 1px dashed var(--border);
  background: #fafaff;
}

.notepad-app .notepad-app .notepad-editor[hidden] {
  display: none;
}

.notepad-share-row[hidden] {
  display: none;
}

.notepad-app .notepad-share-url {
  flex: 1 1 220px;
  width: auto;
  min-height: 2.4rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: inherit;
}

.notepad-app .notepad-share-row .btn {
  min-height: 2.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

/* Attention pulse when the share link appears; an inset overlay so the
   same animation reads correctly on the light and dark row backgrounds. */
.notepad-app .notepad-share-reveal {
  animation: notepad-share-pulse 1.2s ease-out 1;
}

@keyframes notepad-share-pulse {
  0% {
    box-shadow: inset 0 0 0 999px rgba(124, 108, 255, 0.22);
  }
  100% {
    box-shadow: inset 0 0 0 999px rgba(124, 108, 255, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .notepad-app .notepad-share-reveal {
    animation: none;
  }
}

.notepad-app .notepad-error {
  margin: 0;
  padding: 0.6rem 1.1rem 0.9rem;
  font-size: 0.92rem;
  color: #b3261e;
}

/* ── Share result modal ──────────────────────────────────────────── */
/* Centered on purpose: anchor ads pinned to the bottom of the screen
   can cover content brought in at the viewport edge, so the link is
   presented mid-screen instead of scrolled to. */

.notepad-modal-overlay {
  position: fixed;
  inset: 0;
  /* Above the mobile tabbar (2147483000 in site.css). Anchor-ad iframes
     can sit at the int32 max where no z-index wins, so the bottom padding
     below also reserves space to keep the card clear of bottom-pinned UI. */
  z-index: 2147483100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1rem calc(2rem + 56px + env(safe-area-inset-bottom, 0px));
  background: rgba(24, 22, 44, 0.55);
}

.notepad-modal-overlay[hidden] {
  display: none;
}

/* Keep the page still while the dialog is open. */
body.notepad-modal-open {
  overflow: hidden;
}

.notepad-modal {
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  overflow: auto;
  padding: 1.25rem 1.4rem 1.1rem;
  border-radius: 14px;
  background: #fff;
  color: #1d1e24;
  box-shadow: 0 18px 48px rgba(20, 18, 40, 0.35);
}

.notepad-modal-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.notepad-modal-meta {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  color: #5a5c66;
}

.notepad-modal-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.notepad-modal-row .btn {
  min-height: 2.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

.notepad-modal-close {
  display: block;
  margin-left: auto;
}

.notepad-modal.notepad-dark {
  background: #1f2128;
  color: #e7e8ee;
}

.notepad-modal.notepad-dark .notepad-modal-meta {
  color: #a6a8b4;
}

/* The modal's URL input inherits its dark styling from the shared
   .notepad-app .notepad-dark .notepad-share-url rule further down. */

/* ── Dark mode: editor surface only ──────────────────────────────── */

.notepad-app .notepad-surface.notepad-dark {
  background: #1f2128;
  border-color: #3a3d4a;
  color: #e7e8ee;
}

.notepad-app .notepad-dark .notepad-tabs {
  background: #17181d;
  border-bottom-color: #3a3d4a;
}

.notepad-app .notepad-dark .notepad-tab.active {
  background: #1f2128;
  border-color: #3a3d4a;
}

.notepad-app .notepad-dark .notepad-tab-label {
  color: #9aa0b0;
}

.notepad-app .notepad-dark .notepad-tab:not(.active) .notepad-tab-label:hover {
  color: #c3c5ff;
  background: rgba(191, 194, 255, 0.1);
}

.notepad-app .notepad-dark .notepad-tab.active .notepad-tab-label {
  color: #bfc2ff;
}

.notepad-app .notepad-dark .notepad-tab-close {
  color: #9aa0b0;
}

.notepad-app .notepad-dark .notepad-tab-close:hover {
  background: rgba(191, 194, 255, 0.14);
  color: #e7e8ee;
}

.notepad-app .notepad-dark .notepad-tab-new,
.notepad-app .notepad-dark .notepad-dark-toggle {
  background: #262835;
  border-color: #3a3d4a;
  color: #bfc2ff;
}

.notepad-app .notepad-dark .notepad-tab-new:hover,
.notepad-app .notepad-dark .notepad-dark-toggle:hover {
  background: #2e3140;
}

.notepad-app .notepad-dark .notepad-title-input,
.notepad-app .notepad-dark .notepad-editor {
  color: #e7e8ee;
  caret-color: #bfc2ff;
}

.notepad-app .notepad-dark .notepad-title-input::placeholder,
.notepad-app .notepad-dark .notepad-editor::placeholder {
  color: #7c8294;
}

.notepad-app .notepad-dark .notepad-statusbar,
.notepad-app .notepad-dark .notepad-share-row {
  background: #1a1b21;
  border-top-color: #3a3d4a;
}

.notepad-app .notepad-dark .notepad-status-left {
  color: #9aa0b0;
}

.notepad-app .notepad-dark .btn-subtle {
  background: #262835;
  color: #bfc2ff;
  border-color: #3a3d4a;
}

.notepad-app .notepad-dark .btn-subtle:hover {
  background: #2e3140;
}

.notepad-app .notepad-dark .notepad-share-url {
  background: #17181d;
  border-color: #3a3d4a;
  color: #e7e8ee;
}

.notepad-app .notepad-dark .notepad-error {
  color: #ffb4ab;
}

/* ── Mobile ──────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .notepad-app .notepad-editor {
    min-height: 55vh;
    font-size: 1rem;
    padding: 0.8rem 0.85rem 1rem;
  }

  .notepad-app .notepad-titlebar {
    padding: 0.7rem 0.85rem 0.1rem;
  }

  .notepad-app .notepad-title-input {
    font-size: 1.2rem;
  }

  .notepad-app .notepad-statusbar,
  .notepad-app .notepad-share-row {
    padding: 0.55rem 0.85rem;
  }

  .notepad-app .notepad-status-actions {
    width: 100%;
  }

  .notepad-app .notepad-status-actions .btn {
    flex: 1 1 auto;
  }

  .notepad-app .notepad-status-actions .notepad-dark-toggle {
    flex: 0 0 auto;
  }
}
