:root {
  --bg: #f2eee5;
  --paper: #f8f4ec;
  --surface: #fcfaf5;
  --ink: #25211b;
  --ink-soft: #5f5649;
  --line: #d8cdbd;
  --line-strong: #baa990;
  --accent: #415d70;
  --accent-hover: #2e4555;
  --success: #2d6a56;
  --danger: #9e342b;
  --shadow: 0 18px 34px rgba(37, 33, 27, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Serif SC", serif;
  background:
    radial-gradient(1200px 640px at 92% -14%, rgba(65, 93, 112, 0.14), transparent 62%),
    radial-gradient(1000px 560px at -6% 110%, rgba(176, 139, 94, 0.12), transparent 64%),
    var(--bg);
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    repeating-linear-gradient(0deg, rgba(37, 33, 27, 0.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(37, 33, 27, 0.018) 0 1px, transparent 1px 3px);
}

.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 56px));
  margin: 42px auto 36px;
}

.hero {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  animation: fade-up 0.55s ease both;
}

.hero-kicker {
  margin: 0;
  color: var(--ink-soft);
  letter-spacing: 0.16em;
  font-size: 12px;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(42px, 5.2vw, 70px);
  line-height: 0.94;
  letter-spacing: 0.01em;
  font-weight: 600;
}

.hero-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 26px;
  max-width: 720px;
}

.editor-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.03fr 0.97fr;
}

.panel {
  background: linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 20px;
  box-shadow: var(--shadow);
  animation: fade-up 0.55s ease both;
}

.result-panel {
  animation-delay: 0.12s;
}

.panel-header {
  margin-bottom: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: 33px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.muted {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 22px;
}

.field-group {
  display: grid;
  gap: 10px;
}

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

.label {
  font-size: 14px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
}

.counter {
  font-size: 12px;
  color: var(--ink-soft);
}

textarea {
  width: 100%;
  min-height: 320px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  resize: vertical;
  color: var(--ink);
  background: #fffefb;
  font-size: 15px;
  line-height: 28px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(65, 93, 112, 0.18);
}

.hint {
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-soft);
}

.actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

button {
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 10px 18px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:active {
  transform: translateY(1px);
}

#submit {
  background: var(--accent);
  color: #ffffff;
}

#submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

.secondary {
  background: #f7f3ea;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.secondary:hover:not(:disabled) {
  background: #f1e9db;
}

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

.status {
  min-height: 20px;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-soft);
}

.status[data-state="working"] {
  color: #37556b;
}

.status[data-state="success"] {
  color: var(--success);
}

.status[data-state="error"] {
  color: var(--danger);
}

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

.result-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.elapsed-time {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

pre {
  margin-top: 14px;
  min-height: 340px;
  padding: 16px;
  border-radius: 2px;
  border: 1px solid var(--line-strong);
  background: #fffefb;
  white-space: pre-wrap;
  line-height: 28px;
  font-size: 15px;
}

.page-note {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  textarea,
  pre {
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .page {
    width: calc(100% - 26px);
    margin: 20px auto 24px;
  }

  .panel {
    padding: 14px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-note {
    flex-direction: column;
    gap: 4px;
  }
}
