:root {
  --bg: #f3ecde;
  --panel: rgba(255, 250, 241, 0.9);
  --panel-strong: #fff8ef;
  --ink: #1f1a16;
  --muted: #62554a;
  --accent: #b4492d;
  --accent-soft: #dca476;
  --line: rgba(53, 38, 24, 0.14);
  --shadow: 0 18px 40px rgba(72, 41, 21, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Zen Kaku Gothic New", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(180, 73, 45, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(110, 132, 79, 0.18), transparent 24%),
    linear-gradient(180deg, #f7f0e3 0%, var(--bg) 100%);
}

.app-shell {
  width: min(960px, calc(100% - 24px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-weight: 700;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  line-height: 1.2;
}

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

.controls {
  display: grid;
  gap: 18px;
  padding: 20px;
}

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

.field-label {
  font-size: 0.92rem;
  font-weight: 700;
}

.term-ja {
  margin-left: 0.35em;
  font-size: 0.8em;
  font-weight: 500;
  color: var(--muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  position: relative;
}

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

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  transition: 180ms ease;
}

.chip input:checked + span {
  border-color: transparent;
  background: var(--ink);
  color: #fff8ef;
  transform: translateY(-1px);
}

.select,
.text-input,
.textarea,
.primary-button,
.secondary-button {
  font: inherit;
}

.select,
.text-input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  color: var(--ink);
}

.select {
  height: 50px;
  padding: 0 16px;
}

.compact-select {
  height: 46px;
}

.text-input {
  height: 46px;
  padding: 0 14px;
}

.textarea {
  resize: vertical;
  min-height: 96px;
  padding: 14px 16px;
  line-height: 1.6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
}

.compact-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 14px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

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

.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.custom-style-panel {
  display: grid;
  gap: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.custom-style-panel-header {
  display: grid;
  gap: 4px;
}

.custom-style-panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.helper-text {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.6;
}

.field-card {
  padding: 12px;
  border: 1px solid rgba(53, 38, 24, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.field-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.detail-value {
  line-height: 1.6;
  word-break: break-word;
}

.custom-style-status {
  padding: 10px 12px;
  border: 1px solid rgba(180, 73, 45, 0.18);
  border-radius: 14px;
  background: rgba(180, 73, 45, 0.08);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.compact-textarea {
  min-height: 72px;
}

.saved-style-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-style-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px 0 12px;
  border-radius: 999px;
  background: rgba(31, 26, 22, 0.06);
  border: 1px solid var(--line);
  font-size: 0.86rem;
}

.saved-style-chip button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
}

.output {
  margin-top: 18px;
  padding: 20px;
}

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

.meta-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-badges span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(180, 73, 45, 0.1);
  color: var(--accent);
  font-size: 0.86rem;
}

.output-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.output-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.75);
}

.output-card h3 {
  font-size: 0.95rem;
}

.code-block {
  margin: 12px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.7;
}

.summary-list {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
}

.summary-list div {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.summary-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary-list dt {
  font-size: 0.82rem;
  color: var(--muted);
}

.summary-list dd {
  margin: 6px 0 0;
  line-height: 1.7;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 28px;
  }

  .controls,
  .output {
    padding: 18px;
  }

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

  .output-header {
    flex-direction: column;
  }
}
