:root {
  --bg: #091022;
  --ink: #e9f2ff;
  --muted: #a6b6d9;
  --line: rgba(200, 220, 255, 0.26);
  --glass: rgba(255, 255, 255, 0.08);
  --accent: #7ef0ff;
  --danger: #ff7297;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.42);
  --pixel-border: 0 0 0 1px rgba(126, 240, 255, 0.5), inset 0 0 0 1px rgba(6, 12, 28, 0.75);
}

@font-face {
  font-family: "RetroGamingLocal";
  src: url("/web/fonts/Retro%20Gaming.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Retron2000Local";
  src: url("/web/fonts/Retron2000.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: radial-gradient(1200px 800px at 0% 0%, #1d2e58 0%, transparent 55%),
    radial-gradient(1000px 700px at 90% 20%, #163c4a 0%, transparent 50%),
    linear-gradient(150deg, #050812 0%, #0b1430 55%, #070d1f 100%);
}

body {
  font-family: "Retron2000Local", monospace;
  overflow-x: hidden;
}

h1,
h2,
h3,
.kicker {
  font-family: "Retron2000Local", monospace;
}

.fx-noise,
.fx-grid,
.fx-glitch,
.fx-orb,
.fx-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.fx-particles {
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.9;
}

.fx-noise {
  background-image: radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px);
  background-size: 3px 3px, 4px 4px;
  opacity: 0.16;
}

.fx-grid {
  background: repeating-linear-gradient(
      to right,
      rgba(137, 200, 255, 0.08) 0,
      rgba(137, 200, 255, 0.08) 1px,
      transparent 1px,
      transparent 60px
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(137, 200, 255, 0.06) 0,
      rgba(137, 200, 255, 0.06) 1px,
      transparent 1px,
      transparent 60px
    );
  mask-image: radial-gradient(circle at 50% 30%, black 35%, transparent 80%);
}

.fx-glitch {
  opacity: 0.13;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 70, 90, 0.2) 49%, transparent 51%),
    linear-gradient(90deg, transparent 0%, rgba(75, 225, 255, 0.2) 49%, transparent 51%);
  mix-blend-mode: screen;
  animation: glitchShift 7s steps(2, end) infinite;
}

@keyframes glitchShift {
  0%,
  88%,
  100% {
    transform: translateX(0);
    opacity: 0.1;
  }
  89% {
    transform: translateX(1px);
    opacity: 0.2;
  }
  90% {
    transform: translateX(-1px);
    opacity: 0.18;
  }
  91% {
    transform: translateX(0.5px);
    opacity: 0.16;
  }
}

.fx-orb {
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(56px);
  opacity: 0.26;
}

.orb-a {
  left: -120px;
  top: -120px;
  background: #4fd2ff;
  animation: driftA 14s ease-in-out infinite;
}

.orb-b {
  right: -120px;
  bottom: -160px;
  background: #58ffb7;
  animation: driftB 17s ease-in-out infinite;
}

@keyframes driftA {
  0%,
  100% { transform: translate(0, 0); }
  50% { transform: translate(100px, 80px); }
}

@keyframes driftB {
  0%,
  100% { transform: translate(0, 0); }
  50% { transform: translate(-120px, -70px); }
}

.layout {
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 18px 34px;
  position: relative;
  z-index: 2;
}

.glass {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.glass-inner {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(200, 220, 255, 0.22);
}

.panel {
  border-radius: 22px;
  padding: 22px;
}

.auth-panel {
  max-width: 560px;
  margin: 9vh auto;
  padding: 34px 30px 28px;
  background: linear-gradient(145deg, rgba(18, 35, 74, 0.72), rgba(11, 22, 50, 0.64));
}

.auth-panel,
.auth-panel h1,
.auth-panel .sub,
.auth-panel .kicker,
.auth-panel .label,
.auth-panel .input,
.auth-panel .btn,
.auth-panel .hint {
  font-family: "Retron2000Local", monospace;
}

.auth-panel .input {
  margin-bottom: 10px;
}

.auth-panel .btn {
  margin-top: 12px;
  margin-bottom: 6px;
}

.hidden {
  display: none;
}

.kicker {
  margin: 0 0 12px;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h1,
h2 {
  margin: 0 0 8px;
  line-height: 1.2;
}

h1 { font-size: clamp(28px, 4.5vw, 42px); }
h2 { font-size: clamp(22px, 3vw, 30px); }

.sub {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.label {
  display: block;
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.input,
.textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(184, 205, 255, 0.25);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.04));
  color: var(--ink);
  padding: 13px 14px;
  outline: none;
}

.input::placeholder,
.textarea::placeholder {
  color: #95a5c7;
}

.input:focus,
.textarea:focus {
  border-color: rgba(126, 240, 255, 0.75);
  box-shadow: 0 0 0 1px rgba(126, 240, 255, 0.32), 0 0 20px rgba(126, 240, 255, 0.12);
}

.textarea {
  min-height: 78px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(126, 240, 255, 0.58);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: "RetroGamingLocal", "Retron2000Local", monospace;
  box-shadow: var(--pixel-border), 0 8px 20px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 40%);
  pointer-events: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--pixel-border), 0 12px 24px rgba(0, 0, 0, 0.32);
  filter: saturate(112%);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  background: linear-gradient(130deg, rgba(126, 240, 255, 0.38), rgba(140, 255, 173, 0.3));
}

.btn-danger {
  border-color: rgba(255, 125, 163, 0.68);
  background: linear-gradient(130deg, rgba(255, 114, 151, 0.32), rgba(224, 76, 116, 0.23));
}

