:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --ink: #17212b;
  --muted: #637083;
  --line: #d9e0e6;
  --accent: #0f766e;
  --accent-dark: #0a5f59;
  --accent-soft: #dff3ef;
  --danger: #b42318;
  --danger-soft: #fff0ec;
  --shadow: 0 18px 40px rgba(25, 35, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.5vw, 2.15rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

.status-pill {
  max-width: min(48vw, 360px);
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 20px rgba(25, 35, 45, 0.06);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(292px, 360px) minmax(292px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.panel,
.image-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
}

.section-title,
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title span,
.board-header .eyebrow + h2 + span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.camera-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17212b;
}

#cameraVideo {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#cameraVideo.is-active {
  display: block;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: #d7e6e2;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.22), rgba(23, 33, 43, 0.1)),
    #17212b;
  text-align: center;
}

.camera-placeholder.is-hidden {
  display: none;
}

.placeholder-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.placeholder-icon svg {
  width: 25px;
  height: 25px;
}

.button-grid,
.action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.btn,
.chip,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  font-weight: 800;
}

.btn:hover,
.chip:hover,
.icon-btn:hover {
  border-color: #b9c6ce;
  transform: translateY(-1px);
}

.btn:active,
.chip:active,
.icon-btn:active {
  transform: translateY(0);
}

.btn:disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

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

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.ghost {
  background: transparent;
}

.btn.danger,
.icon-btn.danger {
  color: var(--danger);
}

.btn.danger:hover,
.icon-btn.danger:hover {
  border-color: #f2b5ad;
  background: var(--danger-soft);
}

.wide {
  width: 100%;
}

.drop-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed #aebcc5;
  border-radius: 8px;
  background: var(--surface-soft);
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input {
  display: none;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

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

.settings-form {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 6px;
}

label span,
legend {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus,
input[type="color"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

input[type="color"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.chip {
  min-height: 34px;
  padding: 6px 8px;
  color: var(--accent-dark);
  font-weight: 800;
  background: #f7fbfa;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.segmented label {
  position: relative;
  display: block;
}

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

.segmented span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.segmented input:checked + span {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.quality-control strong {
  color: var(--ink);
}

input[type="range"] {
  accent-color: var(--accent);
}

.image-board {
  min-height: 520px;
  padding: 14px;
}

.board-header {
  margin-bottom: 14px;
}

.board-tools {
  display: inline-flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
}

.empty-state {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.58);
}

.empty-state.is-hidden {
  display: none;
}

.empty-state h3 {
  color: var(--ink);
}

.empty-state p {
  margin: 0;
}

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

.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.thumb-wrap {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 4 / 3;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(45deg, #eff3f2 25%, transparent 25%),
    linear-gradient(-45deg, #eff3f2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eff3f2 75%),
    linear-gradient(-45deg, transparent 75%, #eff3f2 75%),
    #ffffff;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.badge {
  position: absolute;
  right: 8px;
  top: 8px;
  max-width: calc(100% - 16px);
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: #ffffff;
  background: rgba(23, 33, 43, 0.78);
  font-size: 0.72rem;
  font-weight: 800;
}

.badge.ready {
  background: rgba(15, 118, 110, 0.9);
}

.badge.error {
  background: rgba(180, 35, 24, 0.9);
}

.card-body {
  padding: 11px;
}

.image-name-control {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.image-name-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--ink);
  background: #fbfcfc;
  font-weight: 800;
  outline: none;
}

.image-name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.card-body dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.card-body dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(292px, 360px) minmax(0, 1fr);
  }

  .settings-panel {
    grid-column: 1;
  }

  .image-board {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .app-header {
    align-items: flex-start;
  }

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

  .settings-panel,
  .image-board {
    grid-column: auto;
    grid-row: auto;
  }

  .image-board {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  .app-header {
    display: grid;
  }

  .status-pill {
    max-width: 100%;
    width: 100%;
  }

  .button-grid,
  .action-row,
  .dimension-grid,
  .format-grid {
    grid-template-columns: 1fr;
  }

  .drop-actions,
  .preset-row,
  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented label:last-child {
    grid-column: 1 / -1;
  }

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