/* ======================================================================
   happwn — cipher console
   ====================================================================== */
:root {
  --bg:        #06070e;
  --bg-2:      #0a0c17;
  --surface:   #0d1020;
  --surface-2: #11152a;
  --line:      rgba(120, 150, 220, 0.10);
  --line-2:    rgba(120, 150, 220, 0.20);
  --ink:       #e9ecfb;
  --muted:     #8b93bd;
  --dim:       #5b6390;

  --cyan:      #2ff3c8;
  --cyan-soft: rgba(47, 243, 200, 0.14);
  --violet:    #8b6cff;
  --amber:     #ffb454;
  --red:       #ff6b7d;

  --grad: linear-gradient(115deg, var(--violet), var(--cyan));

  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Chakra Petch", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;

  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 12% -8%, rgba(139, 108, 255, 0.18), transparent 60%),
    radial-gradient(1000px 760px at 110% 8%, rgba(47, 243, 200, 0.14), transparent 55%),
    radial-gradient(900px 900px at 50% 130%, rgba(139, 108, 255, 0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}

/* fine technical grid over the whole page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 85%);
  pointer-events: none;
  z-index: 0;
}

/* film grain */
.grain {
  position: fixed;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.04;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: overlay;
}

/* slow scan sweep */
.scan {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 36vh;
  background: linear-gradient(180deg, rgba(47, 243, 200, 0.05), transparent);
  pointer-events: none;
  z-index: 1;
  animation: sweep 9s linear infinite;
}
@keyframes sweep { 0% { transform: translateY(-40vh); } 100% { transform: translateY(140vh); } }

main {
  position: relative;
  z-index: 2;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 44px) 18px 80px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 52px; height: 52px; border-radius: 13px;
  box-shadow: 0 0 0 1px var(--line-2), 0 14px 40px -12px rgba(139, 108, 255, 0.55);
}
.brand-text h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 7vw, 40px);
  letter-spacing: 1px;
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tag {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 2.5px;
  color: var(--muted);
}
.tag .slash { color: var(--cyan); }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.vchip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--cyan);
  padding: 5px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--cyan-soft);
}
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: transform .25s, color .25s, border-color .25s, box-shadow .25s;
}
.icon-btn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 22px -6px var(--cyan); }
.icon-btn .gear { font-size: 18px; transition: transform .5s; display: inline-block; }
.icon-btn:hover .gear { transform: rotate(120deg); }

/* ---------- panels ---------- */
.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: clamp(18px, 3.5vw, 26px);
  backdrop-filter: blur(6px);
}
.console { box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9); }

/* instrument corner brackets */
.corner { position: absolute; width: 14px; height: 14px; border: 2px solid var(--cyan); opacity: .55; }
.corner.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--radius); }
.corner.tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; border-top-right-radius: var(--radius); }
.corner.bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; border-bottom-left-radius: var(--radius); }
.corner.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--radius); }

.panel-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--cyan);
  text-transform: uppercase;
}

.field-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 10px;
}
.blink { color: var(--cyan); animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- inputs ---------- */
textarea, input {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  padding: 13px 14px;
  transition: border-color .2s, box-shadow .2s, background .2s;
  resize: vertical;
}
textarea::placeholder, input::placeholder { color: var(--dim); }
textarea:focus, input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-soft), inset 0 0 24px -16px var(--cyan);
  background: #070a14;
}

