:root {
  color-scheme: light;
  --bg: #f3eee6;
  --card: #fffdf9;
  --ink: #241c17;
  --muted: #5e5148;
  --line: #e4d8cc;
  --etsy: #f1641e;
  --etsy-ink: #9a3d0c;
  --etsy-soft: #fff1e8;
  --good: #0f7a4a;
  --bad: #a3261c;
  --shadow: 0 10px 30px rgba(60, 36, 16, 0.06);
  --header: #fffdf9;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161210;
  --card: #241c18;
  --ink: #f6efe8;
  --muted: #cbbbae;
  --line: #3b302a;
  --etsy: #ff8a4c;
  --etsy-ink: #ffd2bc;
  --etsy-soft: #3a2418;
  --good: #7ddea8;
  --bad: #ffb4ab;
  --shadow: none;
  --header: #1d1714;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: "Segoe UI", "Avenir Next", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

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

button { cursor: pointer; }

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

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header);
  border-bottom: 1px solid var(--line);
}

.bar, .presets, .tabs, .shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 0;
}

.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }

.mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--etsy);
  color: #fff;
  font-weight: 700;
  flex: none;
}

.brand h1 { font-size: 1.05rem; line-height: 1.2; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--etsy-soft);
  color: var(--etsy-ink);
}

.tagline { color: var(--muted); }

.tools { display: flex; gap: 8px; align-items: center; }

.langs, .presets, .filters { display: flex; gap: 6px; align-items: center; }
.filters { overflow-x: auto; }

.presets {
  padding: 8px 16px 0;
  overflow-x: auto;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 16px;
}

.tab, .chip, .ghost, .primary, .langs button, #theme-toggle {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.tab.active, .chip.active, .langs button.active {
  background: var(--etsy);
  border-color: var(--etsy);
  color: #fff;
}

.shell { padding: 8px 16px 120px; }

.view { display: grid; gap: 12px; }

.grid { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 12px; align-items: start; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stack { display: grid; gap: 10px; }

label { display: grid; gap: 4px; font-weight: 600; }

.hint, .status { color: var(--muted); font-weight: 400; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

textarea { min-height: 160px; resize: vertical; }

.primary {
  background: var(--etsy);
  border-color: var(--etsy);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
}

.row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

.tags, .titles, .list, .bars { display: grid; gap: 8px; }

.pick {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.pick input { width: auto; }

.tag, .title, .check, .product, .comp-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.tag span, .title p, .check div { min-width: 0; overflow-wrap: anywhere; }

.metric { text-align: center; }
.metric strong { display: block; font-size: 1.6rem; }
.metric .good { color: var(--good); }
.metric .bad { color: var(--bad); }
.metric .etsy { color: var(--etsy); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

.warning {
  border: 1px solid var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, var(--card));
  border-radius: 12px;
  padding: 12px;
}

.bar-track { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--etsy); }
.bar-fill.mine { background: var(--ink); }

.files { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.files label { font-weight: 500; grid-template-columns: auto 1fr; align-items: center; }

#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  background: var(--bg);
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--etsy);
  animation: spin 0.8s linear infinite;
}

.skeleton, .skeleton.short {
  width: min(420px, 80vw);
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--line), var(--card), var(--line));
  background-size: 200% 100%;
  animation: sheen 1.2s linear infinite;
}

.skeleton.short { width: min(220px, 50vw); }

#pencil {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--etsy);
  color: #fff;
  overflow: visible;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

#pencil svg { width: 20px; height: 20px; flex: none; }

#toast {
  position: fixed;
  right: 16px;
  bottom: 80px;
  z-index: 80;
  max-width: min(320px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

#toast.show { opacity: 1; transform: none; }

#notes-panel {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 65;
  width: min(360px, calc(100vw - 180px));
}

/* Toast and pencil stay in the footer so they cannot cover a tag row. */
html, body { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
header { position: static; flex: none; }
.shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 16px;
}
#dock {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 8px 16px 16px;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-sizing: border-box;
}
#notes-panel, #toast, #pencil {
  position: static;
  right: auto;
  bottom: auto;
  width: auto;
  max-width: min(420px, 100%);
  transform: none;
}
#notes-panel { width: 100%; max-width: 100%; }
#toast {
  display: none;
  opacity: 1;
  pointer-events: none;
}
#toast.show { display: block; }
#pencil { overflow: visible; white-space: nowrap; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sheen { to { background-position: -200% 0; } }

@media (max-width: 800px) {
  .grid, .grid-2, .grid-3, .files:not(label) { grid-template-columns: 1fr; }
  .bar { align-items: flex-start; }
  .tools { flex-wrap: wrap; justify-content: flex-end; }
}
