:root {
  color-scheme: light;
  --panel-bg: rgba(255, 255, 255, 0.74);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(27, 35, 48, 0.12);
  --border-strong: rgba(27, 35, 48, 0.2);
  --text: #17202f;
  --muted: #667085;
  --soft: #f5f7fb;
  --accent: #ff7a1a;
  --accent-strong: #e8640e;
  --accent-soft: rgba(255, 122, 26, 0.12);
  --selected: #ff5a1f;
  --download-ready: #ff7a1a;
  --download-ready-hover: #e8640e;
  --focus: rgba(255, 122, 26, 0.3);
  --shadow: 0 20px 55px rgba(26, 35, 50, 0.12);
  --shadow-soft: 0 12px 30px rgba(26, 35, 50, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif,
    Arial,
    Helvetica,
    sans-serif;
  color: var(--text);
  background: #edf1f7;
}

button,
input,
select {
  font: inherit;
}

.app {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.9),
      rgba(246, 248, 252, 0.86)
    ),
    #edf1f7;
}

.sidebar {
  height: 100vh;
  padding: 16px;
  overflow-y: auto;
  z-index: 20;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.8),
      rgba(242, 245, 250, 0.72)
    ),
    #f7f9fc;
  border-right: 1px solid var(--border);
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
}

.sidebar-intro {
  padding: 6px 4px 2px;
}

.eyebrow,
.panel-heading span,
.section-heading span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar h1 {
  margin: 7px 0 8px;
  font-size: 25px;
  line-height: 1.05;
  letter-spacing: 0;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel,
.tag-control {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.panel {
  padding: 14px;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2,
.section-heading h2,
.tag-control h2 {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
}

.field {
  display: block;
  margin: 0;
}

.field span,
.export-panel label,
.padding-panel label {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 12px;
  font-weight: 750;
}

input[type="file"],
input[type="number"],
select,
button {
  width: 100%;
}

input[type="number"],
select {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

input[type="number"]:focus,
select:focus {
  border-color: rgba(255, 122, 26, 0.72);
  background: #ffffff;
  box-shadow: 0 0 0 4px var(--focus);
}

button {
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.actions-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.sidebar-button.lggc {
  --lggc-radius: 14px;
  --lggc-padding: 10px 13px;
  --lggc-bg: rgba(255, 255, 255, 0.54);
  --lggc-border: rgba(27, 35, 48, 0.14);
  --lggc-blur: 10px;
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.9),
    0 14px 28px rgba(26, 35, 50, 0.11);
}

.secondary-action {
  background: rgba(255, 255, 255, 0.72);
}

.secondary-action:hover {
  border-color: var(--border-strong);
}

.primary-action {
  color: #8f4b08;
  background: rgba(255, 255, 255, 0.72);
}

#downloadBtn.ready-download {
  --lggc-bg: rgba(255, 122, 26, 0.88);
  --lggc-border: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 122, 26, 0.9);
  background: linear-gradient(180deg, #ff9a3d 0%, var(--download-ready) 100%);
  color: #ffffff;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.52),
    inset 0 -10px 18px rgba(154, 69, 0, 0.18),
    0 14px 28px rgba(255, 122, 26, 0.28),
    0 0 0 4px rgba(255, 122, 26, 0.12);
}

#downloadBtn.ready-download:hover {
  --lggc-bg: rgba(232, 100, 14, 0.92);
  border-color: rgba(232, 100, 14, 0.95);
  background: linear-gradient(
    180deg,
    #ff8d29 0%,
    var(--download-ready-hover) 100%
  );
  color: #ffffff;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -10px 18px rgba(124, 53, 0, 0.2),
    0 16px 32px rgba(232, 100, 14, 0.34),
    0 0 0 4px rgba(255, 122, 26, 0.16);
}

.export-panel,
.padding-panel {
  margin: 0;
}

.padding-panel input[type="number"] {
  margin-bottom: 9px;
}

.export-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
}

.help-panel {
  padding-bottom: 12px;
}

.guide-list {
  display: grid;
  gap: 9px;
}

.guide-list p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.guide-list strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 12px;
}

.tag-panel {
  display: grid;
  gap: 10px;
}

#tagControls {
  display: grid;
  gap: 10px;
}

.tag-control {
  padding: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.tag-control h2 {
  margin-bottom: 10px;
}

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

.tag-control label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.upload-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.78);
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.upload-card.empty {
  border: 1.5px dashed rgba(255, 122, 26, 0.58);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.82),
      rgba(255, 245, 234, 0.82)
    ),
    #fffaf4;
  box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.08);
}

