:root {
  --bg: #0b0d10;
  --panel: #12161b;
  --panel-2: #171d23;
  --panel-3: #1f2730;
  --text: #eef2f6;
  --muted: #9aa7b4;
  --line: #2b3440;
  --black: #050607;
  --charcoal: #15191f;
  --maroon: #401019;
  --accent-red: #b51f32;
  --accent-cyan: #22d3ee;
  --light: #f4f7fa;
  --warn: #ff5c70;
  --focus: rgba(34, 211, 238, 0.28);
  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(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #0d1014;
  overflow-x: auto;
  overflow-y: hidden;
}

.brand-lockup {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 12px;
  min-width: 228px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-red), #5f1724 55%, var(--accent-cyan));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: white;
  font-weight: 800;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
  line-height: 1.15;
}

.brand-lockup strong {
  font-size: 15px;
}

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

.top-actions,
.canvas-toolbar,
.toolbar-group,
.layer-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.btn,
.tiny-btn,
.icon-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 7px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn:hover,
.tiny-btn:hover,
.icon-btn:hover {
  background: var(--panel-3);
  border-color: #3b4653;
}

.btn:active,
.tiny-btn:active,
.icon-btn:active {
  transform: translateY(1px);
}

.btn {
  height: 36px;
  padding: 0 13px;
  font-weight: 650;
  white-space: nowrap;
}

.btn.compact {
  padding: 0 10px;
}

.btn.primary {
  background: #18232b;
  border-color: rgba(34, 211, 238, 0.35);
  color: #dffaff;
}

.btn.accent {
  background: var(--accent-red);
  border-color: #d64556;
  color: white;
}

.tiny-btn {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 650;
}

.full-btn {
  width: 100%;
  margin-bottom: 12px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 20px;
  line-height: 1;
}

.danger {
  color: #ff9baa;
}

.filename-input {
  width: 180px;
}

.workspace {
  display: grid;
  grid-template-columns: clamp(250px, 20vw, 320px) minmax(420px, 1fr) clamp(290px, 23vw, 360px);
  min-height: 0;
}

.sidebar {
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

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

.tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 1 0 auto;
  height: 42px;
  min-width: 78px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #101419;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent-cyan);
}

.tab-panel {
  display: none;
  height: calc(100vh - 106px);
  overflow-y: auto;
  padding: 14px;
}

.tab-panel.active {
  display: block;
}

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

.panel-heading h2,
.inspector-section h3,
.dialog-head h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.upload-drop {
  display: grid;
  gap: 4px;
  min-height: 82px;
  margin-bottom: 12px;
  padding: 15px;
  border: 1px dashed #425061;
  border-radius: 8px;
  background: #10151a;
  color: var(--muted);
}

.upload-drop strong {
  color: var(--text);
}

.upload-drop.dragging {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--focus);
}

.font-upload-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151b;
}

.font-upload-panel span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.list {
  display: grid;
  gap: 8px;
}

.list-card,
.layer-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #10151b;
  border-radius: 8px;
}

.list-card.active,
.layer-row.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--focus);
}

.thumb {
  display: grid;
  place-items: center;
  width: 48px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #090b0f;
}

.thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.font-thumb {
  color: var(--accent-cyan);
  font-size: 18px;
  font-weight: 800;
}

.list-card strong,
.layer-row input {
  display: block;
  width: 100%;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-card span,
.layer-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.layer-row input {
  height: 28px;
  border-color: transparent;
  background: transparent;
  padding-left: 2px;
}

.layer-row input:focus {
  border-color: var(--accent-cyan);
  background: var(--panel-2);
}

.layer-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.layer-buttons button {
  width: 28px;
  height: 28px;
  padding: 0;
}

.editor-pane {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: #07090c;
}

.canvas-toolbar {
  justify-content: space-between;
  min-width: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #0c1014;
  overflow-x: auto;
}

.toolbar-group {
  min-width: max-content;
}

.zoom-readout {
  width: 52px;
  color: var(--muted);
  font-size: 12px;
}

.number-mini {
  width: 86px;
}

.canvas-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background-color: #090b0e;
  background-image:
    linear-gradient(45deg, #10141a 25%, transparent 25%),
    linear-gradient(-45deg, #10141a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #10141a 75%),
    linear-gradient(-45deg, transparent 75%, #10141a 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.canvas-zoom-shell {
  position: relative;
  margin: 42px auto;
  width: 1080px;
  height: 1080px;
}

.canvas-zoom-shell .canvas-container {
  margin: 0;
  transform-origin: top left;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.46);
}

.canvas-stage.pan-ready {
  cursor: grab;
}

.canvas-stage.panning {
  cursor: grabbing;
}

.empty-state {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  gap: 6px;
  min-width: 320px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 27, 0.92);
  color: var(--muted);
  text-align: center;
  transform: translate(-50%, -50%);
}

.empty-state strong {
  color: var(--text);
}

.empty-state.hidden {
  display: none;
}

.inspector {
  padding: 14px;
}

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

.inspector-section:first-of-type {
  border-top: 0;
}

.inspector-section summary {
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  list-style-position: inside;
  text-transform: uppercase;
}

.section-content {
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  white-space: nowrap;
}

input,
select,
textarea {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1116;
  color: var(--text);
  outline: none;
  padding: 7px 9px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[type="color"] {
  width: 100%;
  min-height: 34px;
  padding: 3px;
}

input[type="range"] {
  accent-color: var(--accent-cyan);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--focus);
}

.inline-grid {
  display: grid;
  gap: 8px;
}

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

.inline-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.swatch {
  width: 100%;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
}

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

.custom {
  grid-template-columns: repeat(8, 1fr);
}

.replace-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 7px;
}

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

.export-dialog {
  width: min(520px, calc(100vw - 30px));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
}

.export-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121820;
  color: var(--text);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

@media (max-width: 1160px) {
  .workspace {
    grid-template-columns: 260px minmax(360px, 1fr) 300px;
  }

  .topbar {
    align-items: flex-start;
    height: auto;
    min-height: 64px;
    padding-block: 10px;
  }

  .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }
}
