:root {
  color-scheme: light;
  --ink: #16181f;
  --muted: #667085;
  --line: #d9dee8;
  --panel: #ffffff;
  --surface: #e8edf4;
  --stage: #d9e0ea;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --gold: #c99a2e;
  --black: #050505;
  --shadow: 0 18px 48px rgba(18, 24, 40, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--surface);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 76px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand-logo,
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
}

.brand-logo {
  object-fit: cover;
  border: 2px solid rgba(201, 154, 46, 0.78);
  background: #111111;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 24px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1;
}

.brand strong {
  font-size: 20px;
}

.brand small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline: auto;
  min-width: 0;
}

.site-nav a,
.site-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  color: #3b3f48;
  text-decoration: none;
  font-size: 14px;
  font-weight: 780;
  line-height: 1;
  white-space: nowrap;
}

.site-nav a {
  padding: 0 12px;
}

.site-nav a:hover,
.site-home-link:hover {
  background: rgba(201, 154, 46, 0.13);
  color: #8a6110;
}

.site-home-link {
  gap: 7px;
  padding: 0 13px;
  border: 1px solid rgba(16, 24, 40, 0.13);
  background: #ffffff;
}

.site-home-link svg {
  width: 18px;
  height: 18px;
}

.topbar-actions,
.button-row,
.camera-tools,
.view-controls,
.rotation-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(420px, 1fr) minmax(240px, 300px);
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.controls-panel,
.summary-panel {
  align-self: stretch;
  overflow: hidden;
}

.mobile-tool-tabs {
  display: none;
}

.control-section {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child {
  border-bottom: 0;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  font-weight: 750;
}

.section-title output,
.hint,
.label,
.spec-list span {
  color: var(--muted);
  font-size: 13px;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(34px, 1fr));
  gap: 10px;
  margin-bottom: 0;
}

.swatch {
  height: 34px;
  border: 1px solid rgba(16, 24, 40, 0.16);
  border-radius: 7px;
  position: relative;
  padding: 0;
  outline-offset: 3px;
}

.swatch.is-selected::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 5px;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.45);
}

.color-picker,
.range-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.color-picker input {
  width: 54px;
  height: 36px;
  border: 0;
  padding: 0;
  background: transparent;
}

.range-control {
  display: grid;
  grid-template-columns: auto 1fr auto;
}

.range-control input {
  width: 100%;
  accent-color: var(--accent);
}

.range-control.compact {
  margin-top: 14px;
}

.upload-zone {
  min-height: 112px;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
  border: 1.5px dashed #a9b4c5;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
}

.upload-zone.has-file {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #edfdf9;
}

.hint {
  margin: 12px 0 0;
  line-height: 1.45;
}

.icon-button,
.action-button,
.secondary-button,
.view-button,
.rotation-button,
.stage-rotate-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.action-button,
.secondary-button,
.view-button {
  padding: 0 14px;
  font-weight: 720;
}

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

.secondary-button {
  flex: 1;
}

.button-row.single-action .secondary-button {
  width: 100%;
}

.icon-button:hover,
.secondary-button:hover,
.view-button:hover,
.rotation-button:hover,
.stage-rotate-button:hover {
  border-color: #aeb8c7;
  background: #f7f9fc;
}

.icon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f3f6fa;
}

.icon-button:disabled:hover {
  border-color: var(--line);
  background: #f3f6fa;
}

.action-button:hover {
  background: #2a2e39;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.view-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.view-button {
  min-height: 42px;
}

.view-button.is-active {
  background: #e9f8f6;
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--accent-strong);
}

.rotation-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.rotation-button {
  min-height: 46px;
  color: var(--accent-strong);
}

.rotation-button svg {
  width: 24px;
  height: 24px;
}

.stage {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 36%),
    radial-gradient(circle at 74% 20%, rgba(37, 99, 235, 0.12), transparent 28%),
    var(--stage);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  cursor: crosshair;
}