/* ---------- buttons ---------- */
.actions { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.btn {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 13px 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform .15s, box-shadow .25s, background .25s, color .25s, border-color .25s, opacity .25s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  color: #04130f;
  background: var(--grad);
  background-size: 180% 180%;
  box-shadow: 0 14px 34px -14px rgba(47, 243, 200, 0.7);
  animation: hue 6s ease infinite;
}
@keyframes hue { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.btn.primary:hover { box-shadow: 0 18px 40px -12px rgba(47, 243, 200, 0.9); transform: translateY(-1px); }
.btn.primary .arr { transition: transform .2s; }
.btn.primary:hover .arr { transform: translateX(4px); }
.btn.ghost {
  color: var(--cyan);
  background: transparent;
  border-color: var(--line-2);
}
.btn.ghost:not(:disabled):hover { border-color: var(--cyan); box-shadow: 0 0 24px -8px var(--cyan); }
.btn.ghost:not(:disabled) { animation: readyPulse 2.6s ease-in-out infinite; }
@keyframes readyPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(47,243,200,0); }
  50% { box-shadow: 0 0 22px -8px rgba(47,243,200,.6); }
}
.btn:disabled { opacity: .38; cursor: not-allowed; animation: none; }
.btn.small { padding: 9px 14px; font-size: 11px; color: var(--cyan); background: var(--cyan-soft); border-color: var(--line-2); }
.btn.small:hover { border-color: var(--cyan); }

/* icon copy button */
.iconbtn {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s, border-color .2s, box-shadow .2s, transform .12s, background .2s;
}
.iconbtn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 18px -6px var(--cyan); }
.iconbtn:active { transform: scale(.92); }
.iconbtn .ic { width: 16px; height: 16px; }
.iconbtn .ic-check { display: none; color: var(--cyan); }
.iconbtn.copied { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 18px -6px var(--cyan); }
.iconbtn.copied .ic-copy { display: none; }
.iconbtn.copied .ic-check { display: block; animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- pipeline ---------- */
.pipeline {
  list-style: none;
  display: flex;
  gap: 0;
  margin: 20px 0 0;
  padding: 0;
}
.stage {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 1.5px;
  color: var(--dim);
  position: relative;
}
.stage + .stage { padding-left: 16px; }
.stage:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 8px; top: 50%;
  width: 16px; height: 1px;
  background: var(--line-2);
}
.stage .dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid var(--line-2);
  background: transparent;
  flex: none;
  transition: background .3s, box-shadow .3s, border-color .3s;
}
.stage.active { color: var(--cyan); }
.stage.active .dot { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 12px var(--cyan); animation: pulse 1s infinite; }
.stage.done { color: var(--ink); }
.stage.done .dot { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 8px -1px var(--cyan); }
.stage.error { color: var(--red); }
.stage.error .dot { background: var(--red); border-color: var(--red); box-shadow: 0 0 10px var(--red); }
@keyframes pulse { 50% { transform: scale(1.35); } }

/* ---------- status + decoded ---------- */
.status {
  font-family: var(--mono);
  font-size: 12.5px;
  min-height: 1.3em;
  margin: 16px 0 0;
  color: var(--red);
}
.decoded {
  margin: 14px 0 0;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--cyan);
  border-radius: 10px;
  padding: 12px 14px;
}
.decoded-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.decoded-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 2px; color: var(--cyan);
}
.ok-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.decoded-value {
  display: block;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  word-break: break-all;
  user-select: all;
}

/* ---------- output ---------- */
.output { border-color: rgba(47, 243, 200, 0.4); box-shadow: 0 0 60px -24px rgba(47, 243, 200, 0.5); }
.output-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.meta { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 1px; }

.sub-row { display: flex; gap: 16px; align-items: stretch; flex-wrap: wrap; }
.sub-main { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.sub-line { display: flex; align-items: stretch; gap: 10px; }
.sub-url {
  display: block;
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--cyan);
  background: var(--bg-2);
  border: 1px dashed rgba(47, 243, 200, 0.45);
  border-radius: 10px;
  padding: 14px;
  word-break: break-all;
  line-height: 1.5;
}
.sub-line .iconbtn { align-self: flex-start; height: 38px; width: 38px; }
.qr-frame {
  padding: 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--line-2), 0 18px 40px -18px rgba(0,0,0,.8);
  align-self: center;
  line-height: 0;
}
#qr { display: block; }

