:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #171b22;
  --muted: #667085;
  --border: #d7dce3;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 18px 55px rgba(16, 24, 40, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.toolbar,
.workspace {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-radius: 8px;
}

.title-block h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 760;
  letter-spacing: 0;
}

.title-block p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.controls {
  display: grid;
  gap: 14px;
}

.drop-zone {
  display: grid;
  gap: 6px;
  min-height: 104px;
  padding: 18px;
  border: 1px dashed #a8b2c1;
  border-radius: 8px;
  background: #fbfcfd;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #f0fdfa;
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-title {
  font-size: 15px;
  font-weight: 720;
}

.drop-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

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

.segmented legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #344054;
  background: #fff;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.segmented input:checked + span {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #ecfdf3;
}

.field {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

.field em {
  font-style: normal;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 4px;
}

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

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  font-size: 14px;
  font-weight: 720;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button:disabled {
  color: #98a2b3;
  background: #edf0f4;
  cursor: not-allowed;
}

.secondary-button {
  border-color: var(--border);
  color: #344054;
  background: #fff;
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #f0fdfa;
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

#dimensionNotice.warning {
  color: var(--danger);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 18px;
  overflow: auto;
}

.preview-card {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.preview-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 1.64 / 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f4f6f8 25%, transparent 25%),
    linear-gradient(-45deg, #f4f6f8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f4f6f8 75%),
    linear-gradient(-45deg, transparent 75%, #f4f6f8 75%);
  background-color: #ffffff;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
  overflow: hidden;
}

.preview-frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.preview-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}

.preview-meta strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  min-height: calc(100vh - 96px);
  color: var(--muted);
  text-align: center;
  padding: 36px;
}

.empty-state svg {
  width: 52px;
  height: 52px;
  color: #98a2b3;
}

.empty-state p {
  max-width: 360px;
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

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

  .toolbar {
    padding: 18px;
  }

  .title-block h1 {
    font-size: 22px;
  }

  .preview-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }
}
