@font-face {
  font-family: "TabacHN";
  src: url("./assets/Tabac_G2_Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f1eb;
  --panel: #ffffff;
  --ink: #161616;
  --muted: #68635f;
  --line: #d9d2c8;
  --accent: #00828c;
  --accent-strong: #006e76;
  --focus: #0aaae6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.controls {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px;
  overflow: auto;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 48px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: #0aaae6;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

h1 {
  margin: 0;
  font-family: TabacHN, Georgia, serif;
  font-size: 28px;
  line-height: 1;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

label,
legend {
  display: block;
  margin-bottom: 9px;
  color: #342f2b;
  font-size: 13px;
  font-weight: 700;
}

.url-form,
.field-group,
.social-panel,
.option-set {
  margin: 0 0 22px;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdfa;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

input[type="range"] {
  min-height: auto;
  padding: 0;
  border: 0;
  accent-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 108px;
  padding: 10px 12px;
  line-height: 1.35;
}

.social-panel textarea {
  min-height: 178px;
}

input:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(10, 170, 230, 0.18);
}

.url-row button,
.download-button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.url-row button {
  min-height: 44px;
  padding: 0 16px;
}

.url-row button:hover,
.download-button:hover {
  background: var(--accent-strong);
}

.status {
  display: block;
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status[data-tone="error"] {
  color: #9e2333;
}

.social-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.social-panel-header label {
  margin-bottom: 0;
}

.copy-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdfa;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.copy-button:hover {
  border-color: var(--accent);
}

.option-set {
  padding: 0;
  border: 0;
}

.color-controls,
.crop-controls {
  margin: 0;
  padding: 0;
  border: 0;
}

.color-controls {
  grid-column: 1 / -1;
}

.color-controls legend {
  margin-bottom: 8px;
}

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

.crop-controls legend {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.range-control {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--ink);
}

.range-control span {
  font-size: 13px;
  font-weight: 700;
}

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

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

.genre-button,
.preset-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdfa;
  color: var(--ink);
  text-align: left;
}

.genre-button {
  padding: 0 12px;
  font-weight: 700;
}

.genre-button[aria-pressed="true"],
.preset-button[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preset-button {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
}

.swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 26px;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.preset-name {
  font-weight: 700;
}

.download-button {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
}

.crop-reset-button {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdfa;
  color: var(--ink);
  font-weight: 700;
}

.crop-reset-button:hover {
  border-color: var(--accent);
}

.preview-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    linear-gradient(45deg, rgba(0, 0, 0, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.035) 75%),
    #ece6dc;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.preview-stack {
  display: grid;
  gap: 12px;
  width: min(100%, 720px);
}

.preview-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: 0 8px 20px rgba(43, 36, 28, 0.08);
}

.preview-tools .preset-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.preview-tools .preset-button {
  min-height: 34px;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 8px;
}

.preview-tools .swatches {
  height: 20px;
}

.preview-tools .preset-name {
  font-size: 13px;
}

canvas {
  display: block;
  justify-self: center;
  width: min(100%, 540px, calc((100vh - 166px) * 0.7941176471));
  min-width: min(100%, 280px);
  height: auto;
  aspect-ratio: 1080 / 1360;
  background: #00828c;
  box-shadow: 0 18px 45px rgba(43, 36, 28, 0.22);
}

canvas.is-draggable {
  cursor: grab;
  touch-action: none;
}

canvas.is-dragging {
  cursor: grabbing;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

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

  .preview-pane {
    min-height: 60vh;
    padding: 18px;
  }

  .preview-stack {
    width: min(100%, 620px);
  }
}

@media (max-width: 520px) {
  .controls {
    padding: 18px;
  }

  .url-row {
    grid-template-columns: 1fr;
  }

  .genre-grid {
    grid-template-columns: 1fr;
  }

  .preview-tools {
    grid-template-columns: 1fr;
  }

  .preview-tools .preset-grid {
    grid-template-columns: 1fr;
  }

  .crop-controls {
    grid-template-columns: 1fr;
  }
}
