:root {
  --bg: #f0f4fa;
  --bg-subtle: #e8edf5;
  --fg: #0c1222;
  --card: #ffffff;
  --muted: #5b6578;
  --border: #d8e0ec;
  --border-strong: #c5d0e0;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: color-mix(in srgb, var(--primary) 10%, white);
  --primary-ring: color-mix(in srgb, var(--primary) 28%, transparent);
  --accent: #0f766e;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgb(12 18 34 / 6%);
  --shadow: 0 8px 28px rgb(12 18 34 / 10%);
  --shadow-lg: 0 16px 48px rgb(12 18 34 / 12%);
  --radius: 14px;
  --radius-sm: 10px;
  --touch: 44px;
  --icon: 40px;
  font-family:
    "Plus Jakarta Sans",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-size: 15px;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
}

[hidden] {
  display: none !important;
}

button,
input,
label {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
label:focus-within,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.tool-chip:focus-visible {
  outline-offset: 1px;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  background: rgb(255 255 255 / 92%);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
  max-width: 1400px;
  margin: 0 auto;
}

.header__logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header__logo-img {
  display: block;
  height: 34px;
  width: auto;
}

.header__title {
  flex: 1;
  min-width: 160px;
}

.header__title h1 {
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 1.1875rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.header__tagline {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

.header__link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.header__link:hover {
  color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}

.btn--post-ad {
  min-height: 40px;
  padding: 0 16px;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  border-radius: 999px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 0;
}

.dropzone {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 50dvh;
  padding: 24px 16px;
}

.dropzone__inner {
  width: min(480px, 100%);
  padding: 48px 32px 40px;
  text-align: center;
  background: var(--card);
  border: 2px dashed var(--border-strong);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.dropzone__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
}

.dropzone--active .dropzone__inner {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: var(--shadow-lg);
  transform: scale(1.01);
}

.dropzone__title {
  margin: 0 0 10px;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.dropzone__feature {
  margin: 0 0 20px;
  max-width: 36rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

.dropzone__feature strong {
  color: var(--fg);
}

.seo {
  margin-top: 8px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.seo__title {
  margin: 0 0 10px;
  font-size: 1.125rem;
  font-weight: 700;
}

.seo__lead {
  margin: 0 0 16px;
  line-height: 1.55;
  color: var(--muted);
}

.seo__lead strong {
  color: var(--fg);
  font-weight: 600;
}

.seo__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.seo__card {
  padding: 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.seo__card h3 {
  margin: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 700;
}

.seo__card p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
}

.seo__card--accent {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: var(--primary-soft);
}

.slider__value {
  min-width: 2.25rem;
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  text-align: right;
}

.seo__faq h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
}

.seo__faq-item {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}

.seo__faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
}

.seo__faq-item p {
  margin: 8px 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
}

.footer {
  padding: 16px 20px 24px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--card);
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer__privacy {
  margin: 8px 0 0;
  max-width: 42rem;
  margin-inline: auto;
  line-height: 1.45;
  font-size: 0.75rem;
}

.dropzone__hint {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}

.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.workspace__body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.workspace__main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.workspace__meta {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.toolbar-sidebar {
  position: relative;
  width: 72px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 5;
}

.toolbar-sidebar__scroll {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toolbar-sidebar .toolbar-group {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
}

.toolbar-sidebar .tool-chip {
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 4px 2px;
}

.toolbar-sidebar .tool-chip__label {
  max-width: 58px;
  font-size: 0.625rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition:
    opacity 0.15s ease,
    max-height 0.15s ease,
    margin-top 0.15s ease;
}

.toolbar-sidebar .tool-chip:hover .tool-chip__label,
.toolbar-sidebar .tool-chip:focus-visible .tool-chip__label,
.toolbar-sidebar .tool-chip--color:focus-within .tool-chip__label {
  opacity: 1;
  max-height: 1.25rem;
  margin-top: 2px;
}

.toolbar-top {
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.toolbar-top__scroll {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px;
}

.toolbar-top .toolbar-group {
  flex-direction: row;
  flex-shrink: 0;
}

.toolbar-top .tool-chip {
  min-width: 52px;
  min-height: 52px;
  padding: 6px 8px;
}

.toolbar-top .tool-chip__label {
  max-width: 72px;
  font-size: 0.6875rem;
}

.toolbar-top .tool-chip--color .tool-chip__inner {
  pointer-events: auto;
}

.stage-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.zoom-rail {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgb(255 255 255 / 94%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.zoom-rail .tool-chip {
  min-width: 44px;
  min-height: 44px;
}

.zoom-rail .tool-chip--text {
  min-width: 44px;
  padding: 6px 4px;
  font-size: 0.75rem;
}

.layers-panel {
  width: min(220px, 32vw);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.layers-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.layers-panel__title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.layers-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.8125rem;
}

.layer-row--hidden {
  opacity: 0.55;
}

.layer-row--active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.layer-row__opacity {
  width: 52px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.layer-row__vis {
  flex-shrink: 0;
  accent-color: var(--primary);
}

.layer-row__name {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
}

.layer-row__name:focus {
  outline: 2px solid var(--primary);
  background: var(--card);
}

.layer-row__actions {
  display: flex;
  gap: 2px;
}

.layer-row__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.layer-row__btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.layers-panel__merge {
  width: 100%;
}

.layers-panel__empty {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.tabs-bar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 8px 12px;
  background: var(--card);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs-bar__list {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 160px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tab-item:hover {
  border-color: var(--border-strong);
  color: var(--fg);
}

.tab-item--active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.tab-item__label {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: inherit;
  color: inherit;
  padding: 0;
  min-width: 48px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-item__label:focus {
  outline: none;
}

.tab-item--active .tab-item__label:focus {
  text-decoration: underline;
}

.tab-item__close {
  display: inline-flex;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.tab-item__close:hover {
  opacity: 1;
  background: rgb(0 0 0 / 8%);
}

.tabs-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tabs-bar__fragment {
  white-space: nowrap;
}

.tabs-bar__add {
  flex-shrink: 0;
  min-width: 40px;
  min-height: 36px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
}

.tabs-bar__add:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.tabs-bar__add:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.select-box {
  border-color: #0f766e;
  box-shadow: 0 0 0 1px rgb(15 118 110 / 70%);
}

.tool-chip--inline {
  min-height: auto;
  min-width: auto;
  padding: 4px 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(12 18 34 / 45%);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(400px, 100%);
  padding: 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.modal__title {
  margin: 0 0 16px;
  font-size: 1.125rem;
  font-weight: 700;
}

.modal__actions {
  margin-top: 16px;
  justify-content: flex-end;
}

.modal--wide {
  width: min(440px, calc(100vw - 32px));
}

.modal__hint {
  margin: 0 0 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

.modal-fieldset {
  margin: 0 0 14px;
  padding: 0;
  border: none;
}

.modal-fieldset:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.modal-fieldset__legend {
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--fg);
}

.modal-radio {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
  cursor: pointer;
}

.modal-radio input {
  margin-top: 3px;
  accent-color: var(--primary);
}

.field-row--indent {
  margin-top: 8px;
  padding-left: 4px;
}

.placement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 168px;
}

.placement-grid__cell {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  font-size: 1.125rem;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.placement-grid__cell:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.placement-grid__cell--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--bg);
  font: inherit;
}

input[type="text"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--bg);
}

#canvas.tool-brush,
#canvas.tool-blur {
  cursor: crosshair;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
  box-shadow: var(--shadow-sm);
}

.topbar__scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.topbar__tools {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: max-content;
  padding: 2px 4px 6px;
}

.toolbar-group {
  display: inline-flex;
  align-items: stretch;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toolbar-group--zoom .tool-chip--text {
  min-width: 58px;
  font-variant-numeric: tabular-nums;
}

.toolbar-group--export {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s,
    transform 0.12s;
}

.tool-chip:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tool-chip:active:not(:disabled) {
  transform: scale(0.97);
}

.tool-chip:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.tool-chip--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-ring);
}

.tool-chip--active:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.tool-chip--accent {
  background: color-mix(in srgb, var(--accent) 8%, white);
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
  color: var(--accent);
  font-weight: 700;
}

.tool-chip--accent:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 16%, white);
  color: #0d5c56;
  border-color: var(--accent);
}

.tool-chip--text {
  min-width: 58px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 700;
}

.tool-chip--color {
  padding: 4px 6px;
}

.tool-chip--color input[type="color"] {
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.tool-chip__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}

.tool-chip--color .tool-chip__inner {
  pointer-events: auto;
}

.tool-chip--color .tool-chip__inner input[type="color"] {
  pointer-events: auto;
}

.tool-chip__label {
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  max-width: 68px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.tool-chip svg {
  display: block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.tool-chip--active svg {
  color: inherit;
}

.topbar__sep {
  display: none;
}

.topbar__meta {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  width: 100%;
  padding: 0 6px 2px;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon);
  height: var(--icon);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.icon-btn--active {
  background: color-mix(in srgb, var(--primary) 12%, white);
  border-color: var(--primary);
  color: var(--primary);
}

.icon-btn--text {
  width: auto;
  min-width: var(--icon);
  padding: 0 10px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.icon-btn--color {
  overflow: hidden;
  padding: 4px;
}

.icon-btn--color input[type="color"] {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.icon-btn svg {
  display: block;
  width: 20px;
  height: 20px;
}

.tool-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--card) 100%);
  border-bottom: 1px solid var(--border);
}

.tool-panel > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.slider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.slider span {
  min-width: 52px;
}

.slider input[type="range"] {
  width: min(160px, 28vw);
  accent-color: var(--primary);
}

.slider--compact span {
  min-width: 44px;
}

.slider--compact input[type="range"] {
  width: min(120px, 24vw);
}

.btn-row--wrap {
  flex-wrap: wrap;
}

.crop-preset.is-active,
.annotate-mode.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.tool-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.field--checkbox input {
  width: auto;
}

.annotate-overlay {
  z-index: 3;
  pointer-events: none;
}

#canvas.tool-clone {
  cursor: crosshair;
}

#canvas.tool-annotate {
  cursor: crosshair;
}

.resize-popover {
  position: absolute;
  left: calc(100% + 8px);
  bottom: 24px;
  z-index: 20;
  width: min(300px, calc(100vw - 120px));
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.btn--sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

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

.field--compact {
  flex: 1;
}

.field__label {
  font-size: 0.75rem;
  color: var(--muted);
}

.field-row {
  display: flex;
  gap: 8px;
}

input[type="number"],
input[type="color"] {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--bg);
}

input[type="color"] {
  padding: 4px;
  height: 40px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.12s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--lg {
  min-height: 48px;
  padding: 0 24px;
  font-size: 1rem;
  border-radius: 12px;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-ring);
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px var(--primary-ring);
}

.btn--secondary {
  background: var(--card);
  border-color: var(--border-strong);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-weight: 600;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--fg);
  border-color: var(--border-strong);
  background: var(--bg);
}

.btn--icon {
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0;
  font-size: 1.25rem;
  background: var(--bg);
  border-color: var(--border);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stage__frame {
  position: relative;
  flex: 1;
  min-height: 300px;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: var(--padding, 20px);
  background-color: #e4eaf2;
  background-image:
    linear-gradient(45deg, #d4dce8 25%, transparent 25%),
    linear-gradient(-45deg, #d4dce8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d4dce8 75%),
    linear-gradient(-45deg, transparent 75%, #d4dce8 75%);
  background-size: 16px 16px;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
}

.layer-transform-box {
  border-color: #7c3aed;
  box-shadow: 0 0 0 1px rgb(124 58 237 / 70%);
}

#canvas {
  display: block;
  max-width: none;
  height: auto;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  touch-action: none;
  position: relative;
  z-index: 1;
}

#canvas.tool-eraser {
  cursor: crosshair;
}

#canvas.tool-lasso,
#canvas.tool-wand {
  cursor: crosshair;
}

.tool-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 4;
}

.tool-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.4;
}

.wand-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
}

.wand-check input {
  width: auto;
  min-height: 0;
  accent-color: var(--primary);
}

.crop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  z-index: 2;
}

.crop-overlay__shade {
  position: absolute;
  pointer-events: auto;
  cursor: crosshair;
  background: rgb(10 15 26 / 45%);
}

.crop-box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgb(29 78 216 / 80%);
  pointer-events: auto;
  cursor: move;
}

.crop-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 2px;
  pointer-events: auto;
  z-index: 3;
}

.crop-handle--nw { top: 0; left: 0; cursor: nwse-resize; }
.crop-handle--n { top: 0; left: 50%; cursor: ns-resize; }
.crop-handle--ne { top: 0; left: 100%; cursor: nesw-resize; }
.crop-handle--e { top: 50%; left: 100%; cursor: ew-resize; }
.crop-handle--se { top: 100%; left: 100%; cursor: nwse-resize; }
.crop-handle--s { top: 100%; left: 50%; cursor: ns-resize; }
.crop-handle--sw { top: 100%; left: 0; cursor: nesw-resize; }
.crop-handle--w { top: 50%; left: 0; cursor: ew-resize; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toast--error {
  background: var(--danger);
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  gap: 16px;
  background: rgb(240 244 250 / 82%);
  backdrop-filter: blur(8px);
}

.loading p {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
}

.loading__spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .toolbar-sidebar {
    width: 100%;
    max-height: 132px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .toolbar-sidebar__scroll {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
  }

  .toolbar-sidebar .toolbar-group {
    flex-direction: row;
    flex-shrink: 0;
  }

  .toolbar-sidebar .tool-chip {
    width: auto;
    min-width: 44px;
  }

  .toolbar-top__scroll {
    padding: 6px 10px;
    gap: 8px;
  }

  .toolbar-top .tool-chip {
    min-width: 48px;
    min-height: 48px;
  }

  .resize-popover {
    left: 8px;
    bottom: auto;
    top: calc(100% + 8px);
  }

  .layers-panel {
    width: 100%;
    max-height: 140px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .workspace__body {
    flex-direction: column;
  }
  .header__inner {
    gap: 10px;
  }

  .header__link {
    display: none;
  }

  .header__title h1 {
    font-size: 0.9375rem;
  }

  .header__tagline {
    font-size: 0.75rem;
  }

  .btn--post-ad {
    width: 100%;
    order: 3;
  }

  .header__actions {
    width: 100%;
    margin-left: 0;
  }

  .tabs-bar__fragment {
    font-size: 0.75rem;
    padding: 0 8px;
  }
}

@media (max-width: 640px) {
  .toolbar-sidebar .tool-chip {
    min-height: 44px;
    min-width: 44px;
  }

  .toolbar-sidebar .tool-chip__label {
    display: none;
  }

  .toolbar-top .tool-chip__label {
    font-size: 0.625rem;
    max-width: 56px;
  }

  .zoom-rail {
    right: 8px;
    padding: 4px;
    gap: 4px;
  }

  .zoom-rail .tool-chip {
    min-width: 40px;
    min-height: 40px;
  }

  .toolbar-group {
    padding: 3px;
    gap: 3px;
  }

  .tool-chip {
    min-height: 44px;
    min-width: 44px;
    padding: 4px 6px;
  }

  .tool-chip__label {
    font-size: 0.625rem;
    max-width: 54px;
  }

  .tool-chip svg {
    width: 20px;
    height: 20px;
  }

  .topbar {
    padding: 8px 10px;
  }

  .topbar__tools {
    gap: 8px;
  }

  .dropzone__inner {
    padding: 36px 20px 32px;
  }

  .stage__frame {
    min-height: 240px;
    padding: 12px;
  }

  .toast {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}
