@font-face { font-family: "Inter"; font-weight: 400 600; font-style: normal; font-display: swap; src: url("/assets/fonts/inter.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 600 700; font-style: normal; font-display: swap; src: url("/assets/fonts/sora.woff2") format("woff2"); }

:root {
  --bg: #000; --fg: #f2f2f2; --muted: #8a8a8a; --line: #2a2a2a;
  --red: #ff1a1a; --red-dark: #b30000;
  --icon-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238a8a8a'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10Zm0 2c-4.4 0-8 2.2-8 5v1h16v-1c0-2.8-3.6-5-8-5Z'/%3E%3C/svg%3E");
  --icon-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238a8a8a'%3E%3Cpath d='M17 9V7a5 5 0 0 0-10 0v2H5v12h14V9h-2Zm-8-2a3 3 0 0 1 6 0v2H9V7Z'/%3E%3C/svg%3E");
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238a8a8a'%3E%3Cpath d='M10 2a8 8 0 1 0 4.9 14.3l5.4 5.4 1.4-1.4-5.4-5.4A8 8 0 0 0 10 2Zm0 2a6 6 0 1 1 0 12 6 6 0 0 1 0-12Z'/%3E%3C/svg%3E");
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--fg); position: relative; overflow-x: hidden;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5;
}

/* ---------- Fundo: brilhos + grade ---------- */
body::before, body::after { content: ""; position: fixed; z-index: 0; pointer-events: none; border-radius: 50%; filter: blur(90px); }
body::before { width: 520px; height: 520px; top: -160px; left: 50%; margin-left: -260px; background: rgba(255, 26, 26, .28); animation: float 12s ease-in-out infinite alternate; }
body::after { width: 420px; height: 420px; bottom: -200px; right: -120px; background: rgba(179, 0, 0, .25); animation: float 16s ease-in-out infinite alternate-reverse; }
@keyframes float { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(40px, 30px, 0) scale(1.15); } }
.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000, transparent 80%);
          mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000, transparent 80%);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { body::before, body::after { animation: none; } * { animation: none !important; } }

/* ---------- Componentes ---------- */
.glass {
  position: relative; overflow: hidden; padding: 1.4rem;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .09); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.glass::before { content: ""; position: absolute; top: 0; left: 15%; right: 15%; height: 1px; background: linear-gradient(90deg, transparent, var(--red), transparent); }
