:root {
  color-scheme: dark;
  --bg: #070708;
  --bg-accent: #1a090d;
  --surface: rgba(20, 20, 22, 0.92);
  --surface-strong: rgba(26, 26, 29, 0.97);
  --border: rgba(220, 31, 52, 0.28);
  --text: #f5f5f6;
  --muted: #d3b2b7;
  --accent: #dc1f34;
  --danger: #ef3348;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, #010101 0, #010101 20%, rgba(1, 1, 1, 0.96) 34%, rgba(12, 6, 8, 0.92) 48%, transparent 68%),
    linear-gradient(135deg, #030304 0%, #070708 32%, #12070a 64%, #1b090d 100%);
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -50% 0 0 0;
  pointer-events: none;
  z-index: 0;
  transform: translateY(50%);
}

body::before {
  opacity: 1;
  background:
    linear-gradient(rgba(220, 31, 52, 0.18) 0 0) 30% 18% / 14px 14px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.26) 0 0) 33.6% 18% / 14px 14px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.24) 0 0) 30% 21.9% / 14px 14px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.16) 0 0) 37.2% 21.9% / 14px 14px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.22) 0 0) 30% 25.8% / 14px 14px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.18) 0 0) 41.8% 25.8% / 14px 14px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.28) 0 0) 30% 29.7% / 14px 14px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.32) 0 0) 45.4% 29.7% / 16px 16px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.34) 0 0) 49.6% 29.7% / 16px 16px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.2) 0 0) 45.4% 34.4% / 16px 16px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.3) 0 0) 53.8% 34.4% / 16px 16px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.26) 0 0) 58% 34.4% / 16px 16px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.38) 0 0) 53.8% 39.1% / 16px 16px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.44) 0 0) 62.2% 39.1% / 18px 18px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.48) 0 0) 66.8% 39.1% / 18px 18px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.42) 0 0) 62.2% 44.4% / 18px 18px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.54) 0 0) 71.4% 44.4% / 18px 18px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.5) 0 0) 76% 44.4% / 18px 18px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.6) 0 0) 71.4% 49.7% / 18px 18px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.7) 0 0) 80.6% 49.7% / 20px 20px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.76) 0 0) 85.8% 49.7% / 20px 20px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.68) 0 0) 80.6% 55.6% / 20px 20px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.82) 0 0) 85.8% 55.6% / 20px 20px no-repeat,
    linear-gradient(rgba(220, 31, 52, 0.88) 0 0) 91% 55.6% / 20px 20px no-repeat;
}

body::after {
  opacity: 1;
  background:
    radial-gradient(circle at 0% 0%, rgba(0, 0, 0, 0.96), rgba(0, 0, 0, 0.88) 18%, rgba(0, 0, 0, 0.48) 36%, transparent 58%),
    radial-gradient(circle at 58% 42%, rgba(220, 31, 52, 0.14), transparent 18%),
    radial-gradient(circle at 88% 56%, rgba(220, 31, 52, 0.18), transparent 22%),
    linear-gradient(180deg, transparent, rgba(18, 7, 10, 0.38));
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.brand-lockup {
  display: flex;
  justify-content: center;
  text-align: center;
}

.brand-lockup > div {
  display: grid;
  justify-items: center;
}

.brand-wordmark {
  display: block;
  width: min(760px, 82vw);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 10px 28px rgba(220, 31, 52, 0.22));
}

.subtitle {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  letter-spacing: 0.02em;
}

