/* Pixel Decoder · vintage cartoon style (Mr. Pixel) */
:root {
  --paper: #efdfc2;
  --paper-2: #f7ecd6;
  --card: #fbf3e2;
  --ink: #2a1d16;
  --ink-soft: #5b4636;
  --text: #2a1d16;
  --red: #d2493a;
  --red-deep: #b23a2d;
  --mustard: #f2b52a;
  --green: #8fae3c;
  --green-deep: #5f7d22;
  --navy: #3f5470;
  --discord: #5865f2;
  --field: #fffaf0;
  --shadow: 6px 6px 0 var(--ink);
}
:root[data-theme="dark"] {
  --paper: #1f1813;
  --paper-2: #2a2019;
  --card: #2d231b;
  --ink: #0d0907;
  --ink-soft: #c9b79a;
  --text: #f3e6cc;
  --field: #1a1410;
  --shadow: 6px 6px 0 #000;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden;
  font-family: 'Rubik', system-ui, sans-serif; line-height: 1.5;
  color: var(--text); background: var(--paper);
}
/* aged-paper grain + halftone */
.paper {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55; mix-blend-mode: multiply;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    radial-gradient(rgba(120, 72, 30, .10) 1px, transparent 1.4px);
  background-size: 220px 220px, 9px 9px;
}
:root[data-theme="dark"] .paper { mix-blend-mode: screen; opacity: .18; }
header, main, footer { position: relative; z-index: 1; }

