:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09;
    --surface: #1c1917;
    --text: #e7e5e4;
    --muted: #a8a29e;
    --border: #292524;
    --accent: #60a5fa;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header, footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

header { border-bottom: 1px solid var(--border); flex-wrap: wrap; }

footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding-block: 6px;
}

.left, .right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.sep { color: var(--muted); }

.doc-id {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}
.status[data-state="online"] .dot { background: var(--ok); }
.status[data-state="offline"] .dot { background: var(--err); }

button, .button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

button:hover, .button:hover { filter: brightness(1.08); }

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#editor {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: 15px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace;
  tab-size: 4;
}

#editor::placeholder { color: var(--muted); }

footer a { color: var(--accent); }
.footer-legal a { color: var(--muted); text-decoration: none; }
.footer-legal a:hover { color: var(--text); }

@media (max-width: 640px) {
  .footer-legal { display: none; }
}

.account-link {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.account-link:hover { color: var(--accent); }
.account-link[hidden] { display: none; }

.expiry { display: inline-flex; align-items: center; gap: 8px; }
.expiry[hidden], .expiry [hidden] { display: none; }

.link-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.link-button:hover { filter: none; text-decoration: underline; }

/* ---------- Anuncios ----------
   Sin «ad» en los nombres: los bloqueadores ocultan esos elementos. */

.side {
  flex: 0 0 320px;
  padding: 16px;
  overflow-y: auto;
}
.side-left { border-right: 1px solid var(--border); }
.side-right { border-left: 1px solid var(--border); }
.side[hidden], .side-fallback[hidden] { display: none; }

@media (max-width: 1199px) {
  .side-left { display: none; }
}

.side-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}
.side-label a { color: var(--accent); }

/* Mensaje de apoyo en lugar del anuncio */
.side[data-fallback] .side-label,
.side[data-fallback] .side-slot { display: none; }
.side[data-fallback="blocked"] .support-unfilled,
.side[data-fallback="unfilled"] .support-blocked { display: none; }

.side-fallback {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.5;
}
.side-fallback p { margin: 0; }
.support-blocked, .support-unfilled, .support-short { font-weight: 600; }
.support-short { display: none; }

.coffee {
  display: block;
  padding: 9px 14px;
  border-radius: 8px;
  background: #ffdd00;
  color: #1c1917;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.coffee:hover { filter: brightness(0.96); }

.side-pro {
  color: var(--accent);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 999px) {
  main { flex-direction: column; }
  .side {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .side-fallback {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 10px 14px;
  }
  /* En móvil, solo una frase corta junto al botón. */
  .side-fallback p:not(.support-unfilled),
  .side-pro { display: none; }
  .side[data-fallback="blocked"] .support-short { display: block; }
}
.warn { color: var(--warn); }

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  justify-content: center;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--warn) 14%, var(--bg));
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.notice[hidden] { display: none; }
.notice a { color: var(--accent); font-weight: 600; }
