:root {
  --bg: #f4efe7;
  --panel: rgba(255, 252, 247, 0.88);
  --panel-border: rgba(41, 34, 28, 0.12);
  --text: #201910;
  --muted: #66584a;
  --accent: #d95d39;
  --accent-dark: #aa3f20;
  --success: #2d6a4f;
  --error: #9b2226;
  --shadow: 0 24px 80px rgba(73, 53, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(217, 93, 57, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(69, 123, 157, 0.12), transparent 30%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 100%);
}

button,
textarea,
.file-button,
select {
  font: inherit;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 4vw, 4.4rem);
  line-height: 0.95;
}

.intro {
  max-width: 780px;
  margin: 16px 0 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(45, 106, 79, 0.1);
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 600;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 20px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.editor-panel,
.preview-panel {
  padding: 22px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
.file-button,
.select-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff8f3;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
  text-decoration: none;
}

button:hover,
.file-button:hover,
.select-wrap:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

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

.select-wrap {
  position: relative;
  padding-right: 38px;
}

.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #fff8f3;
  pointer-events: none;
  font-size: 0.95rem;
}

.select-wrap select {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff8f3;
  font-weight: 700;
  cursor: pointer;
  min-width: 152px;
  outline: none;
}

.select-wrap select option {
  color: var(--text);
}

#file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(41, 34, 28, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
}

.meta-label {
  flex: 0 0 auto;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-dark);
}

.meta-value {
  min-width: 0;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

textarea {
  width: 100%;
  min-height: 520px;
  padding: 18px;
  border: 1px solid rgba(41, 34, 28, 0.12);
  border-radius: 18px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-family: "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

textarea:focus {
  outline: 2px solid rgba(217, 93, 57, 0.24);
  border-color: rgba(217, 93, 57, 0.4);
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(102, 88, 74, 0.12);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.status.ready {
  background: rgba(45, 106, 79, 0.14);
  color: var(--success);
}

.status.error {
  background: rgba(155, 34, 38, 0.12);
  color: var(--error);
}

.error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(155, 34, 38, 0.08);
  color: var(--error);
  line-height: 1.5;
}

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 620px;
  padding: 24px;
  border: 1px dashed rgba(41, 34, 28, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(247, 240, 231, 0.72)),
    linear-gradient(90deg, rgba(32, 25, 16, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(32, 25, 16, 0.03) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  overflow: auto;
}

.preview svg {
  max-width: 100%;
  height: auto;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 20px, 1200px);
    padding: 20px 0 28px;
  }

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

  .panel-head,
  .upload-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: flex-start;
  }

  textarea {
    min-height: 360px;
  }

  .preview {
    min-height: 420px;
  }
}
