:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #627084;
  --line: #d9e0ea;
  --accent: #d93f3f;
  --accent-dark: #b92f34;
  --soft: #eef3f8;
  --success: #1f7a4d;
  --danger: #b42318;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(217, 63, 63, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1060px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.workspace {
  display: grid;
  gap: 22px;
}

.header {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.04;
  letter-spacing: 0;
}

.tool,
.results {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(24, 35, 55, 0.08);
}

.tool {
  display: grid;
  gap: 12px;
  padding: 20px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

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

input {
  min-width: 0;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(217, 63, 63, 0.12);
}

button {
  height: 50px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.results {
  overflow: hidden;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

h2 {
  font-size: 18px;
}

#result-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.status {
  margin: 20px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  line-height: 1.5;
}

.status.error {
  background: #fff1f0;
  color: var(--danger);
}

.status.success {
  background: #eefaf3;
  color: var(--success);
}

.image-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 20px 20px;
}

.image-actions[hidden] {
  display: none;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 0 20px 20px;
}

.media-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.image-item {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.video-item {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.preview {
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 6px;
  background: #f7f9fc;
}

.video-item .preview {
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #101820;
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  display: block;
}

.preview img {
  object-fit: contain;
}

.preview video {
  object-fit: contain;
}

.preview-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #fff;
  font-weight: 800;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.open-link:hover {
  background: var(--accent-dark);
}

.image-open-link {
  background: var(--soft);
  color: var(--ink);
}

.image-open-link:hover {
  background: #e0e8f2;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1060px);
    padding: 28px 0;
  }

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

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

  button,
  .image-actions button {
    width: 100%;
  }

  .image-actions {
    align-items: stretch;
    padding: 0 20px 20px;
  }

  .preview {
    max-height: 320px;
  }
}

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