:root {
  --ink: #20242b;
  --muted: #6f7480;
  --line: #dce1e7;
  --panel: #ffffff;
  --paper: #f4f6f8;
  --accent: #177b72;
  --accent-strong: #0d5f58;
  --danger: #b53d3d;
  --shadow: 0 18px 50px rgba(23, 31, 42, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef1f4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.button-like,
.upload-control {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 13px;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

button:hover,
.button-like:hover,
.upload-control:hover {
  border-color: #9aa6b5;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover { background: var(--accent-strong); }

button.danger { color: var(--danger); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
}

.sidebar,
.inspector {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--line);
  padding: 20px;
  overflow: auto;
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #152a2d;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 0.9rem;
}

.tool-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.tool-section h2 {
  margin: 0 0 12px;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #454b55;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  min-height: 40px;
}

.segmented button.active {
  background: #152a2d;
  color: #fff;
}

.hint,
.empty-state {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.45;
}

.swatches,
.frame-buttons,
.button-grid,
.split {
  display: grid;
  gap: 8px;
}

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

.swatch {
  aspect-ratio: 1;
  min-height: auto;
  padding: 0;
  border-radius: 8px;
}

.frame-buttons {
  grid-template-columns: repeat(3, 1fr);
}

.button-grid,
.split {
  grid-template-columns: 1fr 1fr;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.field span {
  color: var(--muted);
  font-size: 0.84rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 123, 114, 0.13);
}

.field.compact {
  grid-template-columns: 74px 1fr;
  align-items: center;
}

.upload-control,
.button-like {
  display: grid;
  place-items: center;
  margin-top: 10px;
  text-align: center;
}

.upload-control input,
.button-like input,
.hidden-file {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.stage-wrap {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 248, 0.8);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stage {
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    #dfe4ea;
  background-size: 26px 26px;
}

canvas {
  width: min(100%, 920px);
  height: auto;
  max-height: calc(100vh - 150px);
  display: block;
  background: #fff;
  box-shadow: var(--shadow);
  touch-action: none;
  object-fit: contain;
}

.selection-tools[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #152a2d;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast[hidden] { display: none; }

.maintenance-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(238, 241, 244, 0.88), rgba(238, 241, 244, 0.9)),
    radial-gradient(circle at 20% 20%, rgba(23, 123, 114, 0.18), transparent 32%),
    #eef1f4;
}

.maintenance-card {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.maintenance-card h1,
.maintenance-card p {
  margin: 0;
}

.maintenance-card p {
  color: var(--muted);
  line-height: 1.5;
}

.maintenance-card a {
  color: var(--accent-strong);
  text-align: center;
  text-decoration: none;
}

.maintenance-logo {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}

.maintenance-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
}

.maintenance-logo span {
  font-weight: 800;
  color: var(--accent-strong);
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.notice {
  border: 1px solid rgba(181, 61, 61, 0.28);
  border-radius: 8px;
  background: rgba(181, 61, 61, 0.08);
  color: var(--danger);
  padding: 10px 12px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }

  .inspector .tool-section {
    border-top: 0;
    padding: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .inspector {
    border: 0;
    padding: 16px;
  }

  .inspector {
    display: block;
  }

  .topbar {
    display: block;
    padding: 18px 16px;
  }

  .top-actions {
    justify-content: stretch;
    margin-top: 14px;
  }

  .top-actions button {
    flex: 1 1 140px;
  }

  .stage {
    padding: 16px;
  }

  canvas {
    width: 100%;
  }
}