.primary-button,
.secondary-button,
.danger-button,
#cancelButton,
.widget-editor-toolbar button,
.card-settings {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.primary-button {
  background: linear-gradient(135deg, #ef3348, #b51225);
  border-color: rgba(239, 51, 72, 0.46);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.04);
}

.danger-button {
  color: white;
  background: linear-gradient(135deg, #ff6d7a, #e11d48);
  border-color: rgba(255, 109, 122, 0.4);
}

.floating-actions {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  display: grid;
  justify-items: end;
  gap: 0.9rem;
  z-index: 30;
}

.action-menu {
  display: grid;
  gap: 0.75rem;
  justify-items: end;
}

.action-menu-button {
  min-width: 9.5rem;
}

.floating-action-toggle {
  width: 4rem;
  height: 4rem;
  border: 1px solid rgba(239, 51, 72, 0.46);
  border-radius: 999px;
  background: linear-gradient(135deg, #ef3348, #b51225);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform 0.18s ease;
}

.floating-action-toggle.is-open {
  transform: rotate(45deg);
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.tab-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.78rem 1.15rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  box-shadow: var(--shadow);
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tab-button.is-active {
  background: linear-gradient(135deg, rgba(239, 51, 72, 0.32), rgba(181, 18, 37, 0.34));
  border-color: rgba(239, 51, 72, 0.5);
  color: var(--text);
}

.tab-button:hover {
  transform: translateY(-1px);
}

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

.icon-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
  cursor: grab;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.icon-card.is-dragging {
  opacity: 0.56;
  transform: scale(0.98);
  cursor: grabbing;
}

.icon-card.is-drop-target {
  border-color: rgba(255, 92, 116, 0.5);
  background: rgba(255, 92, 116, 0.08);
}

.card-launch {
  display: grid;
  gap: 1rem;
  align-items: center;
  justify-items: start;
  border: none;
  background: transparent;
  padding: 0;
  color: inherit;
  text-align: left;
  box-shadow: none;
}

.card-settings {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: none;
  font-size: 1rem;
}

.icon-visual {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(239, 51, 72, 0.26), rgba(239, 51, 72, 0.08));
  border: 1px solid rgba(239, 51, 72, 0.24);
  font-size: 2rem;
}

.icon-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.6rem;
}

.card-copy {
  min-width: 0;
}

.card-meta {
  margin-bottom: 0.55rem;
}

.card-visibility {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.28rem 0.58rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.card-visibility-public {
  background: rgba(73, 181, 123, 0.16);
  color: #8ff0bc;
}

.card-visibility-internal {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
}

.card-title {
  margin: 0;
  font-size: 1.1rem;
}

.card-description {
  margin: 0.4rem 0 0;
  color: var(--text);
  font-size: 0.92rem;
  opacity: 0.88;
}

.card-url {
  display: none;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 8, 15, 0.7);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(680px, 100%);
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-header h2 {
  margin: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.modal-form,
.field-grid {
  display: grid;
  gap: 1rem;
}

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

label {
  display: grid;
  gap: 0.45rem;
}

label span {
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

select {
  appearance: none;
}

.emoji-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

.emoji-picker-button {
  min-width: 4.8rem;
  height: 3.1rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  box-shadow: none;
  font-size: 0.95rem;
  padding: 0 0.85rem;
}

.helper-text,
.form-error {
  margin: 0;
  font-size: 0.92rem;
}

.helper-text {
  color: var(--muted);
}

.form-error {
  color: #ff9aa5;
  min-height: 1.2rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-picker-card {
  width: min(760px, 100%);
}

.widget-editor-card {
  width: min(1280px, calc(100vw - 2rem));
  max-height: min(92vh, 980px);
  overflow: auto;
}

.category-manager-card {
  width: min(760px, calc(100vw - 2rem));
  max-height: min(92vh, 760px);
  overflow: auto;
}

.widget-editor-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.widget-editor-form {
  display: grid;
  gap: 1rem;
}

.category-manager-form {
  display: grid;
  gap: 1rem;
}

.widget-editor-toolbar,
.widget-editor-table-head,
.widget-editor-row {
  display: grid;
  grid-template-columns:
    minmax(130px, 0.95fr)
    minmax(180px, 1.35fr)
    minmax(150px, 1fr)
    minmax(130px, 0.85fr)
    minmax(100px, 0.65fr)
    minmax(80px, 0.45fr)
    minmax(160px, 1fr)
    minmax(90px, 0.5fr);
  gap: 0.85rem;
  align-items: end;
}

.widget-editor-toolbar {
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
}

.category-manager-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.85rem;
  align-items: center;
}

.widget-editor-table-head {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.widget-editor-rows {
  display: grid;
  gap: 0.85rem;
}

.category-manager-rows {
  display: grid;
  gap: 0.85rem;
}

.widget-editor-row {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.category-manager-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: end;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.widget-editor-row label {
  min-width: 0;
}

.widget-editor-row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 100%;
}

.widget-editor-row-actions .danger-button {
  width: 100%;
}

.category-manager-row-actions {
  display: flex;
  gap: 0.75rem;
}

.category-manager-row-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 0.75rem;
}

.icon-choice {
  height: 72px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  box-shadow: none;
  font-size: 1.9rem;
}

.spacer {
  flex: 1;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .topbar {
    align-items: center;
  }

  .brand-wordmark {
    width: min(420px, 92vw);
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .widget-editor-toolbar {
    grid-template-columns: 1fr;
  }

  .category-manager-toolbar {
    grid-template-columns: 1fr;
  }

  .widget-editor-toolbar > .spacer {
    display: none;
  }

  .category-manager-toolbar > .spacer {
    display: none;
  }

  .floating-actions {
    right: 1rem;
    bottom: 1rem;
  }
}

@media (max-width: 960px) {
  .icon-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

@media (max-width: 1320px) {
  .widget-editor-table-head {
    display: none;
  }

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

@media (max-width: 720px) {
  .widget-editor-row {
    grid-template-columns: 1fr;
  }

  .category-manager-row {
    grid-template-columns: 1fr;
  }
}
