:root {
  color-scheme: dark;
  --bg: #080c12;
  --panel: rgba(18, 24, 35, 0.88);
  --field: #0e141e;
  --button: #252d3a;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: #343d4c;
  --text: #f5f7fb;
  --muted: #9ba7b8;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(58, 122, 254, 0.16), transparent 34rem),
    radial-gradient(circle at 85% 90%, rgba(106, 76, 240, 0.12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

button, select, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(1240px, calc(100% - 40px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(36px, env(safe-area-inset-top)) 0 max(36px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8f9aac;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1, h2 { letter-spacing: -0.035em; }
h1 { margin-bottom: 10px; font-size: clamp(2.5rem, 6vw, 4.6rem); line-height: 0.98; }
h2 { margin-bottom: 6px; font-size: 1.2rem; }

.header-copy, .panel-title p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.status-pill {
  max-width: 48%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(9, 13, 20, 0.78);
  color: #dfe5ef;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(380px, 1.06fr);
  gap: 18px;
}

.input-panel, .result-panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.input-panel {
  display: flex;
  flex-direction: column;
  min-height: 710px;
  padding: 24px;
}

.panel-title { margin-bottom: 16px; }

.drop-zone {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 330px;
  place-items: center;
  border: 1px dashed #3b4656;
  border-radius: 20px;
  background: rgba(9, 14, 21, 0.72);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-active {
  border-color: #5f8ff7;
  outline: none;
  box-shadow: 0 0 0 3px rgba(95, 143, 247, 0.15);
}

.drop-zone.is-dragover {
  border-color: #8b70f5;
  background: rgba(81, 63, 153, 0.16);
  box-shadow: 0 0 0 3px rgba(118, 87, 237, 0.16);
}

.drop-zone.is-busy { cursor: progress; }
#fileInput { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.empty-state { display: grid; gap: 10px; padding: 28px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); font-size: 1.3rem; }
#previewImage { width: 100%; height: 100%; max-height: 56vh; object-fit: contain; background: #090e15; transition: transform 160ms ease; }

.notice {
  margin-top: 12px;
  border: 1px solid rgba(242, 196, 94, 0.42);
  border-radius: 14px;
  padding: 11px 13px;
  background: rgba(242, 196, 94, 0.1);
  color: #ffdc8e;
  line-height: 1.45;
}

.notice.is-error { border-color: rgba(255, 119, 127, 0.48); background: rgba(255, 119, 127, 0.1); color: #ffb0b0; }
.controls { display: grid; gap: 14px; padding: 16px 0; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-label { display: grid; gap: 8px; color: #c4ccd8; font-size: 14px; font-weight: 650; }

.switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  padding: 10px 14px;
  background: var(--field);
  color: var(--text);
}

.switch-label input { width: 18px; height: 18px; accent-color: #4f8cff; }

select {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  padding: 0 14px;
  outline: none;
  background: var(--field);
  color: var(--text);
}

select:focus, textarea:focus { border-color: #5f8ff7; box-shadow: 0 0 0 3px rgba(95, 143, 247, 0.15); }
.button-grid { display: grid; gap: 10px; }
.main-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.text-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }

button {
  min-height: 48px;
  border: 0;
  border-radius: 15px;
  padding: 0 16px;
  background: var(--button);
  color: #e9eef8;
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

button:hover:not(:disabled) { filter: brightness(1.08); }
button:focus-visible:not(:disabled) { outline: 3px solid rgba(95, 143, 247, 0.34); outline-offset: 2px; }
button:active:not(:disabled) { transform: translateY(1px) scale(0.995); }
button.primary { background: linear-gradient(135deg, #397ff5, #6d50e6); color: #fff; }
button.primary:disabled { background: var(--button); }
button:disabled, select:disabled, input:disabled { color: #6f7b8d; cursor: not-allowed; opacity: 0.65; }

.progress-wrap { display: grid; gap: 8px; }
.progress-meta { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 0.85rem; }
progress { width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 999px; background: #242c38; }
progress::-webkit-progress-bar { background: #242c38; }
progress::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, #397ff5, #7657ed); }
progress::-moz-progress-bar { border-radius: 999px; background: linear-gradient(90deg, #397ff5, #7657ed); }

.result-panel { display: grid; grid-template-rows: auto 1fr auto; min-height: 710px; padding: 24px; }
.result-title { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; }
.result-actions { display: flex; gap: 10px; }

textarea {
  width: 100%;
  min-height: 540px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 16px;
  outline: none;
  background: rgba(9, 14, 21, 0.86);
  color: var(--text);
  line-height: 1.55;
}

textarea::placeholder { color: #6f7b8d; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .input-panel, .result-panel { min-height: auto; }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 680px); padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .app-header { align-items: start; flex-direction: column; }
  .status-pill { max-width: 100%; }
  .input-panel, .result-panel { border-radius: 24px; padding: 20px; }
  .settings-grid, .main-actions, .text-actions { grid-template-columns: 1fr; }
  .drop-zone { min-height: 300px; }
  .result-title { grid-template-columns: 1fr; }
  .result-actions { display: grid; grid-template-columns: 1fr 1fr; }
  textarea { min-height: 360px; }
}

@media (max-width: 430px) { .result-actions { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
