:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --text: #14181f;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --bad: #b42318;
  --ok: #047857;
  --tile: 150px;
  --shadow: 0 18px 38px rgb(15 23 42 / 14%);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 300px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

h1,
p {
  margin: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

h1 {
  font-size: 24px;
}

.brand p,
.hint,
.status,
#selectionInfo,
#previewMeta {
  color: var(--muted);
  font-size: 13px;
}

.status {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--bad);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input[type="search"] {
  padding: 0 12px;
}

input[type="range"] {
  min-height: auto;
}

select {
  padding: 0 12px;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.workspace {
  min-width: 0;
  padding: 18px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0 18px;
  background: rgb(238 241 245 / 92%);
  backdrop-filter: blur(10px);
}

.toolbar > div:first-child {
  display: grid;
  gap: 2px;
}

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

.tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tile.selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgb(37 99 235 / 20%);
}

.tile button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: #e8edf3;
  background-repeat: no-repeat;
}

.tile footer {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 8px;
  font-size: 12px;
}

.tile strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.check {
  width: 18px;
  height: 18px;
}

.preview-dialog {
  width: min(900px, calc(100vw - 24px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgb(8 13 20 / 72%);
}

.preview-thumb {
  width: min(480px, calc(100vw - 48px));
  aspect-ratio: 4 / 5;
  margin: 0 auto;
  background: #111827;
  background-repeat: no-repeat;
}

.preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: #fff;
}

.preview-actions > div:first-child {
  display: grid;
  gap: 3px;
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 92%);
  font-size: 20px;
  cursor: pointer;
}

@media (max-width: 820px) {
  body {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .toolbar,
  .preview-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
