:root {
  color-scheme: light;
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  background: #f4f6f8;
  color: #20242a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 20px;
}

button,
input {
  font: inherit;
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  min-height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #d8dee4;
  border-radius: 8px;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.preview-panel,
.controls {
  background: #ffffff;
  border: 1px solid #d8dee4;
  border-radius: 8px;
}

.preview-panel {
  min-height: 520px;
  padding: 14px;
  overflow: auto;
}

.empty-state {
  min-height: 490px;
  display: grid;
  place-items: center;
  color: #64707d;
  text-align: center;
  border: 1px dashed #a7b0ba;
  border-radius: 8px;
  padding: 18px;
}

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

.thumb-card {
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 8px;
  min-width: 0;
  background: #ffffff;
}

.thumb-box {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #eef1f4 25%, transparent 25%),
    linear-gradient(-45deg, #eef1f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef1f4 75%),
    linear-gradient(-45deg, transparent 75%, #eef1f4 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-name {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-info {
  margin-top: 4px;
  color: #64707d;
  font-size: 11px;
  line-height: 1.35;
}

.controls {
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.control-group {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid #c9d1d9;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.segmented input:checked + span {
  border-color: #0969da;
  outline: 3px solid rgba(9, 105, 218, 0.16);
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: center;
}

.range-row output {
  text-align: right;
  color: #64707d;
  font-weight: 600;
}

.primary-button,
.export-button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  background: #0969da;
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px;
}

.export-button {
  background: #1f883d;
}

.primary-button:disabled,
.export-button:disabled {
  background: #8c959f;
  cursor: not-allowed;
}

.status {
  margin: 0;
  min-height: 42px;
  color: #64707d;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 820px) {
  body {
    padding: 10px;
  }

  .app {
    min-height: calc(100vh - 20px);
  }

  .app-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 19px;
  }

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

  .controls {
    order: -1;
  }

  .preview-panel {
    min-height: 360px;
  }

  .empty-state {
    min-height: 330px;
  }

  .thumb-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
