:root {
  color-scheme: light;

  --bg: #eef3fb;
  --surface: rgba(255,255,255,.78);
  --surface-solid: #ffffff;
  --surface-soft: #f5f8fd;

  --text: #172033;
  --text-soft: #657089;
  --text-fade: #8a94ab;

  --line: rgba(18, 31, 53, .12);
  --line-strong: rgba(18, 31, 53, .18);

  --primary: #0067c0;
  --primary-hover: #00539c;
  --primary-soft: rgba(0,103,192,.12);

  --success: #0f9d58;
  --danger: #d93025;
  --warn: #ff9800;

  --shadow-sm: 0 6px 18px rgba(16,24,40,.08);
  --shadow-md: 0 16px 40px rgba(16,24,40,.12);
  --shadow-lg: 0 24px 60px rgba(16,24,40,.16);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;

  --transition: .18s ease;
}

* {
  box-sizing: border-box;
  min-width: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body.discover-shell {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(0,103,192,.14), transparent 28rem),
    radial-gradient(circle at top right, rgba(15,157,88,.08), transparent 24rem),
    linear-gradient(180deg, #f8fbff, #eef3fb);
  font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

input,
textarea,
select,
.rich-editor-content {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,.92);
  color: var(--text);
  border-radius: var(--radius-sm);
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

input,
select {
  height: 42px;
  padding-inline: 14px;
}

textarea {
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
.rich-editor-content:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0,103,192,.12);
}

label {
  display: grid;
  gap: 8px;
  font-weight: 650;
}

.discover-header {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 4vw, 42px);
  background: rgba(255,255,255,.76);
  backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #0067c0, #3aa0ff);
  color: white;
  font-size: 18px;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand small {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  max-width: 240px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  color: var(--text-soft);
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-inline: 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  transition:
    transform var(--transition),
    background var(--transition),
    border-color var(--transition),
    opacity var(--transition);
}

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

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  color: white;
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255,255,255,.84);
  border: 1px solid var(--line-strong);
}

.btn-secondary:hover {
  background: white;
  border-color: rgba(0,103,192,.35);
}

.btn-danger {
  color: white;
  background: var(--danger);
}

.btn.full {
  width: 100%;
}

.icon-only {
  width: 40px;
  padding: 0;
}

.beta-notification {
  position: fixed;
  top: 88px;
  right: 22px;
  z-index: 140;
  width: min(420px, calc(100vw - 24px));
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
}

.beta-notification.show {
  display: flex;
}

.beta-notification p {
  margin-top: 4px;
  color: var(--text-soft);
}

.discover-layout {
  width: min(1440px, 100%);
  margin-inline: auto;
  padding: 26px 18px 50px;
}

.toolbar-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(24px);
}

.category-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-strip::-webkit-scrollbar {
  display: none;
}

.category-btn {
  height: 38px;
  flex-shrink: 0;
  padding-inline: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-weight: 750;
  cursor: pointer;
  transition: all var(--transition);
}

.category-btn:hover,
.category-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(0,103,192,.25);
}

.toolbar-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.contents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.content-card {
  position: relative;
  min-height: 260px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 18px;
  overflow: hidden;
  border-radius: 22px;
  background: rgba(255,255,255,.84);
  border: 1px solid rgba(255,255,255,.65);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  cursor: pointer;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
}

.content-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.08), transparent);
  pointer-events: none;
}

.content-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0,103,192,.18);
  box-shadow: var(--shadow-lg);
}

.content-card img.app-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.content-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
}

.content-card p {
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.content-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-soft);
}

.badge,
.verified-badge {
  width: fit-content;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.badge {
  background: var(--success);
}

.badge.beta {
  background: var(--warn);
}

.badge.alpha,
.badge.suspended {
  background: var(--danger);
}

.badge.deprecated {
  background: #6c7893;
}

.badge.in-progress {
  background: var(--primary);
}

.verified-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--success);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 11px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 70px 20px;
  border-radius: 24px;
  border: 2px dashed var(--line-strong);
  text-align: center;
  color: var(--text-soft);
  background: rgba(255,255,255,.6);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.pagination button {
  min-width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.84);
  font-weight: 800;
  cursor: pointer;
}

.pagination button.active {
  color: white;
  background: var(--primary);
  border-color: var(--primary);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  height: 100%;
  padding: 20px;
  overflow: visible;
  background: transparent;
  border: 0;
  display: none;
}

.modal::backdrop {
  background: rgba(15,23,42,.42);
  backdrop-filter: blur(18px);
}

.modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  gap: 16px;
  padding: 24px;
  border-radius: 28px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: var(--shadow-lg);
}

.modal-card:not(.compact) {
  min-height: 600px;
}

.modal-card.compact {
  width: min(520px, 100%);
}

.modal-card.wide {
  width: min(1100px, 100%);
}

.close-modal {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 24px;
}

.close-modal:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.segment {
  height: 40px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-weight: 800;
}