.hint {
  min-height: 18px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: 999px;
  padding: 8px 14px;
  border: 2px solid rgba(126, 240, 255, 0.58);
  color: var(--ink);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  cursor: pointer;
  font-size: 13px;
  font-family: "RetroGamingLocal", "Retron2000Local", monospace;
  text-transform: none;
  letter-spacing: 0.02em;
  box-shadow: var(--pixel-border);
  transition: background 0.2s ease, transform 0.2s ease;
}

.chip::before {
  content: "●";
  font-size: 9px;
  margin-right: 7px;
  color: rgba(158, 255, 209, 0.7);
}

.chip:hover {
  background: rgba(255, 255, 255, 0.13);
  transform: translateY(-1px);
}

.chip:active {
  transform: translateY(1px) scale(0.995);
}

.chip.active {
  background: linear-gradient(130deg, rgba(126, 240, 255, 0.22), rgba(140, 255, 173, 0.16));
}

.messages {
  margin-top: 4px;
  height: 560px;
  overflow: auto;
  border-radius: 8px;
  padding: 14px;
  position: relative;
  background: repeating-linear-gradient(
      to bottom,
      rgba(126, 240, 255, 0.05) 0,
      rgba(126, 240, 255, 0.05) 1px,
      rgba(9, 16, 34, 0.1) 1px,
      rgba(9, 16, 34, 0.1) 3px
    ),
    linear-gradient(180deg, rgba(8, 17, 40, 0.95), rgba(8, 14, 32, 0.9));
  box-shadow: inset 0 0 0 1px rgba(126, 240, 255, 0.25), inset 0 0 22px rgba(62, 191, 255, 0.16);
}

.messages::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: rgba(126, 240, 255, 0.35);
  animation: crtSweep 8s linear infinite;
  pointer-events: none;
}

@keyframes crtSweep {
  0% { top: 0; opacity: 0; }
  5% { opacity: 0.55; }
  100% { top: 100%; opacity: 0; }
}

.msg {
  max-width: 90%;
  padding: 10px 11px;
  border-radius: 8px;
  margin: 8px 0;
  white-space: pre-wrap;
  line-height: 1.45;
  font-family: "Retron2000Local", monospace;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.msg.user {
  margin-left: auto;
  background: linear-gradient(130deg, rgba(126, 240, 255, 0.24), rgba(126, 240, 255, 0.1));
  border: 1px solid rgba(126, 240, 255, 0.5);
  box-shadow: inset 0 0 0 1px rgba(98, 237, 255, 0.26);
}

.msg.bot {
  margin-right: auto;
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.07));
  border: 1px solid rgba(184, 205, 255, 0.3);
  box-shadow: inset 0 0 0 1px rgba(184, 205, 255, 0.18);
}

.inputs {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}

.row .btn:first-child {
  flex: 1 1 auto;
}

.mic-btn {
  width: 56px;
  min-width: 56px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.mic-btn.listening {
  border-color: rgba(140, 255, 173, 0.95);
  background: linear-gradient(130deg, rgba(140, 255, 173, 0.42), rgba(126, 240, 255, 0.3));
  box-shadow: 0 0 0 1px rgba(140, 255, 173, 0.55), 0 0 26px rgba(140, 255, 173, 0.35);
  animation: pulseMic 1s ease-in-out infinite;
}

@keyframes pulseMic {
  0%,
  100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.photo-toggle-btn {
  width: fit-content;
  min-width: 180px;
}

.single-upload {
  max-width: 520px;
}

.upload-block.collapsed {
  display: none;
}

.upload-block {
  border-radius: 12px;
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.upload-block h3 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.upload-block .label {
  margin: 6px 0 4px;
}

input[type="file"] {
  border-radius: 8px;
  padding: 6px;
  border: 1px solid rgba(184, 205, 255, 0.26);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
}

input[type="file"]::file-selector-button {
  border: 1px solid rgba(184, 205, 255, 0.5);
  border-radius: 6px;
  padding: 7px 11px;
  margin-right: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.12));
  color: #091022;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: linear-gradient(180deg, rgba(126, 240, 255, 0.54), rgba(140, 255, 173, 0.34));
}

@media (max-width: 900px) {
  .layout {
    margin: 16px auto;
    padding: 0 12px 20px;
  }

  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .auth-panel {
    margin: 3vh auto;
    padding: 20px 14px 16px;
  }

  h1 { font-size: clamp(24px, 8vw, 32px); }
  h2 { font-size: clamp(18px, 5.8vw, 24px); }

  .messages {
    height: 460px;
    padding: 12px 10px;
  }

  .topbar {
    flex-direction: column;
  }

  .toolbar {
    gap: 8px;
    padding: 10px;
  }

  .chip {
    font-size: 12px;
    padding: 7px 11px;
  }

  .btn {
    width: 100%;
  }

  .row {
    flex-direction: row;
    flex-wrap: nowrap;
  }

  .msg {
    max-width: 96%;
    font-size: 14px;
  }

  .mic-btn {
    width: 52px;
    min-width: 52px;
  }

  .single-upload {
    max-width: 100%;
  }
}

@media (max-width: 700px) {
  .orb-b {
    right: -240px;
    bottom: -280px;
    opacity: 0.12;
    filter: blur(70px);
  }

  .orb-a {
    opacity: 0.2;
    filter: blur(62px);
  }

  .auth-panel {
    background: linear-gradient(145deg, rgba(18, 35, 74, 0.84), rgba(11, 22, 50, 0.78));
  }

  .sub,
  .label,
  .hint {
    color: #b8c8e8;
  }

  .fx-particles {
    opacity: 0.5;
  }
}
