:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #26302c;
  background: #f5f2eb;
  --green: #275b4d;
  --paper: #fffef9;
  --line: #d7d0c3;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input, .action-button { font: inherit; }
button, .action-button { cursor: pointer; }
.visually-hidden { position: fixed; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  color: white;
  background: var(--green);
  border-bottom: 4px solid #d49b5c;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
h2 { margin-bottom: 12px; font-size: 15px; }
.eyebrow { margin-bottom: 2px; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; opacity: .75; }
.actions { display: flex; gap: 8px; }
button, .action-button {
  display: inline-block;
  padding: 9px 13px;
  color: white;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 7px;
  font-weight: 650;
  line-height: normal;
  text-decoration: none;
}
header button, header .action-button { color: #24483e; background: #fff; border-color: transparent; }
button.quiet, .action-button.quiet { color: #34423d; background: transparent; border-color: #b9b3a8; }
header button.quiet, header .action-button.quiet { color: white; border-color: rgba(255,255,255,.45); }

main {
  height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: 240px minmax(560px, 1fr) 310px;
}
aside { overflow-y: auto; background: #fbfaf6; }
aside section { padding: 20px; border-bottom: 1px solid var(--line); }
.tools { border-right: 1px solid var(--line); }
.colors { border-left: 1px solid var(--line); }
.hint { color: #6d756f; font-size: 12px; line-height: 1.45; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.choice-grid button { color: #3c4944; background: white; border-color: var(--line); }
.choice-grid button.active { color: white; background: var(--green); border-color: var(--green); }
.dimensions { margin-top: 10px; padding: 10px; background: #eeeae1; border-radius: 8px; font-size: 12px; }
.dimensions label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.dimensions input { width: 68px; padding: 5px; }
.dimensions button { width: 100%; margin-top: 3px; }

.pan-choices { display: grid; gap: 8px; }
.pan-choice {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: grab;
}
.pan-icon { display: inline-block; flex: 0 0 auto; background: #f8f8f5; border: 2px solid #9da49f; border-radius: 3px; box-shadow: inset 0 0 0 2px white; }
.pan-copy strong, .pan-copy small { display: block; }
.pan-copy strong { font-size: 12px; }
.pan-copy small { margin-top: 2px; color: #7a817d; font-size: 10px; }

.workspace { min-width: 0; display: flex; flex-direction: column; background: #e8e4dc; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; height: 54px; padding: 0 20px; background: rgba(255,255,255,.55); border-bottom: 1px solid #d3cec5; font-weight: 750; }
.workspace-heading small { display: block; margin-top: 2px; color: #777f7a; font-size: 10px; font-weight: 500; }
.workspace-action { padding: 6px 9px; font-size: 11px; white-space: nowrap; }
.stage { min-height: 0; flex: 1; display: grid; place-items: center; padding: 36px; overflow: auto; }
#palette {
  position: relative;
  background: linear-gradient(145deg, #d9d9d6, #f5f5f1 45%, #c8c9c5);
  border: 1px solid #aeb0ac;
  border-radius: 10px;
  box-shadow: 0 22px 40px rgba(50,47,39,.22), inset 0 0 0 4px rgba(255,255,255,.45);
}
#palette::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(90,95,91,.3); border-radius: 6px; pointer-events: none; }
#tray {
  position: absolute;
  background-color: #666b68;
  background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  border-radius: 3px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,.35);
}
.workspace-help { margin: 0; padding: 10px 20px; color: #727973; background: rgba(255,255,255,.6); border-top: 1px solid #d3cec5; font-size: 11px; text-align: center; }

.placed-pan {
  position: absolute;
  overflow: hidden;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  caret-color: transparent;
  background: #f7f6f1;
  border: 2px solid #a6aaa6;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,.24), inset 0 0 0 2px rgba(255,255,255,.72);
}
.placed-pan * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  caret-color: transparent;
}
.placed-pan.selected { outline: 3px solid #e9a74f; outline-offset: 2px; }
.placed-pan img { width: 100%; height: 100%; display: block; object-fit: cover; pointer-events: none; }
.placed-pan .pan-label { position: absolute; inset: auto 0 0; max-height: 100%; padding: 3px 3px 2px; overflow: hidden; color: #17201c; background: rgba(255,255,255,.9); border-radius: 0 0 2px 2px; font-size: 8px; line-height: 1.1; pointer-events: none; }
.pan-color-name { display: block; overflow: hidden; font-size: 8px; font-weight: 800; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.placed-pan .pan-label small { display: flex; justify-content: space-between; gap: 2px; margin-top: 2px; overflow: hidden; color: #48514d; font-size: 7px; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; white-space: nowrap; }
.placed-pan.mixing { background: linear-gradient(135deg, #fff, #ecece8); }
.placed-pan.swatch-hidden { background: #fff; }
.placed-pan.mixing::after { content: "MIX"; position: absolute; inset: 0; display: grid; place-items: center; color: #b6bab7; font-size: 10px; font-weight: 900; letter-spacing: .12em; }

.search span { display: block; margin-bottom: 5px; color: #69716d; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.color-heading { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.color-heading h2 { margin-top: 5px; }
.color-heading > div { display: flex; gap: 4px; }
.small-action { min-width: 66px; padding: 4px 6px; color: #53605b; background: white; border: 1px solid #d4cfc5; border-radius: 5px; font-size: 9px; font-weight: 650; line-height: 1.15; text-decoration: none; white-space: normal; }
.small-action span { display: block; }
button.small-action { cursor: pointer; }
.search input, #dialogSearch { width: 100%; padding: 10px 11px; border: 1px solid #bdb8ae; border-radius: 7px; outline: none; }
.search input:focus, #dialogSearch:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(39,91,77,.12); }
.filters { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.filters button { padding: 5px 8px; color: #53605b; background: white; border-color: #d4cfc5; font-size: 10px; }
.filters button.active { color: white; background: var(--green); border-color: var(--green); }
#colorCount { margin: 9px 0 6px; }
.color-list { display: grid; gap: 5px; }
.color-card {
  display: grid;
  grid-template-columns: 51px 1fr;
  gap: 9px;
  min-height: 49px;
  padding: 5px;
  background: white;
  border: 1px solid #ddd8ce;
  border-radius: 7px;
  cursor: grab;
}
.color-card:hover { border-color: #8eaaa1; }
.color-card img { width: 51px; height: 38px; object-fit: cover; border-radius: 3px; }
.color-card strong { display: block; margin-top: 2px; font-size: 11px; line-height: 1.2; }
.color-card small { display: block; margin-top: 4px; color: #777f7b; font-size: 9px; }

.context-menu { position: fixed; z-index: 20; width: 175px; padding: 5px; background: white; border: 1px solid #ccc7bd; border-radius: 8px; box-shadow: 0 9px 25px rgba(0,0,0,.2); }
.context-menu button { width: 100%; padding: 8px; color: #303a36; background: transparent; border: 0; text-align: left; font-size: 12px; }
.context-menu button:hover { background: #eeeae2; }
.context-menu button.danger { color: #a0362d; }
.pan-drag-image { position: fixed; left: -1000px; top: -1000px; z-index: -1; background: #f7f6f1; border: 2px solid #a6aaa6; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,.24), inset 0 0 0 2px rgba(255,255,255,.72); }
.color-drag-image { position: fixed; left: -1000px; top: -1000px; z-index: -1; width: 51px; height: 38px; object-fit: cover; border-radius: 3px; }

dialog { width: min(720px, 88vw); height: min(680px, 88vh); padding: 0; border: 0; border-radius: 12px; box-shadow: 0 25px 70px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(25,31,28,.55); }
dialog form { height: 100%; display: flex; flex-direction: column; padding: 20px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; }
.dialog-head h2 { font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.icon-button { padding: 2px 8px; color: #58615d; background: transparent; border: 0; font-size: 26px; }
.dialog-colors { min-height: 0; flex: 1; display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 7px; margin-top: 12px; overflow-y: auto; }
.dialog-color { display: grid; grid-template-columns: 60px 1fr; gap: 9px; padding: 6px; color: #2b3531; background: white; border: 1px solid #d9d4ca; text-align: left; }
.dialog-color img { width: 60px; height: 43px; object-fit: cover; }
.dialog-color strong { display: block; font-size: 11px; }
.dialog-color small { color: #757d78; font-size: 9px; }
.info-dialog { width: min(620px, 88vw); height: auto; max-height: 88vh; }
.info-content { overflow-y: auto; }
.info-swatch { width: 100%; height: 130px; margin-bottom: 14px; object-fit: cover; border-radius: 8px; }
.info-color-title { margin: -3px 0 14px; font-family: Georgia, serif; font-size: 22px; font-weight: 500; text-align: center; }
.info-content dl { margin: 0; }
.info-content dl div { display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); }
.info-content dt { color: #68716c; font-size: 11px; font-weight: 750; }
.info-content dd { margin: 0; font-size: 12px; }
.save-dialog { width: min(470px, 88vw); height: auto; }
.csv-download-dialog { width: min(620px, 88vw); height: auto; }
.message-dialog { width: min(470px, 88vw); height: fit-content; min-height: 0; max-height: 88vh; }
.message-dialog form, .save-dialog form, .csv-download-dialog form, .info-dialog form { height: auto; }
.message-dialog .dialog-head h2 { margin-top: 3px; }
.message-text { margin: 8px 0 2px; color: #3f4945; font-size: 14px; line-height: 1.5; white-space: pre-line; }
.csv-explanation { color: #3f4945; font-size: 13px; line-height: 1.55; }
.csv-explanation p { margin: 0 0 12px; }
.save-name { display: grid; gap: 6px; color: #68716c; font-size: 11px; font-weight: 750; }
.save-name input { width: 100%; padding: 10px 11px; color: #26302c; background: white; border: 1px solid #bdb8ae; border-radius: 7px; font-size: 14px; font-weight: 500; }
.save-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.save-status { min-height: 18px; margin: 12px 0 0; color: var(--green); font-size: 12px; text-align: right; }

button, input, .pan-choice, .placed-pan, .color-card { touch-action: manipulation; }
#tray { touch-action: none; }

@media (max-width: 1100px) {
  main { grid-template-columns: 200px minmax(480px, 1fr) 260px; }
  aside section { padding: 13px; }
  .stage { padding: 20px; }
  header { padding: 0 16px; }
  .color-heading { display: block; }
  .color-heading > div { margin-bottom: 10px; }
}

@media (max-width: 800px) {
  header { height: auto; min-height: 72px; gap: 12px; padding-block: 10px; }
  header .actions { flex-wrap: wrap; justify-content: flex-end; }
  main { height: auto; display: grid; grid-template-columns: 1fr; }
  .workspace { order: 1; min-height: 520px; }
  .tools { order: 2; border-right: 0; }
  .colors { order: 3; border-left: 0; }
  aside { overflow: visible; }
  .tools section, .colors section { border-top: 1px solid var(--line); }
  .pan-choices { grid-template-columns: 1fr 1fr; }
}

#printSheet { display: none; }

@page { size: Letter; margin: 0; }

@media print {
  body > :not(#printSheet) { display: none !important; }
  html, body { width: 215.9mm; height: 279.4mm; min-width: 0; margin: 0; background: white; }
  #printSheet { position: relative; display: block; width: 215.9mm; height: 279.4mm; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #printPalette { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); overflow: hidden; border: .25mm solid #777; }
  #printPalette .placed-pan { box-shadow: none; outline: 0; }
}
