:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #68645d;
  --line: #ded9cf;
  --accent: #176b63;
  --accent-soft: #dcefeb;
  --warn: #8b4e18;
  --shadow: 0 14px 40px rgba(39, 35, 28, 0.12);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 88px;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 4;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.15;
  margin: 0 0 4px;
}

p {
  color: var(--muted);
  margin: 0;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stats span {
  background: var(--accent-soft);
  border: 1px solid #c5ded9;
  border-radius: 8px;
  color: #174640;
  padding: 8px 10px;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 88px);
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
button,
.command {
  font: inherit;
}

input,
select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

.segmented {
  background: #eee9df;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  min-height: 34px;
  padding: 0 8px;
}

.segmented button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(38, 35, 29, 0.12);
}

.command {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
}

.command.secondary {
  background: var(--panel);
  color: var(--accent);
}

.content {
  padding: 22px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  grid-template-rows: 160px minmax(168px, auto);
  min-width: 0;
  overflow: hidden;
}

.thumb {
  align-items: center;
  background: #e8e3da;
  display: flex;
  height: 160px;
  justify-content: center;
}

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

.not-image {
  color: var(--warn);
  font-weight: 700;
}

.meta {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.inventory-number {
  align-items: center;
  background: #1f1f1d;
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-weight: 800;
  justify-content: center;
  letter-spacing: 0;
  min-height: 30px;
  padding: 4px 8px;
  width: fit-content;
}

.sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.price {
  background: #f1f7f5;
  border: 1px solid #cfe5df;
  border-radius: 6px;
  color: #124f47;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  padding: 6px;
}

.collection-badge {
  background: #fff4d8;
  border: 1px solid #ecd28d;
  border-radius: 6px;
  color: #715315;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  padding: 6px;
}

.file-chip {
  align-self: end;
  background: #f4f1ea;
  border-radius: 6px;
  color: #746d62;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.2;
  margin-top: auto;
  overflow: hidden;
  padding: 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  min-height: 180px;
  justify-content: center;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: min(1100px, calc(100vw - 36px));
  padding: 0;
  width: 100%;
}

dialog::backdrop {
  background: rgba(20, 19, 17, 0.62);
}

.dialog-grid {
  background: var(--panel);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  max-height: min(760px, calc(100vh - 36px));
}

figure {
  align-items: center;
  background: #111;
  display: flex;
  justify-content: center;
  margin: 0;
  min-height: 360px;
  overflow: auto;
}

figure img {
  max-height: calc(100vh - 36px);
  max-width: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 140ms ease;
}

.details {
  overflow: auto;
  padding: 22px;
  position: relative;
}

.icon-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 24px;
  height: 38px;
  line-height: 1;
  position: absolute;
  right: 16px;
  top: 16px;
  width: 38px;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0 48px 18px 0;
  overflow-wrap: anywhere;
}

.rotate-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.rotate-tools .command {
  min-height: 34px;
  padding: 0 10px;
}

#rotationValue {
  background: #f4f1ea;
  border-radius: 6px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  padding: 8px 10px;
}

dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

@media (max-width: 820px) {
  .topbar,
  .layout,
  .dialog-grid {
    display: block;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }

  .topbar {
    position: static;
  }

  .stats {
    justify-content: flex-start;
    margin-top: 14px;
  }
}
