* {
  box-sizing: border-box;
}

:root {
  --bg-page: #f1f5f9;
  --bg-panel: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 24px 60px -28px rgba(15, 23, 42, 0.25);
  --radius-large: 28px;
  --radius-medium: 18px;
  --radius-small: 12px;
  --font-base: 'Noto Sans SC', 'Noto Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-base);
  line-height: 1.6;
  min-height: 100vh;
}

.site-header {
  text-align: center;
  padding: 4rem 1.5rem 2.5rem;
}

.site-header .inner {
  max-width: 760px;
  margin: 0 auto;
}

.eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text-muted);
}

.site-header h1 {
  margin: 0.5rem 0 1rem;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
}

.site-header .intro {
  margin: 0 auto;
  font-size: 1rem;
  color: var(--text-muted);
}

.site-nav {
  margin: 1.5rem auto 0;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-nav__link {
  color: var(--text-main);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.site-nav__link:hover,
.site-nav__link:focus-visible {
  color: #2563eb;
  border-color: #2563eb;
}

.layout {
  display: grid;
  gap: 2rem;
  padding: 0 1.5rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  }
}

.controls {
  background: var(--bg-panel);
  border-radius: var(--radius-large);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: sticky;
  top: 1.5rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.control-textarea,
.control-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 0.85rem 1rem;
  font: inherit;
  background: #fff;
  resize: vertical;
  min-height: 160px;
}

.control-select {
  min-height: auto;
}

.control-textarea:focus-visible,
.control-select:focus-visible,
.color-custom input:focus-visible,
.font-option:focus-visible,
.color-swatch:focus-visible,
.primary-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.control-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.color-options {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}

.color-swatch {
  border-radius: var(--radius-small);
  border: 2px solid transparent;
  height: 44px;
  padding: 0;
}

.color-swatch.is-selected {
  border-color: rgba(15, 23, 42, 0.65);
}

.color-custom {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.color-custom input {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 0.3rem;
  width: 60px;
  height: 36px;
  cursor: pointer;
}

.color-custom.is-selected span {
  color: var(--text-main);
  font-weight: 600;
}

.font-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.font-option {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 0.75rem 1rem;
  text-align: left;
  background: #fff;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.font-option.is-selected {
  border-color: rgba(15, 23, 42, 0.6);
  box-shadow: 0 12px 30px -18px rgba(15, 23, 42, 0.45);
}

.control-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.primary-button {
  border: none;
  border-radius: var(--radius-small);
  padding: 0.95rem 1.2rem;
  font-weight: 600;
  background: #111827;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px -20px rgba(15, 23, 42, 0.65);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.status-message {
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.status-message.is-active {
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status-message.is-active::before {
  content: '';
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.preview {
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.preview-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.size-label {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.preview-stage {
  background: var(--bg-panel);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 420px;
}

.poster {
  width: min(100%, 480px);
  border-radius: var(--radius-medium);
  background: #0f172a;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
  --poster-ratio: 177.7778;
}

.poster::before {
  content: '';
  display: block;
  padding-bottom: calc(var(--poster-ratio) * 1%);
}

.poster-content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2.5rem, 6vw, 4rem);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}

.poster-text {
  margin: 0;
  color: #ffffff;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
  letter-spacing: 0;
  font-size: 48px;
  width: 100%;
}

.font-noto-sans {
  font-family: 'Noto Sans SC', 'Noto Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

.font-noto-serif {
  font-family: 'Noto Serif SC', 'Noto Serif', 'Songti SC', serif;
  font-weight: 600;
}

.font-inter {
  font-family: 'Inter', 'Noto Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
}

.site-footer {
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 959px) {
  .controls {
    position: static;
  }

  .poster {
    width: 100%;
  }
}