/* ---------- hero ---------- */
.hero { padding: 36px 16px 20px; overflow: hidden; }
.hero__sun {
  position: absolute; width: 270px; aspect-ratio: 1; border-radius: 50%; left: 50%; top: -18px; transform: translateX(-457px);
  background: radial-gradient(circle at 40% 35%, #dd5a47, var(--red) 55%, var(--red-deep)); opacity: .9;
}
.hero__inner { position: relative; max-width: 820px; margin: 0 auto; display: flex; gap: 26px; align-items: center; }
.hero__mascot {
  width: 170px; height: auto; flex: none; border-radius: 24px; border: 4px solid var(--ink);
  box-shadow: var(--shadow); transform: rotate(-3deg); background: var(--paper-2);
}
.logo {
  margin: 0; font-family: 'Shrikhand', cursive; font-weight: 400; line-height: 1;
  font-size: clamp(2.6rem, 7vw, 4.4rem); color: #fbf3e2;
  -webkit-text-stroke: 3px #2a1d16; paint-order: stroke fill; text-shadow: 4px 5px 0 #2a1d16;
}
.logo span { color: var(--mustard); display: inline-block; transform: rotate(-4deg) translateY(3px); }
.tagline { margin: 10px 0 0; max-width: 40ch; font-size: 1.08rem; font-weight: 500; }

.top-actions { position: absolute; top: 14px; right: 16px; display: flex; gap: 10px; }
.theme-toggle, .discord-mini {
  height: 44px; border-radius: 12px; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
}
.theme-toggle { width: 44px; background: var(--card); font-size: 1.2rem; }
.discord-mini { white-space: nowrap; display: inline-flex; align-items: center; padding: 0 14px; background: var(--discord); color: #fff; font-weight: 800; text-decoration: none; }
.visits {
  height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border-radius: 12px;
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--red); background: var(--ink); color: #fff3d8;
  font-family: 'Courier Prime', monospace; font-weight: 700; font-size: .95rem; white-space: nowrap;
}
.visits[hidden] { display: none; }
.visits b { font-size: 1.05rem; letter-spacing: 1px; }
@media (max-width: 400px) { .visits__label { display: none; } }
.theme-toggle:active, .discord-mini:active { transform: translate(3px, 3px); box-shadow: none; }

/* ---------- card ---------- */
main { max-width: 820px; margin: 0 auto; padding: 8px 16px 36px; display: grid; gap: 28px; }
.card { background: var(--card); border: 4px solid var(--ink); border-radius: 20px; box-shadow: var(--shadow); padding: 24px; }

.tool__top { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; box-shadow: 3px 3px 0 var(--ink); background: var(--paper-2); }
.seg__btn { border: 0; background: transparent; color: var(--text); font: 800 1.05rem 'Rubik', sans-serif; padding: 10px 20px; cursor: pointer; }
.seg__btn + .seg__btn { border-left: 3px solid var(--ink); }
.seg__btn.is-on { background: var(--green-deep); color: #fff6e6; }
.seg--small .seg__btn { font-size: .9rem; padding: 7px 14px; }
.seg--small .seg__btn.is-on { background: var(--navy); }
.seg__btn:focus-visible, .btn:focus-visible, .link-btn:focus-visible { outline: 3px dashed var(--red); outline-offset: 3px; }

.field { display: grid; gap: 6px; }
.field__label { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .82rem; color: var(--ink-soft); }
textarea {
  width: 100%; min-height: 130px; resize: vertical; color: inherit;
  font: 400 1.02rem/1.45 'Courier Prime', ui-monospace, monospace;
  background: var(--field); border: 3px solid var(--ink); border-radius: 14px; padding: 14px 16px;
  box-shadow: inset 3px 3px 0 rgba(42, 29, 22, .12);
}
textarea:focus { outline: none; border-color: var(--red); box-shadow: inset 3px 3px 0 rgba(42, 29, 22, .12), 0 0 0 4px rgba(210, 73, 58, .25); }
#output { background: var(--paper-2); }
.field__meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .85rem; color: var(--ink-soft); }
.field__meta > span:first-child { margin-right: auto; }
.link-btn { border: 0; background: none; color: inherit; font: 700 .9rem 'Rubik', sans-serif; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.link-btn:hover { background: rgba(242, 181, 42, .35); }

.buddy { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.buddy img { border-radius: 50%; border: 3px solid var(--ink); background: var(--paper-2); flex: none; }
.buddy.pop img { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.15) rotate(-6deg); } }
.bubble { position: relative; margin: 0; background: var(--field); border: 3px solid var(--ink); border-radius: 16px; padding: 9px 14px; font-weight: 600; }
.bubble::before { content: ''; position: absolute; left: -11px; top: 50%; width: 16px; height: 16px; background: var(--field); border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: translateY(-50%) rotate(45deg); }
.bubble.is-error { background: #ffe0d6; color: #5a1a10; }
.bubble.is-error::before { background: #ffe0d6; }
:root[data-theme="dark"] .bubble.is-error, :root[data-theme="dark"] .bubble.is-error::before { background: #4a1d15; color: #ffd9cc; }

.btn {
  display: inline-block; font: 800 .95rem 'Rubik', sans-serif; color: #fff6e6; background: var(--red);
  border: 3px solid var(--ink); border-radius: 12px; padding: 7px 14px; box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn--green { background: var(--green-deep); }

.links { margin-top: 14px; border: 3px dashed var(--green-deep); border-radius: 16px; padding: 12px 16px; background: rgba(143, 174, 60, .12); }
.links[hidden] { display: none; }
.links__title { margin: 0 0 6px; font-weight: 800; }
.links ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.links li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.links code { font-family: 'Courier Prime', monospace; word-break: break-all; flex: 1 1 240px; }
.links__warn { margin: 8px 0 0; font-size: .85rem; color: var(--ink-soft); }

.chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; font-size: .9rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.chip input { accent-color: var(--red); width: 16px; height: 16px; }
body.fmt-url .only-b64 { display: none; }

/* ---------- discord ---------- */
.discord {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--mustard); color: #2a1d16; border: 4px solid var(--ink); border-radius: 20px; box-shadow: var(--shadow);
  padding: 18px 22px; transform: rotate(-.6deg);
}
.discord img { border-radius: 50%; border: 3px solid #2a1d16; background: #f7ecd6; }
.discord div { flex: 1 1 260px; }
.discord h2 { margin: 0; font-family: 'Shrikhand', cursive; font-weight: 400; font-size: 1.45rem; line-height: 1.2; }
.discord p { margin: 4px 0 0; font-weight: 500; }
.btn--discord { background: var(--discord); color: #fff; font-size: 1.05rem; padding: 10px 18px; border-color: #2a1d16; box-shadow: 3px 3px 0 #2a1d16; }

/* ---------- footer ---------- */
.foot { text-align: center; padding: 4px 16px 36px; }
.foot p { margin: 4px 0; font-weight: 600; }
.foot a { color: var(--red); font-weight: 800; }
.foot__small { font-size: .85rem; color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 200%); z-index: 9; visibility: hidden;
  background: #2a1d16; color: #fff3d8; border-radius: 14px; padding: 10px 18px; font-weight: 700;
  box-shadow: 4px 4px 0 var(--red); transition: transform .25s ease, visibility .25s;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .hero { padding-top: 72px; }
  .top-actions { left: 16px; justify-content: flex-end; }
  .visits { margin-right: auto; padding: 0 10px; }
  .hero__inner { flex-direction: column; text-align: center; gap: 16px; }
  .hero__mascot { width: 140px; }
  .hero__sun { width: 220px; top: 50px; transform: translateX(-50%); }
  .tagline { margin-inline: auto; }
  .card { padding: 18px 14px; }
  .tool__top { justify-content: center; }
  .discord { text-align: center; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
