:root {
  --bg: #fff8f1;
  --surface: #ffffff;
  --surface-2: #f3eadf;
  --ink: #182024;
  --muted: #637277;
  --line: #eadbcc;
  --brand: #0f3d4c;
  --brand-2: #17677a;
  --accent: #ff6f61;
  --accent-2: #ffc857;
  --danger: #b42318;
  --ok: #147a52;
  --shadow: 0 12px 34px rgba(15, 61, 76, 0.12);
  --radius: 18px;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: contain;
}

button, input, textarea {
  font: inherit;
}

button, .button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: background 180ms, border-color 180ms;
}

button:hover, .button:hover { background: var(--brand-2); }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary, .button.secondary { background: var(--surface); color: var(--brand); border: 1px solid var(--line); }
button.ghost { background: transparent; color: var(--brand); padding: 0 10px; }
button.danger { background: #fff1ef; color: var(--danger); border: 1px solid #ffd0ca; }

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdfb;
  color: var(--ink);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
}

input:focus, textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(23, 103, 122, 0.13);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 800; font-size: 0.88rem; }
.ok { color: var(--ok); font-weight: 800; font-size: 0.88rem; }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: min(100%, 410px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--brand);
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

.mark svg { width: 34px; height: 34px; }
.login-card h1 { font-size: 2rem; line-height: 1.05; margin-bottom: 8px; color: var(--brand); }
.login-card p { margin-bottom: 22px; color: var(--muted); line-height: 1.45; }
.login-card form { display: grid; gap: 12px; }

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 14px 38px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 248, 241, 0.9);
  backdrop-filter: blur(14px);
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--brand);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-badge svg { width: 25px; height: 25px; }
.brand strong { display: block; font-size: 1rem; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { display: block; color: var(--muted); font-size: 0.78rem; }

.hero {
  margin: 12px 0 18px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(15, 61, 76, 0.97), rgba(23, 103, 122, 0.92)),
    radial-gradient(circle at 85% 10%, rgba(255, 200, 87, 0.8), transparent 28%);
  color: white;
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.hero h1 { font-size: clamp(2rem, 7vw, 4.5rem); line-height: 0.98; max-width: 760px; }
.hero p { color: rgba(255, 255, 255, 0.82); max-width: 610px; line-height: 1.5; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero .button, .hero button { background: white; color: var(--brand); }
.hero .button.secondary, .hero button.secondary { background: rgba(255, 255, 255, 0.12); color: white; border-color: rgba(255, 255, 255, 0.25); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 8px 26px rgba(15, 61, 76, 0.07);
  margin-bottom: 16px;
}

.upload-form { display: grid; gap: 12px; }
.field-grid { display: grid; gap: 12px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.stage {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.stage-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface-2);
}

.stage-item img,
.stage-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stage-item button {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  background: rgba(24, 32, 36, 0.78);
}

.filters {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--brand);
  min-height: 38px;
  padding: 0 13px;
  white-space: nowrap;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

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

.photo {
  position: relative;
  min-width: 0;
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(15, 61, 76, 0.08);
}

.photo img,
.photo video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.photo-info {
  padding: 10px 10px 46px;
}

.photo-info strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.92rem;
}

.photo-info span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-actions {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.photo-actions button, .photo-actions a {
  pointer-events: auto;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
}

.empty {
  text-align: center;
  padding: 42px 20px;
  color: var(--muted);
}

.empty svg {
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  color: var(--accent);
}

@media (min-width: 620px) {
  .app { padding: 22px 22px 52px; }
  .hero { padding: 36px; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: minmax(220px, 360px) 1fr; align-items: start; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 980px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