/* ---------- configs ---------- */
.configs { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.configs li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s, transform .1s;
  word-break: break-all;
}
.configs li:hover { border-color: var(--cyan); color: var(--ink); background: #070b15; }
.configs li:active { transform: scale(.995); }
.configs .idx { color: var(--dim); flex: none; font-size: 10px; min-width: 22px; }
.configs .scheme {
  flex: none;
  text-transform: uppercase;
  font-size: 9.5px;
  letter-spacing: 1px;
  color: var(--cyan);
  border: 1px solid var(--line-2);
  background: var(--cyan-soft);
  border-radius: 5px;
  padding: 2px 6px;
}
.configs .uri { color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ---------- settings ---------- */
/* smooth open/close */
.settings {
  overflow: hidden;
  max-height: 420px;
  transition: max-height .42s cubic-bezier(.4, 0, .2, 1), opacity .3s ease,
              padding .42s cubic-bezier(.4, 0, .2, 1), transform .42s cubic-bezier(.4, 0, .2, 1),
              border-width .3s ease;
  will-change: max-height, opacity;
}
.settings.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  transform: translateY(-10px);
}
.icon-btn.active { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 22px -6px var(--cyan); }
.icon-btn.active .gear { transform: rotate(90deg); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.settings-grid label { display: grid; gap: 6px; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; color: var(--muted); }
.settings-grid label.wide { grid-column: 1 / -1; }
.settings .hint { margin: 12px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.6; }

/* ---------- terminal (manual extraction) ---------- */
.terminal { padding: 0; overflow: hidden; }
.term-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: #04060d;
  border-bottom: 1px solid var(--line-2);
}
.dots { display: inline-flex; gap: 7px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; display: block; opacity: .9; }
.dots .r { background: var(--red); }
.dots .a { background: var(--amber); }
.dots .g { background: var(--cyan); }
.term-title {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
}
.term-body {
  margin: 0;
  padding: 18px 16px;
  background: #04060d;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}
.term-body .cline { min-height: 1.2em; }
.term-body .c-prompt { color: var(--cyan); }
.term-body .c-cmd { color: var(--ink); font-weight: 700; }
.term-body .c-flag { color: var(--dim); }
.term-body .c-str { color: var(--amber); }
.term-body .c-url { color: var(--cyan); }
.term-body .c-pipe { color: var(--dim); }
.term-body .c-cont { color: var(--dim); }
.term-note {
  margin: 0;
  padding: 12px 16px 16px;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.6;
  border-top: 1px solid var(--line);
}
.term-note b { color: var(--cyan); font-weight: 600; }
.term-note code { font-family: var(--mono); color: var(--amber); }

/* ---------- footer ---------- */
footer {
  margin-top: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .5px;
}
footer .dim { color: var(--dim); }
footer a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line-2); }
footer a:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(14px); animation: rise .6s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: var(--d, 0s); }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- scrollbar ---------- */
.configs::-webkit-scrollbar { width: 8px; }
.configs::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; }
.configs::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

@media (max-width: 640px) {
  main { padding: 22px 14px 64px; gap: 14px; }
  .logo { width: 46px; height: 46px; }
  .tag { font-size: 9.5px; letter-spacing: 1.5px; }
  .settings-grid { grid-template-columns: 1fr; }
  .actions { gap: 10px; }
  .actions .btn { flex: 1 1 100%; justify-content: center; }
  textarea, input { font-size: 16px; }            /* stop iOS focus-zoom */
  .sub-row { flex-direction: column; }
  .qr-frame { align-self: center; }
  .configs li { font-size: 11.5px; }
  .vchip { display: none; }
  footer { flex-direction: column; gap: 6px; align-items: flex-start; }
}

@media (max-width: 420px) {
  .pipeline { gap: 2px; }
  .stage { font-size: 9px; letter-spacing: .5px; gap: 6px; }
  .stage + .stage { padding-left: 10px; }
  .stage:not(:last-child)::after { width: 8px; right: 4px; }
  .term-body { font-size: 11.5px; padding: 14px 12px; }
  .configs .uri { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .scan, .blink, .btn.primary, .btn.ghost:not(:disabled), .stage.active .dot { animation: none; }
  .reveal { opacity: 1; transform: none; animation: none; }
}
