:root {
  --page: #f3f4f7;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --surface-soft: #f8f9fb;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d6d9de;
  --blue: #3c7be1;
  --blue-soft: rgba(60, 123, 225, 0.08);
  --success: #0f8a49;
  --danger: #c2410c;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --sans: "Plus Jakarta Sans", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
input,
label,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1360px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.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;
}

.page-header {
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 0;
  font-size: 2.1rem;
  line-height: 1.18;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.page-header p {
  max-width: 56ch;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.workspace-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
}

.workspace-sidebar {
  padding: 20px 22px 24px;
}

.workspace-preview {
  border-left: 1px solid var(--line);
  padding: 20px 24px 24px;
}

.form-section + .form-section {
  margin-top: 36px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
  font-weight: 600;
}

.section-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.section-divider {
  margin: 16px 0 20px;
  border-top: 1px solid var(--line);
}

.field-label,
.result-meta dt,
.progress-kicker {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.upload-meta-copy,
.progress-note,
.preview-post-body p,
.preview-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.upload-dropzone {
  position: relative;
  width: 100%;
  min-height: 100%;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  overflow: hidden;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease;
}

.upload-dropzone:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(60, 123, 225, 0.12);
}

.upload-dropzone.is-drop-active {
  border-color: var(--blue);
  background: #f6f9ff;
}

.upload-dropzone img {
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: contain;
  background: #f3f4f6;
}

.upload-empty,
.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.upload-empty.is-active {
  background: rgba(246, 249, 255, 0.82);
}

.upload-empty.is-disabled {
  opacity: 0.65;
}

.upload-empty h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.inline-code {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.button-primary {
  background: var(--blue);
  color: #ffffff;
}

.button-primary:hover:not(:disabled) {
  background: #316cd2;
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
}

.notice-box,
.slider-field,
.progress-panel,
.preview-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.notice-box {
  margin-top: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.notice-box[data-state="success"] {
  color: #166534;
}

.notice-box[data-state="busy"] {
  color: #1d4ed8;
}

.notice-box[data-state="error"] {
  color: #b45309;
}

.field-stack {
  display: grid;
  gap: 16px;
}

.field-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field-group {
  margin: 0;
  padding: 0;
  border: 0;
}

.field-label {
  margin-bottom: 8px;
}

.field-group-compact .field-label {
  margin-bottom: 6px;
}

.control-list {
  display: grid;
  gap: 8px;
}

.control-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease;
}

.control-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.control-row:has(input:checked) {
  border-color: rgba(60, 123, 225, 0.4);
  background: var(--blue-soft);
}

.control-indicator {
  width: 16px;
  height: 16px;
  border: 1.5px solid #9ca3af;
  border-radius: 50%;
  background: #ffffff;
}

.control-row:has(input:checked) .control-indicator {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 4px var(--blue);
}

.control-copy strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.slider-field {
  padding: 10px 12px;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.slider-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.slider-value {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  font-family: var(--mono);
}

#speed-input {
  width: 100%;
  margin-top: 12px;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: #dbe1ea;
  outline: none;
}

#speed-input::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
}

#speed-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.77rem;
}

.toggle-list {
  display: grid;
  gap: 8px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}

.toggle-copy strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.action-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.progress-panel {
  padding: 14px;
  background: var(--surface-soft);
}

.progress-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.progress-kicker {
  margin: 0;
}

.progress-title {
  margin: 4px 0 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.progress-percent {
  font-family: var(--mono);
  font-size: 0.92rem;
}

.progress-track {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e6e9ef;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3c7be1, #5fa0f6);
  transition: width 180ms ease;
}

.progress-panel[data-status="complete"] .progress-fill {
  background: linear-gradient(90deg, #0f8a49, #32c96b);
}

.progress-panel[data-status="error"] .progress-fill {
  background: linear-gradient(90deg, #c2410c, #f97316);
}

.progress-note {
  margin-top: 10px;
}

.progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.step-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.step-status.is-active {
  border-color: rgba(60, 123, 225, 0.35);
  background: var(--blue-soft);
  color: #1d4ed8;
}

.step-status.is-done {
  border-color: rgba(15, 138, 73, 0.2);
  background: rgba(240, 253, 245, 0.95);
  color: #166534;
}

.preview-section {
  height: 100%;
}

.preview-shell {
  overflow: hidden;
  background: #ffffff;
}

.preview-shell.is-post-mode {
  background: #fbfbfc;
}

.preview-post-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.preview-post-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e7eefb;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.preview-post-meta {
  display: grid;
  gap: 2px;
}

.preview-post-meta strong {
  font-size: 0.92rem;
  font-weight: 600;
}

.preview-post-meta span {
  color: var(--muted);
  font-size: 0.78rem;
}

.preview-post-body {
  padding: 12px 16px 0;
  background: #ffffff;
}

.preview-media {
  position: relative;
  min-height: 360px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f6f7f9;
}

.preview-shell:not(.is-post-mode) .preview-media {
  border-top: 0;
}

.preview-media > .upload-dropzone,
.preview-media > img,
.preview-media > video,
.preview-media > .preview-empty {
  position: absolute;
  inset: 0;
}

.preview-media img,
.preview-media video {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: contain;
  background: #f3f4f6;
}

.preview-empty {
  background: linear-gradient(180deg, rgba(251, 251, 252, 0.98), rgba(247, 248, 250, 0.94));
}

.preview-post-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.preview-post-actions span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.result-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
}

.result-meta-item {
  padding: 12px 14px;
}

.result-meta-item + .result-meta-item {
  border-left: 1px solid var(--line);
}

.result-meta dd {
  margin: 6px 0 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 600;
}

@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .workspace-preview {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 24px, 100%);
    padding: 20px 0 32px;
  }

  .workspace-sidebar,
  .workspace-preview {
    padding: 18px;
  }

  .action-bar,
  .result-meta {
    grid-template-columns: 1fr;
  }

  .result-meta-item + .result-meta-item {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .section-head,
  .progress-head,
  .slider-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .preview-post-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preview-media,
  .preview-media img,
  .preview-media video {
    min-height: 260px;
  }
}