.segment.active {
  background: white;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.login-panel {
  display: none;
  gap: 12px;
}

.login-panel.active {
  display: grid;
}

.hint {
  color: var(--text-soft);
  font-size: 13px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-head img {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.modal-actions,
.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-apps-list,
.stack-list {
  display: grid;
  gap: 10px;
}

.list-item,
.version-item,
.changelog-list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.version-item {
  align-items: center;
}

.changelog-list-item > div {
  display: grid;
  gap: 6px;
}

.editor-modal {
  padding: 14px;
}

.editor-card {
  width: min(1240px, 100%);
  height: min(780px, calc(100vh - 60px));
  max-height: calc(100vh - 60px);
  padding: 0;
  overflow: hidden;
  grid-template-rows: auto 1fr auto;
  gap: 0;
}

.editor-head,
.editor-actions {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
}

.editor-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-right: 60px;
}

.editor-status {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 850;
}

.editor-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(190px, 240px) 1fr;
}

.editor-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 18px;
  background: rgba(245,248,253,.9);
  border-right: 1px solid var(--line);
}

.editor-nav button {
  min-height: 42px;
  padding-inline: 14px;
  text-align: left;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 750;
  cursor: pointer;
}

.editor-nav button:hover,
.editor-nav button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.editor-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
}

.editor-section {
  display: none;
  max-width: 900px;
  gap: 18px;
}

.editor-section.active {
  display: grid;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 16px;
}

.rich-editor-wrapper {
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: white;
}

.rich-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.toolbar-btn,
.toolbar-select {
  min-width: 34px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
}

.toolbar-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.toolbar-select {
  min-width: 120px;
  padding-inline: 10px;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin-inline: 4px;
}

.rich-editor-content {
  min-height: 120px;
  padding: 14px;
  border: 0;
  border-radius: 0;
  overflow-wrap: anywhere;
}

.rich-editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-fade);
}

.media-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
}

.upload-box {
  min-height: 190px;
  align-content: start;
  padding: 16px;
  border-radius: 20px;
  border: 2px dashed var(--line-strong);
  background: rgba(255,255,255,.55);
  cursor: pointer;
}

.upload-box input {
  display: none;
}

.preview-slot,
.preview-images {
  margin-top: 14px;
}

.preview-slot img,
.preview-image {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.preview-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gallery-item-wrapper {
  position: relative;
}

.remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  cursor: pointer;
}

.inline-add {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.file-pill {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 16px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 750;
}

.file-pill input {
  display: none;
}

.changelog-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  padding-right: 48px;
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detail-title img {
  width: 82px;
  height: 82px;
  border-radius: 20px;
  object-fit: cover;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  align-self: flex-start;
  margin-top: 4px;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-inline: 14px;
  border-radius: 12px;
  color: var(--text-soft);
  font-weight: 750;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.tab:hover {
  background: rgba(0,103,192,.07);
  color: var(--text);
}

.tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
  padding-top: 18px;
}

.tab-content.active {
  display: grid;
  gap: 12px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.gallery img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.support-table {
  display: grid;
  gap: 10px;
}

.support-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.support-label {
  color: var(--text-soft);
  font-weight: 850;
}

.rating-stars {
  display: flex;
  gap: 4px;
}

.rating-star {
  background: transparent;
  color: #c7d0df;
  cursor: pointer;
  font-size: 30px;
}

.rating-star.is-active,
.rating-star:hover {
  color: #ffb300;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 400;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.95);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow-md);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-warning {
  border-left-color: var(--warn);
}

.toast-error {
  border-left-color: var(--danger);
}

@media (max-width: 980px) {
  .editor-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .editor-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .discover-header {
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    width: 100%;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .toolbar-search,
  .two-column,
  .media-grid,
  .inline-add,
  .support-row {
    grid-template-columns: 1fr;
  }

  .contents-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (max-width: 560px) {
  .discover-layout {
    padding-inline: 12px;
  }

  .modal,
  .editor-modal {
    padding: 8px;
  }

  .modal-card,
  .editor-card {
    border-radius: 22px;
    max-height: calc(100vh - 16px);
  }

  .contents-grid,
  .gallery {
    grid-template-columns: 1fr;
  }

  .detail-hero {
    padding-right: 20px;
  }
}

/* ── Card Action Buttons (Melden / Download) ─────────────────────────── */

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.card-action-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 15px;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    transform var(--transition);
}

.card-action-btn:hover {
  transform: translateY(-2px);
}

.card-action-report:hover {
  background: rgba(217, 48, 37, 0.1);
  color: var(--danger);
  border-color: rgba(217, 48, 37, 0.3);
}

.card-action-download:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(0, 103, 192, 0.3);
}

/* ── Version Item Icon Buttons (Melden / Download) ───────────────────── */

.version-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 15px;
  flex-shrink: 0;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    transform var(--transition);
}

.version-icon-btn:hover {
  transform: translateY(-2px);
}

.version-icon-report:hover {
  background: rgba(217, 48, 37, 0.1);
  color: var(--danger);
  border-color: rgba(217, 48, 37, 0.3);
}

.version-icon-download:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(0, 103, 192, 0.3);
}

/* ── Report Modal ────────────────────────────────────────────────────────── */

#report-modal h2,
#report-confirm-modal h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--danger);
}

#report-modal h2 i,
#report-confirm-modal h2 i {
  font-size: 18px;
}

#report-custom-wrapper {
  display: grid;
}

#report-custom-wrapper.hidden {
  display: none !important;
}
