/* Swiss / Mobbin-style gallery — flat grid, no shadows */

:root {
  --bg: #ffffff;
  --text: #111111;
  --text-secondary: #6b6b6b;
  --text-muted: #9a9a9a;
  --border: #e8e8e8;
  --border-soft: #f0f0f0;
  --soft: #f5f5f5;
  --accent: #111111;
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.08);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --brand: #00c853;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --topbar-h: 56px;
  --rail-h: 72px;
  --phone-w: min(240px, 70%);
  --phone-radius: 30px;
  --phone-ratio: 9 / 19.5;
  --grid-line: #ececec;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  background: var(--soft);
  color: var(--text);
}

.btn:hover {
  background: #ebebeb;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
}

.btn.primary:hover {
  background: #2a2a2a;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
}

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

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

.btn.sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ——— Topbar ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: 1fr minmax(180px, 320px) 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}

.brand:hover {
  color: var(--text);
}

.top-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 320px;
  height: 36px;
  justify-self: center;
  align-self: center;
  margin: 0;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.top-search input {
  display: block;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  outline: none;
  font-size: 13.5px;
  line-height: 36px;
  appearance: none;
  -webkit-appearance: none;
}

.top-search input::-webkit-search-decoration,
.top-search input::-webkit-search-cancel-button,
.top-search input::-webkit-search-results-button,
.top-search input::-webkit-search-results-decoration {
  display: none;
}

.top-search input:focus {
  border-color: #ccc;
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
}

/* ——— App logo rail ——— */
.app-rail-wrap {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.app-rail {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 14px 20px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.app-rail::-webkit-scrollbar {
  display: none;
}

.app-icon-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  transition: opacity 0.12s ease;
}

.app-icon-btn:not(.is-active) {
  opacity: 0.85;
}

.app-icon-btn:hover {
  opacity: 1;
}

.app-icon-tile {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--soft);
  border: 1px solid transparent;
}

.app-icon-btn.is-active .app-icon-tile {
  border-color: var(--text);
  outline: 1px solid var(--text);
  outline-offset: 1px;
}

.all-tile {
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: #fff;
}

.app-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-initials {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

/* ——— Swiss gallery grid ——— */
.gallery-main {
  width: 100%;
  margin: 0;
  padding: 0;
  background: #fff;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  /* continuous swiss lines */
  border-top: 1px solid var(--grid-line);
}

.card {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
  background: #fff;
  margin: 0;
  padding: 56px 32px 36px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 640px;
  border-radius: 0;
  box-shadow: none;
  outline: none;
  transition: none;
}

.card:nth-child(3n) {
  border-right: 0;
}

.card:hover,
.card:focus-visible {
  background: #fff;
  transform: none;
  box-shadow: none;
}

/* Portrait phone — clean, no chrome/shadow */
.phone {
  position: relative;
  width: var(--phone-w);
  max-width: 260px;
  aspect-ratio: var(--phone-ratio);
  border-radius: var(--phone-radius);
  overflow: hidden;
  background: #d9d9d9;
  box-shadow: none;
  border: none;
  flex-shrink: 0;
}

.media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #d0d0d0;
}

.media.poster {
  z-index: 1;
}

.media.video {
  z-index: 2;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.card.is-playing .media.video {
  opacity: 1;
}

/* Meta under phone: logo + app name · clip */
.card-meta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 90%;
  min-width: 0;
}

.app-icon-xs {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}

.app-icon-xs.solid {
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.card-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
}

.card-app-name {
  white-space: nowrap;
}

.card-sep {
  color: var(--text-muted);
  font-weight: 400;
}

.card-clip-title {
  color: var(--text-secondary);
  font-weight: 450;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 360px;
  padding: 48px 24px;
  color: var(--text-secondary);
  text-align: center;
  border-top: 1px solid var(--grid-line);
}

.empty-state p {
  margin: 0;
  max-width: 360px;
  line-height: 1.5;
}

/* ——— Lightbox (fullscreen black detail) ——— */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 0;
  background: #000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: #000;
}

.lightbox-panel {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  padding: 12px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
  box-shadow: none;
  pointer-events: none;
}

