:root {
  --bg-1: #05070d;
  --bg-2: #0b1020;
  --bg-3: #121a31;
  --panel: rgba(19, 28, 52, 0.55);
  --panel-solid: #121c34;
  --panel-alt: rgba(16, 24, 45, 0.8);
  --stroke: rgba(148, 173, 255, 0.24);
  --text: #ecf2ff;
  --muted: #a6b8e4;
  --accent: #6ef3ff;
  --accent-2: #7f8dff;
  --accent-3: #9f6bff;
  --danger: #ff6f95;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --shadow-1: 0 24px 70px rgba(0, 0, 0, 0.55);
  --shadow-2: 0 8px 20px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(105, 129, 255, 0.28), transparent 35%),
    radial-gradient(circle at 85% 5%, rgba(129, 243, 255, 0.2), transparent 40%),
    linear-gradient(155deg, var(--bg-3), var(--bg-2) 45%, var(--bg-1));
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(42px);
  pointer-events: none;
  z-index: -2;
}

.orb-1 {
  width: 360px;
  height: 360px;
  background: rgba(93, 126, 255, 0.24);
  top: -90px;
  left: -80px;
}

.orb-2 {
  width: 420px;
  height: 420px;
  background: rgba(124, 251, 255, 0.18);
  bottom: -120px;
  right: -110px;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(131, 163, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(131, 163, 255, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 0%, transparent 80%);
  pointer-events: none;
  z-index: -1;
}

.app-shell {
  width: min(1120px, 94vw);
  margin: 32px auto 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1.35fr minmax(240px, 360px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 20px;
}

.hero-copy,
.hero-panel,
.mode-wrap,
.layer-content,
.footer {
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(24, 36, 66, 0.72), rgba(14, 22, 42, 0.62));
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.hero-copy {
  border-radius: var(--radius-xl);
  padding: 24px 28px;
}

.hero-panel {
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  text-align: center;
}

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

.hero-title {
  margin: 10px 0 10px;
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.05;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: clamp(14px, 2vw, 17px);
  line-height: 1.55;
  max-width: 62ch;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.primary {
  position: relative;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  min-width: 170px;
  color: #030b12;
  background: linear-gradient(135deg, var(--accent), #9efeff);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow:
    0 12px 32px rgba(96, 243, 255, 0.35),
    inset 0 -2px 8px rgba(255, 255, 255, 0.45);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.primary:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow:
    0 14px 36px rgba(96, 243, 255, 0.4),
    inset 0 -2px 9px rgba(255, 255, 255, 0.5);
}

.secondary {
  border: 1px solid rgba(159, 188, 255, 0.4);
  background: rgba(20, 30, 55, 0.7);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.18s ease;
}

.secondary:hover {
  background: rgba(30, 45, 75, 0.85);
  border-color: rgba(159, 188, 255, 0.6);
}

.config-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 8px;
  border-top: 1px solid rgba(159, 188, 255, 0.15);
  margin-top: 8px;
}

.idle-panel {
  width: 100%;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(159, 188, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.idle-panel h3 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.idle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}

.idle-row input[type="number"] {
  width: 88px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 173, 255, 0.32);
  background: rgba(9, 15, 30, 0.8);
  color: var(--text);
}

.idle-check {
  justify-content: flex-start;
}

.gif-manager {
  margin-bottom: 18px;
}

.gif-header h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.gif-header p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.gif-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.gif-slot {
  border: 1px solid rgba(148, 173, 255, 0.2);
  border-radius: 12px;
  padding: 12px;
  background: rgba(11, 18, 35, 0.75);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gif-slot h4 {
  margin: 0;
  font-size: 14px;
}

.gif-preview {
  width: 128px;
  height: 64px;
  border: 1px solid rgba(148, 173, 255, 0.3);
  border-radius: 8px;
  background: #0a1325;
  image-rendering: pixelated;
  align-self: center;
}

.gif-meta {
  font-size: 12px;
  color: var(--muted);
  min-height: 30px;
}

.gif-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.status {
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(159, 188, 255, 0.25);
  background: rgba(10, 16, 32, 0.75);
  color: var(--muted);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
}

.mode-wrap {
  border-radius: var(--radius-lg);
  padding: 10px;
  margin-bottom: 16px;
}

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.mode-tab {
  background: rgba(9, 15, 30, 0.8);
  color: var(--muted);
  border: 1px solid transparent;
  padding: 10px 20px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.18s ease;
}

.mode-tab:hover {
  color: var(--text);
  border-color: rgba(131, 172, 255, 0.35);
}

.mode-tab.active {
  color: #f7fbff;
  background: linear-gradient(135deg, rgba(117, 140, 255, 0.3), rgba(95, 208, 255, 0.26));
  border-color: rgba(132, 181, 255, 0.6);
}

.content {
  margin-top: 8px;
}

.layer-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 18px;
}

.layer-tab {
  background: rgba(11, 18, 35, 0.85);
  color: var(--muted);
  border: 1px solid rgba(142, 171, 255, 0.2);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.layer-tab.active {
  color: var(--text);
  border-color: rgba(123, 225, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(108, 217, 255, 0.17);
}

.layer-content {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.icon-card {
  background: linear-gradient(180deg, rgba(15, 26, 48, 0.92), rgba(10, 18, 34, 0.85));
  border: 1px solid rgba(148, 173, 255, 0.2);
  border-radius: 14px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  transform-style: preserve-3d;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.icon-card:hover {
  transform: perspective(700px) rotateX(2deg) rotateY(-2deg) translateY(-2px);
  border-color: rgba(125, 232, 255, 0.45);
}

.icon-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.icon-canvas {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: 1px solid rgba(128, 165, 255, 0.28);
  background:
    linear-gradient(45deg, rgba(40, 65, 110, 0.45) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(40, 65, 110, 0.45) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(40, 65, 110, 0.45) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(40, 65, 110, 0.45) 75%),
    #0a1325;
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  box-shadow: inset 0 0 24px rgba(77, 130, 255, 0.18);
  image-rendering: pixelated;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.small,
.key-add-btn,
.key-save-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}

.small {
  background: rgba(18, 32, 60, 0.95);
  color: var(--text);
  border: 1px solid rgba(141, 167, 255, 0.22);
}

.small.danger {
  color: #ffd4e0;
  border-color: rgba(255, 118, 160, 0.55);
  background: rgba(58, 16, 35, 0.85);
}

.key-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.key-button-block {
  border-radius: 14px;
  padding: 14px;
  border: 1px solid rgba(148, 173, 255, 0.2);
  background: linear-gradient(180deg, rgba(13, 22, 42, 0.9), rgba(10, 17, 33, 0.86));
}

.key-button-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.key-button-title {
  font-size: 15px;
  font-weight: 700;
}

.key-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.key-item {
  background: rgba(10, 16, 31, 0.86);
  border: 1px solid rgba(148, 173, 255, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.key-item-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.key-item-delete {
  background: transparent;
  border: none;
  color: #ff7ba6;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
}

.key-add-section {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.key-select {
  flex: 1;
  min-width: 210px;
  border-radius: 10px;
  border: 1px solid rgba(140, 168, 255, 0.27);
  padding: 8px 10px;
  background: rgba(9, 16, 32, 0.95);
  color: var(--text);
  font-weight: 600;
}

.key-add-btn {
  color: #071422;
  background: linear-gradient(145deg, #76f7ff, #5fd0ff);
}

.key-save-btn {
  color: #f6f9ff;
  background: linear-gradient(145deg, #6f7fff, #9468ff);
}

.footer {
  margin-top: 16px;
  border-radius: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 14px;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    align-items: stretch;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: 95vw;
    margin-top: 18px;
  }

  .hero-copy {
    padding: 18px;
  }

  .layer-content {
    padding: 16px;
  }

  .icon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-tabs {
    flex-direction: column;
  }
}

/* Button Press Fullscreen Overlay */
.button-press-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 20, 34, 0.95);
  backdrop-filter: blur(20px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.button-press-overlay.show {
  display: flex;
}

.button-press-content {
  text-align: center;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.button-press-canvas {
  width: 256px;
  height: 256px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 20px 50px rgba(118, 247, 255, 0.5));
}

.button-press-label {
  margin-top: 24px;
  font-size: 32px;
  font-weight: 700;
  color: #76f7ff;
  text-shadow: 0 4px 20px rgba(118, 247, 255, 0.7);
  animation: pulse 0.5s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 20, 34, 0.85);
  backdrop-filter: blur(10px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  min-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content h2 {
  margin: 0 0 20px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.modal-content input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(7, 20, 34, 0.4);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.modal-content input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(159, 188, 255, 0.1);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
}

.modal-actions button.primary {
  color: #071422;
  background: linear-gradient(145deg, var(--accent-2), var(--accent-3));
}

.modal-actions button:not(.primary) {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

.modal-actions button:hover {
  transform: translateY(-2px);
}

/* Layer tab edit button */
.layer-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.layer-tab-edit {
  opacity: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.2s, background 0.2s;
}

.layer-tab:hover .layer-tab-edit {
  opacity: 1;
}

.layer-tab-edit:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
}
