/*! Mob v1.0.1 — a tiny WYSIWYG editor | MIT License | (c) Naked Tuxedo | https://mob.nakedtuxedo.com */

/* =========================================================================
   Theme tokens — override any of these on .mob (or a parent) to theme
   ========================================================================= */
.mob {
  --mob-bg: #ffffff;
  --mob-surface: #fbfbfc;          /* toolbar / footer */
  --mob-fg: #1d1f23;
  --mob-muted: #6b7079;
  --mob-border: #e3e5e9;
  --mob-accent: #18181b;
  --mob-accent-contrast: #ffffff;
  --mob-link: #1d5fa8;
  --mob-btn-bg: transparent;
  --mob-btn-bg-hover: #eef0f3;
  --mob-btn-bg-active: #e4e4e7;
  --mob-btn-fg-active: #18181b;
  --mob-code-bg: rgba(110, 118, 129, .12);
  --mob-pre-bg: #f6f7f9;
  --mob-quote: #c9ced6;
  --mob-danger: #c62828;
  --mob-ring: rgba(24, 24, 27, .14);
  --mob-shadow: 0 10px 30px -8px rgba(16, 24, 40, .18), 0 2px 6px rgba(16, 24, 40, .06);
  --mob-radius: 10px;
  /* --mob-font is left unset on purpose: the editor uses the font of the page it is placed on.
     Set it to give the editor its own font, e.g. .mob { --mob-font: Georgia, serif; } */
  --mob-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --mob-font-size: 16px;
  --mob-line-height: 1.65;
  --mob-sticky-top: 0px;
}

.mob[data-theme="dark"] {
  --mob-bg: #14161b;
  --mob-surface: #181b21;
  --mob-fg: #e6e8ec;
  --mob-muted: #959ba5;
  --mob-border: #2a2f39;
  --mob-accent: #f4f4f5;
  --mob-accent-contrast: #111318;
  --mob-link: #8ab4f8;
  --mob-btn-bg-hover: #232730;
  --mob-btn-bg-active: #2c3039;
  --mob-btn-fg-active: #ffffff;
  --mob-code-bg: rgba(160, 170, 185, .14);
  --mob-pre-bg: #1b1e25;
  --mob-quote: #3a404c;
  --mob-danger: #ef6b6b;
  --mob-ring: rgba(255, 255, 255, .16);
  --mob-shadow: 0 12px 32px -8px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  .mob[data-theme="auto"] {
    --mob-bg: #14161b;
    --mob-surface: #181b21;
    --mob-fg: #e6e8ec;
    --mob-muted: #959ba5;
    --mob-border: #2a2f39;
    --mob-accent: #f4f4f5;
    --mob-accent-contrast: #111318;
    --mob-link: #8ab4f8;
    --mob-btn-bg-hover: #232730;
    --mob-btn-bg-active: #2c3039;
    --mob-btn-fg-active: #ffffff;
    --mob-code-bg: rgba(160, 170, 185, .14);
    --mob-pre-bg: #1b1e25;
    --mob-quote: #3a404c;
    --mob-danger: #ef6b6b;
    --mob-ring: rgba(255, 255, 255, .16);
    --mob-shadow: 0 12px 32px -8px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* =========================================================================
   Frame
   ========================================================================= */
.mob {
  position: relative;
  display: flex;
  flex-direction: column;
  font-family: var(--mob-font);
  font-size: var(--mob-font-size);
  color: var(--mob-fg);
  background: var(--mob-bg);
  border: 1px solid var(--mob-border);
  border-radius: var(--mob-radius);
  transition: border-color .15s ease, box-shadow .15s ease;
  text-align: left;
}
.mob *, .mob *::before, .mob *::after { box-sizing: border-box; }
.mob.is-focused {
  border-color: color-mix(in srgb, var(--mob-accent) 55%, var(--mob-border));
  box-shadow: 0 0 0 3px var(--mob-ring);
}
.mob [hidden] { display: none !important; }

/* =========================================================================
   Toolbar
   ========================================================================= */
.mob-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: var(--mob-surface);
  border-bottom: 1px solid var(--mob-border);
  border-radius: calc(var(--mob-radius) - 1px) calc(var(--mob-radius) - 1px) 0 0;
}
.mob.is-sticky .mob-toolbar {
  position: sticky;
  top: var(--mob-sticky-top);
  z-index: 3;
}
.mob-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--mob-border);
  flex: none;
}
.mob-spacer { flex: 1 1 auto; }

.mob-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  min-width: 32px;
  padding: 0 7px;
  margin: 0;
  border: 0;
  border-radius: 7px;
  background: var(--mob-btn-bg);
  color: var(--mob-fg);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.mob-btn:hover { background: var(--mob-btn-bg-hover); }