.lb-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
}

.lb-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.lb-phone {
  /* Near full viewport height; width follows 9/19.5 portrait ratio */
  width: min(
    calc((100dvh - 24px) * 9 / 19.5),
    calc((100vh - 24px) * 9 / 19.5),
    calc(100vw - 24px)
  );
  aspect-ratio: var(--phone-ratio);
  height: auto;
  max-height: min(calc(100dvh - 24px), calc(100vh - 24px));
  border-radius: var(--phone-radius);
  overflow: hidden;
  background: #111;
  pointer-events: auto;
}

.lb-phone video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}

.lb-caption {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 64px;
  text-align: left;
  pointer-events: none;
}

#lb-title {
  margin: 0;
  font-size: 13px;
  font-weight: 550;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.85);
}

#lb-app-name {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
}

/* ——— Admin (kept functional, flat) ——— */
.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.admin-hero {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.admin-hero h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.lede {
  margin: 8px 0 0;
  max-width: 520px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.5;
}

.banner {
  padding: 11px 13px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 520;
}

.banner.ok {
  background: var(--success-soft);
  color: var(--success);
}

.banner.err {
  background: var(--danger-soft);
  color: var(--danger);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.upload-card,
.manage-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: none;
}

.fieldset {
  border: 0;
  margin: 0 0 20px;
  padding: 0;
}

.fieldset legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 12.5px;
  font-weight: 520;
  color: var(--text-secondary);
}

.field-span {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 9px 11px;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #bbb;
}

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

.dropzone {
  position: relative;
  border: 1px dashed #ccc;
  border-radius: 12px;
  background: #fafafa;
  min-height: 168px;
  overflow: hidden;
}

.dropzone.is-dragover {
  border-color: #111;
  background: #f3f3f3;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 168px;
  padding: 24px 14px;
  text-align: center;
  color: var(--text-secondary);
  pointer-events: none;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  margin-bottom: 4px;
}

.dropzone-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.dropzone-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.dropzone-file {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  pointer-events: none;
}

.phone-sm {
  width: 64px;
  border-radius: 12px;
  aspect-ratio: var(--phone-ratio);
  flex-shrink: 0;
  overflow: hidden;
  background: #ddd;
}

.phone-sm canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.file-meta strong {
  color: var(--text);
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  margin: 8px 0 16px;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: #111;
  transition: width 0.2s ease;
}

.progress-label {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

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

.form-hint {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.form-hint.is-error {
  color: var(--danger);
}

.form-hint.is-ok {
  color: var(--success);
}

.manage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.manage-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 520;
  white-space: nowrap;
}

.empty-sm {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.app-manage-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-manage-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px;
  background: #fafafa;
}

.app-manage-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-manage-head .grow {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-manage-head .grow strong {
  font-size: 13.5px;
}

.app-icon-sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.app-icon-sm.solid {
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.muted {
  color: var(--text-muted);
  font-size: 11.5px;
}

.demo-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.demo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
}

.demo-thumb {
  width: 32px;
  height: 50px;
  object-fit: cover;
  border-radius: 7px;
  background: #111;
  flex-shrink: 0;
}

.demo-row-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.demo-row-meta strong {
  color: var(--text);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ——— Responsive ——— */
@media (max-width: 960px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .card:nth-child(3n) {
    border-right: 1px solid var(--grid-line);
  }

  .card:nth-child(2n) {
    border-right: 0;
  }

  .card {
    min-height: 560px;
    padding: 44px 24px 28px;
  }

  .phone {
    max-width: 220px;
  }

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

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    padding: 10px 14px;
    gap: 10px;
  }

  .topbar-left {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar-right {
    grid-column: 2;
    grid-row: 1;
  }

  .top-search {
    grid-column: 1 / -1;
    max-width: none;
  }

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

  .card {
    border-right: 0 !important;
    min-height: 520px;
    padding: 40px 20px 28px;
  }

  .phone {
    width: min(260px, 72%);
    max-width: 280px;
  }

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

@media (prefers-reduced-motion: reduce) {
  .media.video {
    transition: none;
  }
}