.stage-rotation {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.stage-rotate-button {
  --arrow-x: 0;
  --arrow-y: 0;
  position: absolute;
  width: 54px;
  min-height: 54px;
  padding: 0;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(190, 200, 215, 0.92);
  box-shadow: 0 14px 32px rgba(18, 24, 40, 0.16);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  transform: translate(var(--arrow-x), var(--arrow-y));
}

.stage-rotate-button svg {
  width: 28px;
  height: 28px;
  stroke-width: 2.4;
}

.stage-rotate-button:active {
  transform: translate(var(--arrow-x), calc(var(--arrow-y) + 1px));
}

.rotate-left,
.rotate-right {
  top: 50%;
  --arrow-y: -50%;
}

.rotate-left {
  left: 18px;
}

.rotate-right {
  right: 18px;
}

.rotate-up,
.rotate-down {
  left: 50%;
  --arrow-x: -50%;
}

.rotate-up {
  top: 20px;
}

.rotate-down {
  bottom: 22px;
}

.stage-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.stage-toolbar > * {
  pointer-events: auto;
}

.stage-toolbar div:first-child {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(217, 222, 232, 0.8);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.stage-toolbar strong {
  font-size: 14px;
}

.stage-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.summary-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.design-card {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.design-card h1 {
  margin: 8px 0 10px;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: 0;
}

.design-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.spec-list {
  padding: 18px 22px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.spec-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.spec-list strong {
  text-align: right;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 300px 1fr;
  }

  .summary-panel {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    overscroll-behavior: none;
  }

  .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    grid-template-rows: 56px minmax(0, 1fr);
    overflow: hidden;
  }

  .topbar {
    position: relative;
    height: 56px;
    padding: 8px 10px;
    align-items: center;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo,
  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .brand-mark {
    font-size: 20px;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand small {
    display: none;
  }

  .site-nav {
    justify-self: stretch;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 2px;
    margin-inline: 0;
    padding-inline: 2px;
  }

  .site-nav::-webkit-scrollbar {
    display: none;
  }

  .site-nav a {
    min-height: 36px;
    padding: 0 9px;
    font-size: 13px;
  }

  .topbar-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 8px;
  }

  .site-home-link {
    display: none;
  }

  .action-button {
    min-height: 40px;
    padding: 0 12px;
  }

  .workspace {
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
    overflow: hidden;
  }

  .stage {
    order: 0;
    min-height: 0;
    height: 100%;
  }

  .stage canvas {
    height: 100%;
    min-height: 0;
    touch-action: none;
  }

  .stage-toolbar {
    top: 8px;
    left: 8px;
    right: 8px;
    align-items: flex-start;
    gap: 8px;
  }

  .stage-toolbar div:first-child {
    max-width: calc(100% - 92px);
    min-height: 38px;
    padding: 8px 10px;
    align-content: center;
  }

  .stage-toolbar strong {
    font-size: 13px;
  }

  .stage-toolbar span {
    display: none;
    font-size: 11px;
  }

  .camera-tools {
    gap: 6px;
  }

  .camera-tools .icon-button {
    width: 38px;
    min-height: 38px;
  }

  .stage-rotate-button {
    width: 46px;
    min-height: 46px;
    border-radius: 8px;
  }

  .stage-rotate-button svg {
    width: 24px;
    height: 24px;
  }

  .rotate-left {
    left: 8px;
  }

  .rotate-right {
    right: 8px;
  }

  .rotate-up {
    top: 54px;
  }

  .rotate-down {
    bottom: 10px;
  }

  .controls-panel {
    order: 1;
    min-height: 214px;
    height: min(38dvh, 256px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .mobile-tool-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
  }

  .mobile-tool-tab {
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-weight: 760;
  }

  .mobile-tool-tab.is-active {
    background: #ffffff;
    border-color: var(--line);
    color: var(--ink);
    box-shadow: 0 6px 18px rgba(18, 24, 40, 0.08);
  }

  .control-section {
    display: none;
    min-height: 0;
    padding: 12px;
    overflow: auto;
    border-bottom: 0;
  }

  .controls-panel[data-mobile-tab="color"] [data-tool-panel="color"],
  .controls-panel[data-mobile-tab="print"] [data-tool-panel="print"],
  .controls-panel[data-mobile-tab="view"] [data-tool-panel="view"] {
    display: block;
  }

  .section-title {
    margin-bottom: 8px;
    font-size: 14px;
  }

  .swatch-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 0;
  }

  .swatch {
    height: 30px;
    min-height: 30px;
  }

  .color-picker,
  .range-control {
    font-size: 13px;
  }

  .color-picker input {
    width: 48px;
    height: 30px;
  }

  .upload-zone {
    min-height: 56px;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    font-size: 13px;
  }

  .upload-zone svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
  }

  .range-control {
    gap: 8px;
  }

  .range-control.compact {
    margin-top: 9px;
  }

  .button-row {
    margin-top: 8px;
  }

  .secondary-button {
    min-height: 36px;
    font-size: 13px;
  }

  .hint {
    display: none;
  }

  .view-controls {
    gap: 7px;
  }

  .view-button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 13px;
  }

  .rotation-controls {
    margin-top: 8px;
    gap: 7px;
  }

  .rotation-button {
    min-height: 42px;
  }

  .summary-panel {
    display: none;
  }
}

@media (max-width: 480px) {
  .app-shell {
    grid-template-rows: 52px minmax(0, 1fr);
  }

  .workspace {
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    height: 52px;
    padding: 7px 8px;
  }

  .brand-logo,
  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .brand-mark {
    font-size: 19px;
  }

  .brand span {
    display: none;
  }

  .topbar-actions .icon-button,
  .action-button {
    width: 40px;
    min-height: 40px;
  }

  .action-button {
    padding: 0;
    font-size: 0;
  }

  .controls-panel {
    min-height: 206px;
    height: min(39dvh, 238px);
  }

  .stage-rotate-button {
    width: 42px;
    min-height: 42px;
  }

  .rotate-left {
    left: 6px;
  }

  .rotate-right {
    right: 6px;
  }

  .rotate-up {
    top: 50px;
  }

  .rotate-down {
    bottom: 8px;
  }

  .mobile-tool-tabs {
    gap: 5px;
    padding: 5px;
  }

  .mobile-tool-tab {
    min-height: 34px;
  }

  .control-section {
    padding: 10px;
  }

  .swatch-grid {
    gap: 6px;
  }

  .swatch {
    height: 28px;
    min-height: 28px;
  }

  .upload-zone {
    min-height: 48px;
    padding: 8px;
  }

  .stage-toolbar {
    top: 7px;
    left: 7px;
    right: 7px;
  }

  .stage-toolbar div:first-child {
    padding: 7px 8px;
  }
}

@media (max-width: 760px) and (max-height: 620px) {
  .controls-panel {
    min-height: 198px;
    height: 198px;
  }

  .mobile-tool-tab {
    min-height: 32px;
  }

  .section-title {
    margin-bottom: 6px;
  }

  .swatch {
    height: 27px;
    min-height: 27px;
  }

  .upload-zone {
    min-height: 44px;
  }

  .view-button,
  .rotation-button {
    min-height: 36px;
  }

  .stage-toolbar span {
    display: none;
  }
}
