:root {
  --bg: #020617;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-2: rgba(2, 6, 23, 0.82);
  --border: rgba(51, 65, 85, 0.95);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-strong: #818cf8;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --button-bg: rgba(15, 23, 42, 0.9);
  --button-hover: rgba(30, 41, 59, 0.95);
  --button-active: linear-gradient(135deg, rgba(99, 102, 241, 1), rgba(56, 189, 248, 0.95));
  --button-active-text: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.12), transparent 32%),
    linear-gradient(to bottom, #0f172a, #020617 38%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: 12px;
}

.app {
  max-width: 1700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card,
.control-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.header {
  padding: 12px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.eyebrow,
.tool-section-title {
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 4px;
}

.title-block {
  min-width: 0;
  flex: 1 1 420px;
}

#tipsHelperLabel {
  transition: opacity 0.7s ease;
  will-change: opacity;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 12px;
  min-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#tipsHelperLabel.is-fading {
  opacity: 0.32;
}

.tool-section-title {
  margin: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.5vw, 2.5rem);
  line-height: 1.05;
  font-weight: 700;
}

.export-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 10px;
  flex-wrap: nowrap;
}

.label {
  color: var(--muted);
  font-size: 12px;
  padding: 0 2px 0 4px;
  white-space: nowrap;
}

.canvas-wrap {
  padding: 8px 12px 12px;
}

.artboard {
  border-radius: 30px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  position: relative;
}

svg {
  display: block;
  width: 100%;
  height: min(78vh, 980px);
  min-height: 640px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.14), transparent 38%),
    linear-gradient(to bottom, rgb(15, 23, 42), rgb(2, 6, 23));
}

.bottom-controls {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls-grid {
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.edit-grid {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.tool-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid rgba(71, 85, 105, 0.95);
  border-radius: 18px;
  overflow: hidden;
  background: var(--button-bg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.tool-pair button {
  border: 0;
  border-right: 1px solid rgba(71, 85, 105, 0.95);
  border-radius: 0;
  box-shadow: none;
}

.tool-pair button:last-child {
  border-right: 0;
}

.tool-pair:has(button:hover) {
  border-color: rgba(100, 116, 139, 0.95);
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
  margin-top: 2px;
}

.top-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  padding: 0 16px 12px;
}

button,
input,
select {
  font: inherit;
}

button {
  appearance: none;
  border: 1px solid rgba(71, 85, 105, 0.95);
  background: var(--button-bg);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
  min-height: 54px;
  width: 100%;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

button:hover {
  background: var(--button-hover);
  border-color: rgba(100, 116, 139, 0.95);
}

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

button.active {
  background: var(--button-active);
  border-color: rgba(129, 140, 248, 0.95);
  color: var(--button-active-text);
  box-shadow: 0 10px 26px rgba(79, 70, 229, 0.24);
}

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

.export-bar .export-btn {
  width: auto;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.94rem;
}

.control-pill {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 16px;
  padding: 9px 12px;
  min-height: 64px;
}

.control-pill span:first-child {
  color: var(--text);
}

.control-pill input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(71, 85, 105, 0.95);
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
}

.control-pill input[type="range"] {
  width: 100%;
}

.control-pill input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.help {
  color: var(--muted);
  font-size: 13px;
}

.footer-link {
  display: flex;
  justify-content: flex-end;
  padding: 0 4px 2px;
}

.footer-link a {
  color: rgba(148, 163, 184, 0.72);
  font-size: 12px;
  text-decoration: none;
  transition: color 0.16s ease;
}

.footer-link a:hover {
  color: rgba(248, 250, 252, 0.9);
}

@media (max-width: 720px) {
  body {
    padding: 10px;
  }

  svg {
    min-height: 480px;
  }

  .header {
    padding: 14px;
  }

  .export-bar {
    width: 100%;
    justify-content: flex-end;
  }

  .bottom-controls {
    padding: 12px;
  }
}

.top-toolbar button { min-height: 50px; }
.edit-grid button { min-height: 50px; }
@media (max-width: 820px) {
  .top-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  svg { min-height: 500px; height: min(66vh, 780px); }
}
