:root {
  color-scheme: light;
  --ink: #22303a;
  --muted: #61707c;
  --line: #d9e0e5;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --aqua: #4fa3a5;
  --coral: #df755f;
  --gold: #d9a93f;
  --green: #597f5d;
  --accent: #d72ab4;
  --accent-soft: #f0e6f1;
  --shadow: 0 14px 40px rgba(34, 48, 58, .12);
}

body[data-accent="teal"] {
  --accent: #4fa3a5;
  --accent-soft: #e0f0ef;
}

body[data-accent="ink"] {
  --accent: #22303a;
  --accent-soft: #e9edf2;
}

body[data-accent="gold"] {
  --accent: #d9a93f;
  --accent-soft: #fbf0ce;
}

body[data-theme="boutique"] {
  --paper: #fff7fb;
  --panel: #fff;
  --ink: #2e2430;
  --muted: #796a78;
  --line: #eadce7;
  --shadow: 0 18px 48px rgba(88, 42, 78, .16);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --paper: #11171b;
  --panel: #182127;
  --ink: #edf3f6;
  --muted: #a8b4bb;
  --line: #2d3a41;
  --accent-soft: rgba(255, 255, 255, .09);
  --shadow: 0 20px 58px rgba(0, 0, 0, .34);
}

body[data-theme="minimal"] {
  --paper: #fff;
  --panel: #fff;
  --line: #e8ecef;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

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

body[data-font-style="classic"] {
  font-family: Georgia, "Times New Roman", serif;
}

body[data-font-style="compact"] {
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

.restore-settings {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 40;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 900;
  box-shadow: var(--shadow);
  display: none;
}

body[data-sidebar-style="hidden"] .restore-settings {
  display: inline-flex;
  align-items: center;
}

body[data-sidebar-style="hidden"] .main-area {
  padding-top: 74px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  min-height: 100vh;
}

body[data-sidebar-style="hidden"] .app-shell,
body[data-editor="hidden"] .content-grid {
  grid-template-columns: 1fr;
}

.sidebar {
  background: #edf4f2;
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body[data-sidebar-style="white"] .sidebar {
  background: var(--panel);
}

body[data-sidebar-style="dark"] .sidebar {
  background: #182127;
  color: #edf3f6;
}

body[data-sidebar-style="dark"] .sidebar .brand p,
body[data-sidebar-style="dark"] .sidebar .fine-print {
  color: #b8c4ca;
}

body[data-sidebar-style="hidden"] .sidebar,
body[data-editor="hidden"] .editor,
body[data-summary="hidden"] .summary-list {
  display: none;
}

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

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.brand-mark svg {
  width: 42px;
  height: 42px;
}

.brand-mark svg path:first-child {
  fill: var(--accent);
}

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

h1 {
  font-size: 25px;
  line-height: 1.05;
}

.brand p,
.fine-print,
.empty-state span {
  color: var(--muted);
}

.sync-panel,
.editor,
.inventory {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

body[data-card-shape="square"] .sync-panel,
body[data-card-shape="square"] .editor,
body[data-card-shape="square"] .inventory,
body[data-card-shape="square"] .item-card,
body[data-card-shape="square"] input,
body[data-card-shape="square"] select,
body[data-card-shape="square"] textarea,
body[data-card-shape="square"] details,
body[data-card-shape="square"] .collection-tab {
  border-radius: 0;
}

body[data-card-shape="rounded"] .sync-panel,
body[data-card-shape="rounded"] .editor,
body[data-card-shape="rounded"] .inventory,
body[data-card-shape="rounded"] .item-card,
body[data-card-shape="rounded"] input,
body[data-card-shape="rounded"] select,
body[data-card-shape="rounded"] textarea,
body[data-card-shape="rounded"] details,
body[data-card-shape="rounded"] .collection-tab {
  border-radius: 16px;
}

.sync-panel {
  padding: 16px;
}

.panel-heading,
.editor-header,
.inventory-head,
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2,
.editor-header h2,
.inventory-head h2 {
  font-size: 17px;
}

.status-pill {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.offline {
  color: #7b3f32;
  background: #ffe5dd;
}

.status-pill.online {
  color: #24543b;
  background: #dff0df;
}

.status-pill.busy {
  color: #6a4a0c;
  background: #fff0bf;
}

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

label {
  display: grid;
  gap: 6px;
  color: #3a4851;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5db;
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 11px;
  min-height: 42px;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] details {
  background: #10161a;
  color: var(--ink);
  border-color: #34444c;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(79, 163, 165, .24);
  border-color: var(--aqua);
}

details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #f7fbfa;
}

summary {
  font-weight: 800;
  cursor: pointer;
}

.field-map,
.table-settings,
.appearance-settings,
.backup-settings {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.field-map {
  grid-template-columns: 1fr 1fr;
}

.table-settings {
  grid-template-columns: 1fr;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.appearance-settings {
  grid-template-columns: 1fr;
}

.backup-settings {
  grid-template-columns: 1fr;
}

.table-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 9px;
}

.table-fieldset legend {
  padding: 0 5px;
  font-weight: 900;
}

.field-map label,
.table-fieldset label {
  font-size: 12px;
}

.primary-action,
.secondary-action,
.danger-action,
.icon-button {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

.primary-action {
  background: var(--ink);
  color: #fff;
}

.secondary-action {
  background: #e5eeee;
  color: var(--ink);
  padding: 0 14px;
}

.danger-action {
  background: #ffe1da;
  color: #8a3120;
  padding: 0 14px;
}

.icon-button {
  width: 40px;
  background: #edf1f3;
  color: var(--ink);
  font-size: 22px;
}

.fine-print {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.35;
}

.sync-details {
  margin-top: 10px;
  border: 1px solid #f0c77c;
  background: #fff7e8;
  color: #604415;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.summary-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  border-radius: 8px;
  padding: 12px;
}

.summary-item strong {
  font-size: 22px;
}

.main-area {
  padding: 24px;
  overflow: hidden;
}

body[data-density="airy"] .main-area,
body[data-density="airy"] .sidebar {
  padding: 34px;
}

body[data-density="dense"] .main-area,
body[data-density="dense"] .sidebar {
  padding: 14px;
}

body[data-density="dense"] .content-grid,
body[data-density="dense"] .toolbar,
body[data-density="dense"] .item-grid {
  gap: 9px;
}

.collection-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.collection-tab {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 900;
}

.collection-tab span {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}

.collection-tab strong {
  color: var(--muted);
}

.collection-tab.active {
  border-color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.collection-tab.dragging {
  opacity: .55;
}

.collection-tab.drop-target {
  outline: 3px solid rgba(215, 42, 180, .22);
  outline-offset: 3px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(170px, 210px) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.search-wrap {
  position: relative;
}

.search-wrap span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-wrap input {
  padding-left: 36px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 18px;
  align-items: start;
}

.editor {
  padding: 16px;
  position: sticky;
  top: 24px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inventory {
  padding: 16px;
  min-height: 600px;
}

.inventory-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.inventory-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  background: #fff;
}

.view-button {
  border: 0;
  min-height: 38px;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.view-button.active {
  background: var(--ink);
  color: #fff;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

body[data-card-size="compact"] .item-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

body[data-card-size="large"] .item-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  min-width: 0;
}

.item-card.no-image .card-body {
  padding-top: 15px;
}

.card-edit {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  width: 100%;
  text-align: left;
}

.card-edit:hover h3 {
  text-decoration: underline;
}

.photo-frame {
  aspect-ratio: 4 / 5;
  background: #f3f5f6;
  display: grid;
  place-items: center;
  overflow: hidden;
}

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

body[data-image-fit="contain"] .photo-frame img,
body[data-image-fit="contain"] .image-open img {
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #fff;
  display: block;
}

body[data-image-fit="contain"] .photo-frame {
  aspect-ratio: auto;
  display: block;
  padding: 0;
  overflow: visible;
}

body[data-image-fit="contain"] .image-open {
  height: auto;
}

body[data-theme="dark"][data-image-fit="contain"] .photo-frame img,
body[data-theme="dark"][data-image-fit="contain"] .image-open img {
  background: #10161a;
}

.image-open {
  border: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  display: block;
}

.image-open:hover img {
  transform: scale(1.03);
}

.image-open img {
  transition: transform .18s ease;
}

.category-art {
  width: 70%;
  max-width: 160px;
  height: auto;
}

.fallback-art {
  width: 74px;
  height: 74px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
  font-size: 22px;
}

.card-body {
  padding: 13px;
  display: grid;
  gap: 9px;
}

.category-chip {
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 5px 9px;
}

.category-chip.shoes {
  background: var(--coral);
}

.category-chip.dress {
  background: var(--green);
}

.favorite-flag {
  color: var(--gold);
  font-size: 18px;
}

.card-body h3 {
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-list span {
  border-radius: 999px;
  padding: 5px 8px;
  background: #e9edf2;
  color: #34424c;
  font-size: 12px;
  font-weight: 800;
}

body[data-card-size="compact"] .card-body {
  padding: 10px;
  gap: 7px;
}

body[data-card-size="compact"] .card-body h3 {
  font-size: 14px;
}

body[data-card-size="compact"] .chip-list span,
body[data-card-size="compact"] .notes {
  font-size: 11px;
}

body[data-card-size="large"] .card-body h3 {
  font-size: 18px;
}

body[data-density="dense"] .card-body {
  padding: 10px;
  gap: 7px;
}

body[data-density="airy"] .card-body {
  padding: 18px;
  gap: 12px;
}

.notes {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.empty-state {
  border: 1px dashed #b9c5ca;
  border-radius: 8px;
  padding: 34px;
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 6px;
}

.table-view {
  overflow: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-view table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

.table-view th,
.table-view td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

.table-view th {
  background: #f5f7f8;
  font-weight: 900;
}

.table-view tr {
  cursor: pointer;
}

.table-view tr:hover td {
  background: #f8fbfb;
}

.table-view img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 20;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.modal-open {
  overflow: hidden;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 22, 28, .74);
}

.modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  display: grid;
  gap: 10px;
  justify-items: center;
}

.modal-panel img {
  max-width: 100%;
  max-height: calc(100vh - 126px);
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
  font-weight: 800;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  z-index: 1;
}

.modal-caption {
  max-width: min(720px, 100%);
  color: #fff;
  text-align: center;
  font-weight: 800;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .app-shell,
  .content-grid {
    grid-template-columns: 1fr;
  }

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

  .editor {
    position: static;
  }

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

@media (max-width: 680px) {
  .sidebar,
  .main-area {
    padding: 16px;
  }

  .two-col,
  .field-map {
    grid-template-columns: 1fr;
  }

  .collection-tab {
    padding: 0 10px;
  }

  .image-modal {
    padding: 14px;
  }

  .modal-close {
    top: 6px;
    right: 6px;
  }
}
