:root {
  --bg: #eceff1;
  --bg-2: #d7dde1;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --text: #111111;
  --muted: #5c6469;
  --border: rgba(17, 17, 17, 0.14);
  --accent: #00a7c2;
  --accent-2: #ff3b30;
  --accent-3: #f5c400;
  --good: #18a058;
  --shadow: 0 18px 48px rgba(20, 24, 26, 0.16);
  --radius: 8px;
  --workspace-pattern:
    linear-gradient(90deg, rgba(17, 17, 17, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(17, 17, 17, 0.05) 1px, transparent 1px),
    repeating-linear-gradient(135deg, #dfe4e7 0, #dfe4e7 22px, #e9edef 22px, #e9edef 44px);
}

body.theme-night {
  --bg: #101010;
  --bg-2: #1b1b1b;
  --panel: rgba(31, 31, 31, 0.95);
  --panel-strong: rgba(38, 38, 38, 0.98);
  --text: #f7f7f7;
  --muted: #b7bdc0;
  --border: rgba(255, 255, 255, 0.16);
  --accent: #43d6c9;
  --accent-2: #ff4f6d;
  --accent-3: #f6d84a;
  --good: #53d37e;
  --shadow: 0 20px 54px rgba(0, 0, 0, 0.42);
  --workspace-pattern:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    repeating-linear-gradient(135deg, #151515 0, #151515 22px, #1c1c1c 22px, #1c1c1c 44px);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  gap: 8px;
  padding: 8px;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 58px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
}

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

.compact-brand {
  min-width: 156px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 800;
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1;
}

.topbar-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-cluster.actions {
  justify-content: flex-end;
}

.main-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 312px;
  gap: 8px;
}

.left-rail,
.right-panel {
  min-height: 0;
  border-radius: var(--radius);
  overflow: auto;
  padding: 10px;
}

.workspace-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workspace-toolbar {
  border-radius: var(--radius);
  padding: 7px 9px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.workspace-toolbar-left,
.workspace-toolbar-center,
.workspace-toolbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.workspace-viewport {
  min-height: 0;
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--workspace-pattern);
  background-size: 32px 32px, 32px 32px, auto;
}

.workspace-viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 3px solid rgba(255, 255, 255, 0.18);
}

.workspace-surface {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.artboard {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(0, 0, 0, 0.18);
  background: #f7f7f2;
  user-select: none;
}

.artboard-grid,
.poster-objects,
.draw-preview,
.safe-margin,
.selection-overlay,
.floating-text-editor {
  position: absolute;
  inset: 0;
}

.artboard-grid {
  pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(rgba(17, 17, 17, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, 0.16) 1px, transparent 1px);
  background-size: 40px 40px;
}

.safe-margin {
  border: 2px dashed rgba(255, 59, 48, 0.65);
  pointer-events: none;
}

.poster-objects {
  pointer-events: none;
}

.draw-preview {
  pointer-events: none;
  overflow: visible;
  z-index: 9998;
}

.draw-preview path {
  fill: none;
  stroke: #111111;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.12));
}

.poster-object {
  position: absolute;
  transform-origin: center center;
  pointer-events: auto;
  cursor: grab;
}

.poster-object.selected {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.poster-object.dragging {
  cursor: grabbing;
}

.poster-object[data-type="image"] img,
.poster-object[data-type="shape"] .shape-inner,
.poster-object[data-type="path"] .path-inner {
  width: 100%;
  height: 100%;
  display: block;
}

.poster-object[data-type="image"] img {
  object-fit: cover;
  user-drag: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.text-render {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: pre-wrap;
  overflow: visible;
  word-break: break-word;
}

.text-render.editing {
  visibility: hidden;
}

.arc-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.arc-svg text {
  dominant-baseline: middle;
}

.drip-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.drip {
  position: absolute;
  border-radius: 8px;
}

.shape-inner {
  border-style: solid;
}

.shape-inner.ellipse {
  border-radius: 50%;
}

.shape-inner.burst {
  clip-path: polygon(50% 0%, 61% 18%, 79% 6%, 76% 27%, 98% 22%, 84% 41%, 100% 50%, 84% 58%, 98% 78%, 75% 73%, 79% 94%, 61% 82%, 50% 100%, 39% 82%, 21% 94%, 24% 73%, 2% 78%, 16% 58%, 0% 50%, 16% 41%, 2% 22%, 24% 27%, 21% 6%, 39% 18%);
}

.shape-inner.sunburst {
  clip-path: polygon(50% 0%, 56% 30%, 74% 6%, 68% 35%, 96% 26%, 72% 44%, 100% 50%, 72% 56%, 96% 74%, 68% 65%, 74% 94%, 56% 70%, 50% 100%, 44% 70%, 26% 94%, 32% 65%, 4% 74%, 28% 56%, 0% 50%, 28% 44%, 4% 26%, 32% 35%, 26% 6%, 44% 30%);
}

.shape-inner.seal {
  clip-path: polygon(50% 0%, 57% 8%, 67% 4%, 72% 14%, 83% 14%, 86% 25%, 96% 31%, 93% 42%, 100% 50%, 93% 58%, 96% 69%, 86% 75%, 83% 86%, 72% 86%, 67% 96%, 57% 92%, 50% 100%, 43% 92%, 33% 96%, 28% 86%, 17% 86%, 14% 75%, 4% 69%, 7% 58%, 0% 50%, 7% 42%, 4% 31%, 14% 25%, 17% 14%, 28% 14%, 33% 4%, 43% 8%);
}

.shape-inner.diamond {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.shape-inner.ticket {
  clip-path: polygon(0% 0%, 100% 0%, 100% 34%, 92% 50%, 100% 66%, 100% 100%, 0% 100%, 0% 66%, 8% 50%, 0% 34%);
}

.shape-inner.ribbon {
  clip-path: polygon(0% 10%, 82% 10%, 100% 50%, 82% 90%, 0% 90%, 12% 50%);
}

.shape-inner.slash {
  clip-path: polygon(18% 0%, 100% 0%, 82% 100%, 0% 100%);
}

.selection-overlay {
  pointer-events: none;
  border: 2px solid var(--accent);
  transform-origin: center center;
}

.selection-overlay.hidden {
  display: none;
}

.handle,
.rotate-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border: 2px solid var(--accent);
  border-radius: 8px;
  pointer-events: auto;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.handle.corner {
  width: 26px;
  height: 26px;
}

.handle.corner.nw { left: -13px; top: -13px; cursor: nwse-resize; }
.handle.edge.n { left: calc(50% - 11px); top: -11px; cursor: ns-resize; }
.handle.corner.ne { right: -13px; top: -13px; cursor: nesw-resize; }
.handle.edge.e { right: -11px; top: calc(50% - 11px); cursor: ew-resize; }
.handle.corner.se { right: -13px; bottom: -13px; cursor: nwse-resize; }
.handle.edge.s { left: calc(50% - 11px); bottom: -11px; cursor: ns-resize; }
.handle.corner.sw { left: -13px; bottom: -13px; cursor: nesw-resize; }
.handle.edge.w { left: -11px; top: calc(50% - 11px); cursor: ew-resize; }

.rotate-handle {
  left: calc(50% - 11px);
  top: -48px;
  background: var(--accent-3);
  border-color: rgba(0, 0, 0, 0.2);
  cursor: grab;
}

.rotate-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 2px;
  height: 18px;
  background: var(--accent);
  transform: translateX(-50%);
}

.floating-text-editor {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px dashed var(--accent);
  background: rgba(255, 255, 255, 0.94);
  color: #111111;
  resize: none;
  padding: 8px;
  outline: none;
  border-radius: 4px;
  transform-origin: center center;
}

.floating-text-editor.hidden {
  display: none;
}

.rail-section,
.panel-section {
  margin-bottom: 12px;
  padding: 0 0 12px;
  border-top: 1px solid var(--border);
}

.rail-section:first-child,
.panel-section:first-child {
  border-top: 0;
}

.rail-title,
.panel-head h2 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 900;
}

.rail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.rail-title-row .rail-title {
  margin: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
}

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

.tool-grid.single,
.tool-grid.two-wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tool-grid.marker-pack {
  margin-top: 8px;
}

.sub-tools-label {
  margin-top: 12px;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 900;
}

.tool-btn.mini {
  padding: 8px 9px;
  font-size: 12px;
}

.template-apply {
  width: 100%;
  margin-top: 8px;
}

.tool-btn,
.ghost-btn,
.solid-btn,
.theme-toggle,
.mode-card,
.marker-size-btn,
.type-hit-btn,
.color-chip {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

body.theme-day .tool-btn,
body.theme-day .ghost-btn,
body.theme-day .solid-btn,
body.theme-day .theme-toggle,
body.theme-day .mode-card,
body.theme-day .marker-size-btn,
body.theme-day .type-hit-btn,
body.theme-day .color-chip {
  background: rgba(17, 17, 17, 0.04);
}

.tool-btn,
.ghost-btn,
.solid-btn,
.small-btn,
.mode-card,
.type-hit-btn {
  padding: 8px 10px;
}

.tool-btn:hover,
.ghost-btn:hover,
.solid-btn:hover,
.theme-toggle:hover,
.mode-card:hover,
.marker-size-btn:hover,
.type-hit-btn:hover,
.color-chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.tool-btn.active,
.tool-btn.accent,
.solid-btn,
.mode-card.active {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
}

body.theme-night .tool-btn.active,
body.theme-night .tool-btn.accent,
body.theme-night .solid-btn,
body.theme-night .mode-card.active {
  background: #f7f7f7;
  border-color: #f7f7f7;
  color: #111111;
}

.solid-btn {
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(0, 167, 194, 0.16);
}

.accent-solid {
  background: var(--accent-3);
  border-color: rgba(17, 17, 17, 0.2);
  color: #111111;
}

.tool-btn.danger {
  background: rgba(255, 59, 48, 0.12);
  border-color: rgba(255, 59, 48, 0.34);
}

.inline-file {
  position: relative;
  overflow: hidden;
}

.inline-file input {
  display: none;
}

.marker-station {
  padding-top: 2px;
}

.marker-color-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.marker-color-pill input {
  width: 26px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
}

.marker-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.color-chip {
  min-height: 28px;
  padding: 0;
  background: var(--chip);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24);
}

.color-chip.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.marker-size-list {
  display: grid;
  gap: 7px;
}

.marker-size-btn {
  min-height: 60px;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 8px;
  text-align: left;
  overflow: hidden;
}

.marker-size-btn.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(0, 167, 194, 0.25);
}

.marker-visual {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 42px;
  margin-left: -36px;
}

.marker-bar {
  display: block;
  flex: 1;
  height: calc(var(--stroke-height) + 12px);
  max-height: 48px;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(180deg, #2b2b2b, var(--marker-preview, #111111));
  box-shadow: inset -10px 0 0 rgba(255, 255, 255, 0.1);
}

.marker-tip {
  width: 28px;
  height: var(--stroke-height);
  min-height: 6px;
  max-height: 38px;
  background: var(--marker-preview, #111111);
  clip-path: polygon(0 8%, 100% 0, 100% 100%, 0 92%);
}

.marker-tip.fine {
  width: 20px;
}

.marker-tip.standard {
  width: 24px;
}

.marker-tip.chunky,
.marker-tip.poster {
  width: 34px;
}

.marker-size-btn strong,
.marker-size-btn small {
  display: block;
}

.marker-size-btn small {
  color: var(--muted);
  margin-top: 2px;
}

.marker-actions {
  margin-top: 8px;
}

.shape-drop {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  margin-top: 8px;
  align-items: end;
}

.type-hits-panel {
  padding-top: 0;
}

.type-hit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.type-hit-btn {
  min-height: 44px;
  font-weight: 850;
}

.type-hit-btn:nth-child(1) {
  font-family: Anton, Impact, sans-serif;
  font-size: 18px;
}

.type-hit-btn:nth-child(2) {
  font-family: Anton, Impact, sans-serif;
  text-transform: uppercase;
}

.type-hit-btn:nth-child(3) {
  font-family: "Permanent Marker", cursive;
}

.type-hit-btn:nth-child(4) {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(67, 214, 201, 0.7);
}

.type-hit-btn:nth-child(5) {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 18px;
}

.type-hit-btn:nth-child(7) {
  border-style: dashed;
}

.locked-ui {
  opacity: 0.34;
}

.locked-ui .panel-head,
.locked-ui .rail-title,
.locked-ui .sub-tools-label {
  opacity: 0.85;
}

.marker-start {
  box-shadow: inset 0 0 0 2px rgba(67, 214, 201, 0.18);
}

.marker-start::after {
  content: "Start here. Unlock the rest when you are done marking.";
  display: block;
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.field,
.control-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 900;
}

.field input[type="number"],
.field input[type="color"],
.field select,
.field textarea,
.compact-field select,
.compact-field input {
  width: 100%;
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 8px 10px;
}

body.theme-day .field input[type="number"],
body.theme-day .field input[type="color"],
body.theme-day .field select,
body.theme-day .field textarea,
body.theme-day .compact-field select,
body.theme-day .compact-field input {
  background: rgba(17, 17, 17, 0.04);
}

.field input[type="color"] {
  padding: 3px;
}

.field textarea {
  resize: vertical;
}

.field-row {
  display: grid;
  gap: 7px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.empty-state,
.mini-note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.status-pill {
  padding: 6px 9px;
  border-radius: var(--radius);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  white-space: nowrap;
}

body.theme-day .status-pill {
  background: rgba(17, 17, 17, 0.04);
}

.status-pill.muted {
  color: var(--muted);
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
}

.toggle-pill.wide {
  justify-content: center;
}

.toggle-pill input {
  accent-color: var(--accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  min-height: 40px;
}

.theme-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: var(--radius);
  background: #111111;
  border: 1px solid var(--border);
}

body.theme-night .theme-toggle-track {
  background: #f7f7f7;
}

.theme-toggle-thumb {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 6px;
  background: var(--accent-3);
  transition: transform 0.18s ease;
}

body.theme-day .theme-toggle-thumb {
  transform: translateX(20px);
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-card input {
  display: none;
}

.mode-card span {
  font-weight: 800;
}

.mode-card small {
  color: var(--muted);
}

.tips-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  line-height: 1.4;
}

.path-inner {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.path-inner polyline,
.path-inner path {
  vector-effect: non-scaling-stroke;
}

@media (max-width: 1480px) {
  .main-layout {
    grid-template-columns: 226px minmax(0, 1fr) 300px;
  }
}

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

  .app-shell {
    min-height: 100vh;
    height: auto;
  }

  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(540px, 1fr) auto;
  }

  .left-rail,
  .right-panel {
    max-height: 44vh;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-wrap {
    min-width: 0;
  }

  .workspace-toolbar {
    align-items: flex-start;
  }

  .two-up,
  .three-up {
    grid-template-columns: 1fr;
  }

  .marker-size-btn {
    grid-template-columns: 56px minmax(0, 1fr);
  }
}