.mob-btn:active { transform: translateY(.5px); }
.mob-btn[aria-pressed="true"] {
  background: var(--mob-btn-bg-active);
  color: var(--mob-btn-fg-active);
}
.mob-btn[aria-disabled="true"] {
  opacity: .38;
  cursor: default;
  background: transparent;
  transform: none;
}
.mob-btn:focus-visible,
.mob-menu-item:focus-visible,
.mob-input:focus-visible {
  outline: 2px solid var(--mob-accent);
  outline-offset: 1px;
}
.mob-ico { display: inline-flex; line-height: 0; pointer-events: none; }
.mob-ico svg { display: block; }

/* Text style dropdown */
.mob-block {
  min-width: 128px;
  justify-content: space-between;
  padding: 0 6px 0 10px;
  font-weight: 500;
}
.mob-block .mob-ico { color: var(--mob-muted); }
.mob-block[aria-expanded="true"] { background: var(--mob-btn-bg-hover); }

.mob-menu {
  position: absolute;
  z-index: 20;
  min-width: 220px;
  padding: 4px;
  background: var(--mob-bg);
  border: 1px solid var(--mob-border);
  border-radius: 10px;
  box-shadow: var(--mob-shadow);
  animation: mob-pop .12s ease-out;
}
.mob-menu-item {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--mob-fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mob-menu-item:hover, .mob-menu-item:focus { background: var(--mob-btn-bg-hover); outline: none; }
.mob-menu-item[aria-selected="true"] { color: var(--mob-btn-fg-active); background: var(--mob-btn-bg-active); }
.mob-menu-item kbd,
.mob-tooltip kbd {
  font-family: var(--mob-font);
  font-size: 11px;
  color: var(--mob-muted);
  background: none;
  border: 0;
  padding: 0;
}
.mob-mi-label { font-size: 14px; line-height: 1.3; }
.mob-mi-h1 { font-size: 20px; font-weight: 700; }
.mob-mi-h2 { font-size: 17px; font-weight: 700; }
.mob-mi-h3 { font-size: 15px; font-weight: 650; }
.mob-mi-h4 { font-size: 14px; font-weight: 650; }

/* =========================================================================
   Writing surface
   ========================================================================= */
.mob-body { position: relative; flex: 1 1 auto; }

.mob-editor {
  position: relative;
  padding: 16px 20px;
  outline: none;
  color: var(--mob-fg);
  line-height: var(--mob-line-height);
  overflow-wrap: break-word;
  word-wrap: break-word;
  caret-color: var(--mob-accent);
  tab-size: 4;
}
.mob[data-theme="dark"] .mob-editor { caret-color: var(--mob-link); }

.mob-editor[data-empty="true"]::before {
  content: attr(data-placeholder);
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  margin-top: .5em;
  color: var(--mob-muted);
  opacity: .8;
  pointer-events: none;
  user-select: none;
}

.mob-editor > :first-child { margin-top: .5em; }
.mob-editor > :last-child { margin-bottom: .5em; }

.mob-editor p { margin: 0 0 .85em; }
.mob-editor h1,
.mob-editor h2,
.mob-editor h3,
.mob-editor h4 {
  margin: 1.3em 0 .45em;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.012em;
  color: inherit;
}
.mob-editor h1 { font-size: 1.95em; letter-spacing: -.02em; }
.mob-editor h2 { font-size: 1.5em; }
.mob-editor h3 { font-size: 1.22em; }
.mob-editor h4 { font-size: 1.05em; }

.mob-editor strong, .mob-editor b { font-weight: 700; }
.mob-editor a { color: var(--mob-link); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; cursor: text; }

.mob-editor ul,
.mob-editor ol { margin: 0 0 .85em; padding-left: 1.6em; }
.mob-editor li { margin: .2em 0; padding-left: .2em; }
.mob-editor li > ul,
.mob-editor li > ol,
.mob-editor ul > ul,
.mob-editor ol > ol,
.mob-editor ul > ol,
.mob-editor ol > ul { margin: .2em 0; }
.mob-editor ul ul { list-style-type: circle; }
.mob-editor ul ul ul { list-style-type: square; }
.mob-editor ol ol { list-style-type: lower-alpha; }
.mob-editor li::marker { color: var(--mob-muted); }

.mob-editor blockquote {
  margin: 0 0 .85em;
  padding: .1em 0 .1em 1em;
  border-left: 3px solid var(--mob-quote);
  color: color-mix(in srgb, var(--mob-fg) 78%, var(--mob-bg));
}
.mob-editor blockquote > :last-child { margin-bottom: 0; }

.mob-editor hr {
  height: 1px;
  margin: 1.6em 0;
  border: 0;
  background: var(--mob-border);
}

.mob-editor code {
  padding: .12em .38em;
  border-radius: 5px;
  background: var(--mob-code-bg);
  font-family: var(--mob-mono);
  font-size: .87em;
}
.mob-editor pre {
  margin: 0 0 .85em;
  padding: 12px 14px;
  border: 1px solid var(--mob-border);
  border-radius: 8px;
  background: var(--mob-pre-bg);
  font-family: var(--mob-mono);
  font-size: .87em;
  line-height: 1.55;
  white-space: pre-wrap;
  tab-size: 2;
}
.mob-editor pre code { padding: 0; background: none; font-size: inherit; border-radius: 0; }

.mob-editor ::selection { background: color-mix(in srgb, var(--mob-accent) 22%, transparent); }

/* HTML source view */
.mob-source {
  display: block;
  width: 100%;
  margin: 0;
  padding: 16px 20px;
  border: 0;
  outline: none;
  resize: vertical;
  background: var(--mob-bg);
  color: var(--mob-fg);
  font-family: var(--mob-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* =========================================================================
   Footer
   ========================================================================= */
.mob-footer {
  display: flex;
  justify-content: flex-end;
  padding: 6px 12px;
  border-top: 1px solid var(--mob-border);
  background: var(--mob-surface);
  border-radius: 0 0 calc(var(--mob-radius) - 1px) calc(var(--mob-radius) - 1px);
  color: var(--mob-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   Link bubble
   ========================================================================= */
.mob-bubble {
  position: absolute;
  z-index: 15;
  padding: 4px;
  background: var(--mob-bg);
  border: 1px solid var(--mob-border);
  border-radius: 10px;
  box-shadow: var(--mob-shadow);
  animation: mob-pop .12s ease-out;
}
.mob-bubble-view,
.mob-bubble-edit { display: none; align-items: center; gap: 2px; margin: 0; }
.mob-bubble[data-mode="view"] .mob-bubble-view,
.mob-bubble[data-mode="edit"] .mob-bubble-edit { display: flex; }
.mob-bubble .mob-btn { height: 30px; min-width: 30px; padding: 0 6px; }
.mob-bubble-url {
  max-width: 260px;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--mob-link);
  text-decoration: none;
}
.mob-bubble-url:hover { text-decoration: underline; }
.mob-input {
  width: min(300px, 60vw);
  height: 30px;
  padding: 0 10px;
  margin-right: 2px;
  border: 1px solid var(--mob-border);
  border-radius: 7px;
  background: var(--mob-bg);
  color: var(--mob-fg);
  font: inherit;
  font-size: 13px;
}
.mob-input:focus { outline: none; border-color: var(--mob-accent); box-shadow: 0 0 0 3px var(--mob-ring); }
.mob-input.is-invalid { border-color: var(--mob-danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mob-danger) 20%, transparent); }
.mob-btn-primary { background: var(--mob-accent); color: var(--mob-accent-contrast); }
.mob-btn-primary:hover { background: color-mix(in srgb, var(--mob-accent) 85%, var(--mob-fg)); }

/* =========================================================================
   Tooltip
   ========================================================================= */
.mob-tooltip {
  position: absolute;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--mob-fg);
  color: var(--mob-bg);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity .1s ease, transform .1s ease, visibility 0s linear .1s;
}
.mob-tooltip[data-show="true"] {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .1s ease, transform .1s ease;
}
.mob-tooltip kbd { color: inherit; opacity: .65; }

/* =========================================================================
   States
   ========================================================================= */
.mob.is-readonly .mob-toolbar,
.mob.is-readonly .mob-footer { display: none; }
.mob.is-readonly .mob-editor a { cursor: pointer; }
.mob.is-source .mob-footer { visibility: hidden; }

@keyframes mob-pop {
  from { opacity: 0; transform: translateY(-3px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mob *, .mob *::before, .mob *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 520px) {
  .mob-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .mob-toolbar::-webkit-scrollbar { display: none; }
  .mob-toolbar > * { flex: none; }
  .mob-spacer { flex: 1 0 8px; }
  .mob-block { min-width: 112px; }
  .mob-editor { padding: 14px 16px; }
  .mob-editor[data-empty="true"]::before { top: 14px; left: 16px; }
}

/* Touch screens: 16px text in fields so phones never zoom in when they are tapped */
@media (pointer: coarse) {
  .mob-input,
  .mob-source { font-size: 16px; }
  .mob-input { height: 36px; }
}
