:root {
  color-scheme: light;
  --bg: #fffff4;
  --text: #111111;
  --line: #111111;
  --muted: #555555;
  --ok: #1f6f43;
  --warn: #9a5a00;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.app {
  width: min(1440px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 36px 0 72px;
}

/* ── Header ── */
header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
  margin-bottom: 28px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.logo {
  display: block;
  width: 72px;
  height: auto;
}

h1 {
  font-size: 56px;
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: 0;
}

.hdr-right {
  display: grid;
  justify-items: end;
  gap: 10px;
  text-align: right;
}

.tagline {
  max-width: 380px;
  font-size: 11px;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.status {
  min-width: 210px;
  font-size: 10px;
  line-height: 1.4;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* ── Workspace ── */
.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(480px, 1.25fr);
  gap: 28px;
  align-items: start;
}

.controls, .preview {
  border: 1px solid var(--line);
  padding: 24px;
}

/* ── Panel title ── */
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.panel-title span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-title small {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ── Provider tabs ── */
.provider-tabs {
  display: flex;
  margin-bottom: 18px;
  border: 1px solid var(--line);
}

.tab {
  flex: 1;
  min-height: 38px;
  border: none;
  border-radius: 0;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab + .tab { border-left: 1px solid var(--line); }

.tab:hover { background: #f0f0e0; color: var(--text); }

.tab.active {
  background: var(--text);
  color: var(--bg);
}

/* ── Drop zone ── */
.drop-zone {
  border: 1px solid var(--line);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 20px;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drop-zone:hover, .drop-zone.drag-over {
  background: #f0f0e0;
}

.drop-label {
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.drop-sub {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Fields ── */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field-hint {
  margin-top: 7px;
  font-size: 10px;
  line-height: 1.45;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field-hint code {
  font-family: "Courier New", monospace;
  font-size: 10px;
  background: #eeeee4;
  padding: 1px 4px;
  text-transform: none;
}

/* ── Buttons ── */
.buttons { display: grid; gap: 10px; margin-top: 16px; grid-template-columns: 1fr 1fr; }
.buttons.single { grid-template-columns: 1fr; }

button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: background 0.15s, color 0.15s;
}

button:hover { background: var(--bg); color: var(--text); }

button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
  pointer-events: none;
}

.btn-ghost {
  background: var(--bg);
  color: var(--text);
}
.btn-ghost:hover { background: var(--text); color: var(--bg); }

/* ── Note ── */
.batch-note {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 14px;
  font-size: 10px;
  line-height: 1.45;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ── Preview panel ── */
.preview { min-height: 580px; }

.canvas-wrap {
  min-height: 480px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 14px;
}

.empty {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 60px 24px;
}

/* ── Result grid ── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.result-block {
  border: 1px solid var(--line);
  background: var(--bg);
}

.wide-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Image containers ── */
.img-wrap {
  background: #f4f4e8;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.img-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.img-wide  { max-height: 240px; }
.img-wide img { object-fit: contain; max-height: 240px; }

.img-portrait {
  aspect-ratio: 4/5;
  max-height: 340px;
}
.img-portrait img { object-fit: cover; }

.img-stories {
  aspect-ratio: 9/16;
  max-height: 340px;
}
.img-stories img { object-fit: cover; }

/* Post + Stories side by side inside preview */
.result-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.formats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ── Dim group (dimensions + proc label) ── */
.dim-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.proc-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.proc-label.ai {
  color: var(--ok);
}

/* ── Warn bar ── */
.warn-bar {
  padding: 8px 12px;
  font-size: 10px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--warn);
  background: #fdf5e4;
  border-bottom: 1px solid var(--line);
}

/* ── Download button ── */
.btn-dl {
  display: block;
  width: 100%;
  min-height: 40px;
  border: none;
  border-top: none;
  border-radius: 0;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: background 0.15s, color 0.15s;
}
.btn-dl:hover { background: #333; }

/* ── Processing overlay ── */
.processing-bar {
  padding: 40px 0;
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  border: 1px solid var(--line);
  display: none;
}
.processing-bar.active { display: block; }

/* ── Batch list ── */
.batch-list { display: flex; flex-direction: column; gap: 18px; }

.batch-item {
  border: 1px solid var(--line);
  background: var(--bg);
}

.batch-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.batch-filename { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-status   { color: var(--muted); flex-shrink: 0; }

.batch-formats {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.batch-fmt-card + .batch-fmt-card { border-left: 1px solid var(--line); }

.batch-fmt-card .img-portrait { max-height: 200px; }
.batch-fmt-card .img-stories  { max-height: 200px; }

/* ── Edit crop button ── */
.btn-edit {
  display: block;
  width: 100%;
  min-height: 36px;
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: background 0.15s, color 0.15s;
}
.btn-edit:hover { background: #f0f0e0; color: var(--text); }

/* ── Crop modal ── */
.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.crop-inner {
  background: var(--bg);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
}

.crop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 11px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}

.crop-header .btn-ghost {
  min-height: 28px;
  padding: 0 12px;
  font-size: 9px;
}

.crop-stage {
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.crop-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  flex-shrink: 0;
}

.crop-controls .btn-ghost {
  min-height: 30px;
  min-width: 30px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.crop-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.crop-footer button {
  border: none;
  border-radius: 0;
  min-height: 44px;
}

.crop-footer button + button { border-left: 1px solid var(--line); }

/* ── Post generator ── */
.post-gen {
  border: 1px solid var(--line);
  padding: 24px;
  margin-top: 28px;
}

.post-url-row {
  display: flex;
  margin-bottom: 14px;
}

.post-url-row input {
  flex: 1;
  min-height: 42px;
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-family: "Courier New", monospace;
  padding: 10px 12px;
  outline: none;
  transition: background 0.15s;
}

.post-url-row input:focus { background: #f0f0e0; }
.post-url-row input::placeholder { color: #aaa; }

.post-url-row button {
  min-width: 90px;
  border-radius: 0;
}

.post-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  min-height: 16px;
  margin-bottom: 14px;
}

.post-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.post-cols.single {
  grid-template-columns: 1fr;
}

.post-col {
  border: 1px solid var(--line);
}

.post-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.post-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-tools small {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.post-tools small.near-limit {
  color: var(--warn);
}

.btn-copy {
  min-height: 26px;
  padding: 0 12px;
  font-size: 9px;
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: background 0.15s, color 0.15s;
}
.btn-copy:hover { background: var(--text); color: var(--bg); }

.post-textarea {
  display: block;
  width: 100%;
  min-height: 220px;
  border: none;
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.65;
  padding: 14px 12px;
  resize: vertical;
  outline: none;
}

/* ── Responsive ── */
@media (max-width: 980px) {
  header { grid-template-columns: 1fr; gap: 18px; }
  .hdr-right { justify-items: start; text-align: left; }
  .status { text-align: left; }
  h1 { font-size: 40px; }
  .workspace { grid-template-columns: 1fr; }
  .preview { min-height: 360px; }
}

@media (max-width: 620px) {
  .app { width: min(100vw - 28px, 1440px); padding: 18px 0 48px; }
  .controls, .preview { padding: 16px; }
  h1 { font-size: 30px; }
  .formats-row { grid-template-columns: 1fr; }
}
