:root {
  color-scheme: light;
  --bg: #f7f5f0;
  --panel: #ffffff;
  --ink: #191c1f;
  --muted: #67717d;
  --line: #d9dee4;
  --accent: #176f8f;
  --accent-dark: #0f536d;
  --accent-soft: #e8f5f8;
  --danger: #ad2f2f;
  --shadow: 0 18px 50px rgba(31, 42, 55, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 245, 240, 0.92)),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
  transform: translateY(-1px);
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 4vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
  letter-spacing: 0;
}

.privacy-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.input-column {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.ghost-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 210px;
  margin-top: 16px;
  border: 2px dashed #a7b4be;
  border-radius: 8px;
  background: #fbfcfc;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

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

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

.drop-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
}

.drop-subtitle {
  display: block;
  max-width: 260px;
  margin-top: -70px;
  color: var(--muted);
  line-height: 1.4;
}

.error-message {
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.preview-shell {
  margin: 16px 0 0;
}

.preview-shell img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  transform-origin: center;
  transition:
    clip-path 120ms ease,
    transform 120ms ease;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f2;
}

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

.crop-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.crop-grid label {
  display: grid;
  gap: 6px;
}

.crop-grid span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.crop-grid strong {
  color: var(--accent-dark);
}

.crop-grid input {
  width: 100%;
  accent-color: var(--accent);
}

.preview-shell figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.layout-control {
  grid-template-columns: repeat(4, 1fr);
}

.segmented-control label {
  min-width: 0;
}

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

.segmented-control span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

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

.primary-button {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
  color: #fff;
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.progress-copy h2 {
  margin: 0;
  color: var(--muted);
}

.progress-copy span {
  font-weight: 800;
  color: var(--accent-dark);
}

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

.output-panel {
  min-height: 660px;
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
}

.confidence {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 16px;
  background: #fbfcfc;
  color: var(--ink);
  line-height: 1.55;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding: 24px 0;
  }

  .app-header,
  .workspace {
    grid-template-columns: 1fr;
  }

  .output-panel {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .segmented-control,
  .layout-control,
  .actions,
  .rotate-actions {
    grid-template-columns: 1fr;
  }
}