label.lbl { display: block; color: var(--muted); font-size: .72rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; margin-bottom: .45rem; }
.input, select, textarea {
  width: 100%; padding: .75rem 1rem; font: inherit; font-size: 1rem; line-height: 1.3; color: var(--fg);
  background: rgba(0, 0, 0, .55); border: 1px solid var(--line); border-radius: 12px; transition: border-color .2s, box-shadow .2s;
}
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 26, 26, .18); }
::placeholder { color: #555; }
select { appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238a8a8a'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6rem center; background-size: 18px; }
select option { background: #111; color: var(--fg); }

.btn {
  padding: .6rem 1rem; font: inherit; font-size: .9rem; font-weight: 500; color: var(--fg); cursor: pointer;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 10px; transition: border-color .2s, box-shadow .2s, color .2s, filter .2s, transform .15s;
}
.btn:hover { border-color: var(--red); box-shadow: 0 0 18px rgba(255, 26, 26, .25); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary {
  font-weight: 600; letter-spacing: .02em; color: #fff; border: 0;
  background: linear-gradient(135deg, var(--red), var(--red-dark)); box-shadow: 0 8px 28px rgba(255, 26, 26, .35);
}
.btn.primary:hover { filter: brightness(1.12); box-shadow: 0 10px 34px rgba(255, 26, 26, .5); transform: translateY(-1px); }
.btn.danger:hover { color: var(--red); }
.btn.sm { padding: .3rem .7rem; font-size: .8rem; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ========== LOGIN ========== */
body.login-page { display: flex; align-items: center; justify-content: center; }
.ek-side { display: none; }
#login { position: relative; z-index: 1; width: min(420px, 92vw); padding: 2rem 0; }
.logo-top { display: block; width: 100%; height: 130px; margin: 0 0 .4rem; object-fit: contain; filter: drop-shadow(0 0 28px rgba(255, 26, 26, .45));
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 55%, transparent 100%); mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 55%, transparent 100%); animation: rise .9s ease-out both; }
.ek-head { text-align: center; margin: 0 0 1rem; animation: rise .9s .15s ease-out both; }
.ek-head h2 { font-family: "Sora", "Inter", sans-serif; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.ek-head h2::after { content: ""; display: block; width: 48px; height: 2px; margin: .7rem auto 0; border-radius: 2px; background: linear-gradient(90deg, var(--red-dark), var(--red)); }
.ek-head p { color: var(--muted); font-size: .9rem; margin: .8rem 0 0; }
.login-card { padding: 1.8rem; animation: rise .9s .3s ease-out both; }
.field { position: relative; margin-bottom: 1.1rem; }
.field .input { padding-left: 2.8rem; }
.field::before { content: ""; position: absolute; left: 1rem; bottom: calc(.75rem + .65em - 9px); width: 18px; height: 18px; z-index: 2; pointer-events: none; background: var(--icon-user) center / contain no-repeat; }
.field.pass::before { background-image: var(--icon-lock); }
.login-card .btn.primary { width: 100%; padding: .9rem 1rem; font-size: 1rem; margin-top: .4rem; }
.err { min-height: 1.3em; margin-top: .9rem; font-size: .9rem; color: #ff6b6b; text-align: center; }
input:-webkit-autofill, input:-webkit-autofill:focus { -webkit-text-fill-color: var(--fg) !important; caret-color: var(--fg); transition: background-color 9999s ease-out 0s; }

@media (min-width: 900px) {
  body.login-page { display: grid; grid-template-columns: 1.15fr 1fr; height: 100vh; min-height: 0; overflow: hidden; }
  body.login-page::before { left: 28%; }
  .ek-side {
    display: flex; flex-direction: column; justify-content: center; grid-column: 1; position: relative; z-index: 1; padding: 2rem 4rem; border-right: 1px solid var(--line);
    background: radial-gradient(70% 50% at 30% 30%, rgba(255, 26, 26, .16), transparent 70%), rgba(255, 255, 255, .015);
  }
  #login { grid-column: 2; align-self: center; justify-self: center; width: min(400px, 84%); padding: 0; }
  .logo-top { display: none; }
  .ek-head { text-align: left; margin-bottom: .6rem; }
  .ek-head h2::after { margin-left: 0; }
  .ek-head h2 { font-size: 1.4rem; }
}
.ek-side-logo { width: 170px; max-width: 60%; margin: 0 0 1rem -1rem; filter: drop-shadow(0 0 30px rgba(255, 26, 26, .5));
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 55%, transparent 100%); mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 55%, transparent 100%); animation: rise .9s ease-out both; }
.ek-side h1 { font-family: "Sora", sans-serif; font-size: clamp(2.2rem, 3.6vw, 3.4rem); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 1rem; animation: rise .9s .15s ease-out both; }
.ek-side h1 span { background: linear-gradient(90deg, var(--red), #ff7a7a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ek-side p { color: var(--muted); margin: 0 0 1.4rem; font-size: 1.05rem; animation: rise .9s .25s ease-out both; }
.ek-code { align-self: flex-start; margin: 0; padding: 1.2rem 1.5rem; font: 500 .9rem/1.7 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; color: #d6d6d6;
  background: #0d0d0d; border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5); animation: rise .9s .35s ease-out both; }
.ek-code .c { color: #5c6370; } .ek-code .k { color: var(--red); } .ek-code .f { color: #ffb86c; } .ek-code .s { color: #8bd49c; }
@media (min-width: 900px) and (max-height: 700px) { .ek-code { display: none; } }
@media (max-width: 600px) { html { font-size: 14px; } .input, select, textarea { font-size: 16px; } }

/* ========== APP ========== */
.app { position: relative; z-index: 1; max-width: 920px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.topbar { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.2rem; animation: rise .9s ease-out both; }
.topbar img { width: 54px; height: 54px; object-fit: contain; filter: drop-shadow(0 0 14px rgba(255, 26, 26, .5)); }
.topbar h1 { font-family: "Sora", sans-serif; font-size: 1.5rem; letter-spacing: -.02em; margin: 0; }
.topbar h1 span { background: linear-gradient(90deg, var(--red), #ff7a7a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar .sp { flex: 1; }

.editor { animation: rise .9s .15s ease-out both; margin-bottom: 1.4rem; padding: 1rem; }
.editing-banner { display: none; align-items: center; gap: .6rem; margin: 0 0 .8rem; padding: .55rem .9rem; font-size: .88rem; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 12px; }
.editing-banner.on { display: flex; }
.editing-banner .sp { flex: 1; }
.tabs { display: flex; gap: .3rem; margin-bottom: .6rem; flex-wrap: wrap; align-items: center; }
.tab { padding: .35rem .9rem; font: inherit; font-size: .85rem; color: var(--muted); background: none; border: 1px solid transparent; border-radius: 9px; cursor: pointer; }
.tab.on { color: var(--fg); border-color: var(--line); background: rgba(255, 255, 255, .05); }
.toolbar { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.toolbar button { min-width: 34px; height: 32px; padding: 0 .55rem; font: inherit; font-size: .85rem; color: var(--muted); background: rgba(0, 0, 0, .4); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: color .2s, border-color .2s; }
.toolbar button:hover { color: var(--fg); border-color: var(--red); }
.toolbar .b { font-weight: 700; } .toolbar .i { font-style: italic; font-family: serif; } .toolbar .m { font-family: ui-monospace, monospace; }
#text { display: block; min-height: 190px; resize: vertical; font: 14px/1.6 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
#preview { min-height: 190px; padding: .75rem 1rem; background: rgba(0, 0, 0, .55); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.hidden { display: none !important; }
.editor-foot { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .8rem; }
.editor-foot .sp { flex: 1; }
.editor-foot .count { color: var(--muted); font-size: .8rem; }
.ttl { display: flex; align-items: center; gap: .5rem; }
.ttl label { color: var(--muted); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.ttl select { width: auto; min-width: 150px; padding: .45rem 2rem .45rem .8rem; font-size: .88rem; }
.ttl .custom { display: flex; gap: .4rem; }
.ttl .custom input { width: 5.2rem; padding: .45rem .6rem; font-size: .88rem; }
.ttl .custom select { min-width: 0; }

.listbar { display: flex; align-items: center; gap: .8rem; margin-bottom: .9rem; animation: rise .9s .3s ease-out both; }
.listbar .search { position: relative; flex: 1; }
.listbar .search input { padding-left: 2.6rem; }
.listbar .search::before { content: ""; position: absolute; left: .9rem; top: 50%; margin-top: -9px; width: 18px; height: 18px; pointer-events: none; background: var(--icon-search) center / contain no-repeat; }
.clip { margin-bottom: .9rem; padding: 1rem 1.1rem; animation: rise .5s ease-out both; }
.clip .body { max-height: 320px; overflow: auto; word-break: break-word; }
.clip .actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .8rem; }
.clip .meta { margin-right: auto; color: var(--muted); font-size: .78rem; }
.badge { display: inline-block; margin-left: .5rem; padding: .05rem .5rem; font-size: .72rem; color: #ffb4b4; background: rgba(255, 26, 26, .12); border: 1px solid rgba(255, 26, 26, .35); border-radius: 999px; }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }
.toast { position: fixed; z-index: 10; bottom: 1.2rem; left: 50%; transform: translateX(-50%); padding: .6rem 1.1rem; font-size: .9rem; background: #111; border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); opacity: 0; pointer-events: none; transition: opacity .25s; }
.toast.on { opacity: 1; }

/* ---------- Markdown renderizado ---------- */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { font-family: "Sora", "Inter", sans-serif; letter-spacing: -.02em; line-height: 1.25; margin: 1em 0 .4em; }
.md h1 { font-size: 1.5rem; } .md h2 { font-size: 1.25rem; } .md h3 { font-size: 1.1rem; } .md h4 { font-size: 1rem; }
.md p { margin: .5em 0; }
.md a { color: #ff6b6b; text-underline-offset: 2px; }
.md a:hover { color: var(--red); }
.md code { font: .88em ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; padding: .12em .4em; background: rgba(255, 255, 255, .08); border-radius: 6px; }
.md pre { margin: .7em 0; padding: .9rem 1.1rem; overflow: auto; background: #0d0d0d; border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 12px; }
.md pre code { padding: 0; background: none; font-size: .85rem; color: #d6d6d6; }
.md blockquote { margin: .7em 0; padding: .2em 1em; color: #c9c9c9; border-left: 3px solid var(--red-dark); background: rgba(255, 255, 255, .03); border-radius: 0 8px 8px 0; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.5em; }
.md hr { border: 0; height: 1px; margin: 1em 0; background: var(--line); }
.raw { margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.6 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.cf-turnstile { margin-bottom: 1.1rem; height: 65px; border-radius: 12px; overflow: hidden; }
.cf-turnstile iframe { width: 100% !important; display: block; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
