/* work-unit: static-r2-thumbnail-manager-style / related-thread: thumbnail-r2-static-manager-v1 */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #f1f5f9;
  --text: #111827;
  --muted: #64748b;
  --border: #dbe3ea;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent: #f97316;
  --success: #059669;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.file-label {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

button:hover,
.file-label:hover {
  background: var(--primary-strong);
}

button:active,
.file-label:active {
  transform: translateY(1px);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 132px;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.topbar-actions,
.form-actions,
.toolbar-controls,
.card-actions,
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-button,
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
  text-decoration: none;
}

.ghost-button:hover,
.file-label:hover {
  background: var(--surface-strong);
  border-color: #cbd5e1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) 1fr;
  gap: 22px;
  align-items: start;
}

.control-panel,
.gallery-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 18px;
}

.panel-section {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
  border-bottom: 0;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.muted {
  background: #f1f5f9;
  color: var(--muted);
}

.status-pill.ready {
  background: #dcfce7;
  color: #166534;
}

.field-label,
.select-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.select-label {
  margin-bottom: 0;
}

.input-row input {
  min-width: 0;
}

.input-row button,
.form-actions button {
  flex: 0 0 auto;
  padding: 0 14px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 128px;
  margin-bottom: 16px;
  border: 1px dashed #9fb0c5;
  border-radius: var(--radius);
  background: #f8fafc;
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.drop-zone.drag-over,
.drop-zone:focus {
  border-color: var(--primary);
  background: #eff6ff;
  outline: none;
}

.drop-zone-copy {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.drop-zone-copy strong {
  font-size: 0.98rem;
}

.drop-zone-copy span,
.form-message,
.url-text,
.summary-row {
  color: var(--muted);
  font-size: 0.86rem;
}

.form-actions {
  justify-content: space-between;
  margin-top: 12px;
}

.form-message {
  min-height: 21px;
  margin: 10px 0 0;
}

.form-message.success {
  color: var(--success);
}

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

.gallery-panel {
  min-width: 0;
  padding: 20px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.toolbar-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-controls select {
  width: auto;
  min-width: 128px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
}

.text-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 0.86rem;
  font-weight: 800;
}

.text-button:hover {
  background: transparent;
  color: #b91c1c;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 16px;
  padding-top: 18px;
}

.thumbnail-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}

.favorite-button {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  width: 34px;
  min-height: 34px;
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.92);
  color: #334155;
  font-size: 1.05rem;
  line-height: 1;
}

.favorite-button:hover,
.favorite-button.active {
  background: #fff7ed;
  color: var(--accent);
}

.preview-box {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--border);
}

.preview-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview-fallback {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  padding: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.preview-box.failed .preview-image {
  display: none;
}

.preview-box.failed .preview-fallback {
  display: grid;
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.file-name {
  margin: 0;
  min-height: 24px;
  font-size: 0.98rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.url-text {
  min-height: 40px;
  margin: 0;
  padding: 9px;
  border-radius: 6px;
  background: var(--surface-strong);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-actions button {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
}

.copy-button.copied {
  background: var(--success);
}

.delete-button {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecaca;
}

.delete-button:hover {
  background: #fee2e2;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .control-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .toolbar,
  .input-row,
  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar-controls {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr;
    width: 100%;
  }

  .toolbar-controls select {
    width: 100%;
    min-width: 0;
  }

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

@media (max-width: 430px) {
  .toolbar-controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .select-label {
    margin-top: 4px;
  }
}
