:root {
  color-scheme: light;
  --bg: #eef3f6;
  --panel: #ffffff;
  --text: #15202b;
  --muted: #657386;
  --line: #d6dde6;
  --accent: #126c7a;
  --accent-dark: #0c5560;
  --soft: #e8f4f6;
  --danger: #a73728;
  --shadow: 0 18px 48px rgba(21, 32, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(18, 108, 122, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(111, 91, 63, 0.09), transparent 36%),
    var(--bg);
  color: var(--text);
}

button,
select,
textarea,
a {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.workspace {
  width: min(1120px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.header,
.control-panel,
.result-header,
.button-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header,
.result-header {
  justify-content: space-between;
}

.header {
  margin-bottom: 22px;
}

.eyebrow,
.panel-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(190px, 240px) 1fr auto;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.setting {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.setting select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.setting-check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--text);
}

.setting-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.primary-button,
.secondary-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #e9eef4;
  color: var(--text);
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 18px;
}

.input-panel,
.result-panel {
  min-width: 0;
}

.drop-zone {
  min-height: 310px;
  border: 2px dashed #99a7b9;
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: #fbfcff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--accent);
  font-size: 34px;
}

.drop-title {
  font-size: 20px;
  font-weight: 800;
}

.drop-subtitle,
.status-line,
.preview-card figcaption {
  color: var(--muted);
}

.preview-card {
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fbfd;
}

.preview-card img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #ffffff;
}

.preview-card figcaption {
  padding: 10px 12px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.result-panel {
  display: grid;
  grid-template-rows: auto auto minmax(360px, 1fr);
  gap: 12px;
}

.status-line {
  min-height: 28px;
  display: grid;
  grid-template-columns: 1fr minmax(120px, 190px);
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  color: var(--text);
  line-height: 1.65;
}

textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(18, 108, 122, 0.22);
  outline-offset: 2px;
}

@media (max-width: 840px) {
  .workspace {
    padding: 18px;
  }

  .header,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .control-panel,
  .layout,
  .status-line {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .button-row {
    width: 100%;
  }

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