.upload-card.empty:hover,
.upload-card.dragover {
  border-color: rgba(255, 122, 26, 0.86);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 239, 219, 0.9)),
    #fff7ee;
  box-shadow:
    0 0 0 4px rgba(255, 122, 26, 0.14),
    0 12px 28px rgba(255, 122, 26, 0.12);
  transform: translateY(-1px);
}

.upload-card.has-file {
  border-color: rgba(42, 157, 143, 0.35);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.88),
      rgba(238, 250, 248, 0.86)
    ),
    #f7fffd;
}

.upload-card.has-file:hover {
  border-color: rgba(42, 157, 143, 0.55);
}

.upload-card:focus,
.upload-card:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px var(--focus),
    0 0 0 1px rgba(255, 122, 26, 0.82) inset;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  color: #b85b0b;
  font-size: 20px;
  font-weight: 900;
  background: var(--accent-soft);
}

.upload-copy {
  min-width: 0;
}

.upload-main-text {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.upload-file-name {
  margin-bottom: 4px;
  color: #986016;
  font-size: 12px;
  font-weight: 700;
  word-break: break-word;
}

.upload-card.has-file .upload-file-name {
  color: #0f766e;
}

.upload-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.upload-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 122, 26, 0.28);
  border-radius: 999px;
  color: #a85208;
  background: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.upload-card.has-file .upload-cta {
  border-color: rgba(42, 157, 143, 0.25);
  color: #0f766e;
}

.main {
  position: relative;
  height: 100vh;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background-color: #e9eef5;
  background-image:
    linear-gradient(45deg, rgba(23, 32, 47, 0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 32, 47, 0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 32, 47, 0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 32, 47, 0.045) 75%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(221, 228, 238, 0.72));
  background-size:
    28px 28px,
    28px 28px,
    28px 28px,
    28px 28px,
    auto;
  background-position:
    0 0,
    0 14px,
    14px -14px,
    -14px 0,
    0 0;
}

.workspace-label {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 999px;
  color: rgba(23, 32, 47, 0.78);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  box-shadow: 0 12px 26px rgba(26, 35, 50, 0.1);
  pointer-events: none;
}

.workspace-label span:first-child {
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.workspace-label span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.stage-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  display: inline-block;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
  user-select: none;
}

.stage {
  position: relative;
  width: 900px;
  height: 600px;
  overflow: hidden;
  border: 1px dashed rgba(23, 32, 47, 0.34);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.72);
  cursor: move;
  touch-action: none;
}

.stage.has-image {
  border: 1px solid rgba(23, 32, 47, 0.26);
  background: #f8fafc;
}

#mainImage {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

#mainImage:not([src]),
#mainImage[src=""] {
  display: none;
}

.empty-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  text-align: center;
}

.empty-message::before {
  content: "";
  position: absolute;
  width: min(44%, 280px);
  aspect-ratio: 1;
  border: 1px solid rgba(23, 32, 47, 0.1);
  border-radius: 28px;
  background:
    linear-gradient(90deg, rgba(23, 32, 47, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 32, 47, 0.08) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.55;
}

.empty-message > * {
  position: relative;
}

.line-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.line-layer line {
  stroke: rgb(52, 52, 52);
  stroke-width: 1.25;
  stroke-dasharray: 10 6;
  stroke-linecap: butt;
  shape-rendering: crispEdges;
  vector-effect: non-scaling-stroke;
}

.tag {
  position: absolute;
  width: 100px;
  height: 100px;
  cursor: move;
  touch-action: none;
  transform: translateZ(0);
  user-select: none;
  box-shadow: 0 0 0 var(--tag-border, 12px) white;
}

.tag.selected {
  outline: 2px solid var(--selected);
  outline-offset: 2px;
  box-shadow:
    0 0 0 var(--tag-border, 12px) white,
    0 0 0 1px rgba(255, 90, 31, 0.25),
    0 10px 22px rgba(255, 90, 31, 0.22);
}

.tag svg {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  filter: drop-shadow(0 8px 14px rgba(15, 23, 42, 0.16));
  pointer-events: none;
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

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

  .sidebar {
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .main {
    min-height: 72vh;
    height: 72vh;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 12px;
  }

  .sidebar h1 {
    font-size: 22px;
  }

  .upload-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .upload-cta {
    grid-column: 1 / -1;
  }

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

  .workspace-label {
    max-width: calc(100vw - 48px);
    flex-wrap: wrap;
    border-radius: 16px;
  }
}
