:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f6f2ea;
  color: #202124;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(246, 242, 234, 0.96)),
    #f6f2ea;
}

button,
input,
textarea {
  font: inherit;
}

.composer-shell,
.article-shell,
.not-found {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
}

.composer-shell {
  padding: 32px 0 56px;
}

.composer-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.composer-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: #7a5b23;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
}

.ttl-group {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid #dfd2bd;
  border-radius: 8px;
  background: #fffaf1;
}

.ttl-group label {
  cursor: pointer;
}

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

.ttl-group span {
  display: block;
  min-width: 70px;
  padding: 9px 12px;
  border-radius: 6px;
  color: #67583f;
  text-align: center;
}

.ttl-group input:checked + span {
  background: #1f4f46;
  color: white;
}

.composer,
.result-card,
.article,
.not-found {
  border: 1px solid #e1d5c2;
  border-radius: 8px;
  background: rgba(255, 252, 247, 0.96);
  box-shadow: 0 18px 40px rgba(83, 61, 29, 0.08);
}

.composer {
  padding: 18px;
}

.title-field,
.editor-pane {
  display: grid;
  gap: 8px;
}

.title-field span,
.editor-pane span,
.pane-label {
  color: #6a604f;
  font-size: 13px;
  font-weight: 700;
}

.title-field input,
.editor-pane textarea,
.share-row input {
  width: 100%;
  border: 1px solid #d6cab7;
  border-radius: 6px;
  background: white;
  color: #202124;
  outline: none;
}

.title-field input {
  height: 48px;
  padding: 0 14px;
  font-size: 22px;
}

.title-field-hero {
  max-width: 960px;
}

.ttl-group {
  flex: 0 0 auto;
}

.title-field-hero span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.title-field-hero input {
  height: auto;
  min-height: 62px;
  padding: 8px 0;
  border: 0;
  border-bottom: 2px solid #d6cab7;
  border-radius: 0;
  background: transparent;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 750;
  line-height: 1.08;
}

.title-field-hero input::placeholder {
  color: #a49884;
}

.title-field-hero input:focus {
  border-color: #1f4f46;
  box-shadow: none;
}

.title-field input:focus,
.editor-pane textarea:focus,
.share-row input:focus {
  border-color: #1f4f46;
  box-shadow: 0 0 0 3px rgba(31, 79, 70, 0.14);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.editor-pane textarea {
  min-height: 560px;
  resize: vertical;
  padding: 14px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
}

.preview-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.markdown-body {
  min-height: 560px;
  overflow-wrap: anywhere;
  border: 1px solid #d6cab7;
  border-radius: 6px;
  background: white;
  padding: 24px;
}

.empty-preview {
  display: grid;
  place-items: center;
  color: #8a7f6d;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body a {
  color: #1b6f93;
}

.markdown-body blockquote {
  margin-left: 0;
  padding-left: 16px;
  border-left: 4px solid #d7a64a;
  color: #5d5548;
}

.markdown-body pre {
  overflow-x: auto;
  padding: 14px;
  border-radius: 6px;
  background: #202124;
  color: #f7f2ea;
}

.markdown-body code {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.markdown-body p code,
.markdown-body li code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #f1e8d8;
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  color: #6a604f;
  font-size: 14px;
}

.status-row .is-error {
  color: #a33824;
  font-weight: 700;
}

.primary-button,
.share-row button,
.share-row a,
.not-found a {
  border: 0;
  border-radius: 6px;
  background: #1f4f46;
  color: white;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.primary-button {
  min-width: 132px;
  padding: 12px 18px;
}

.primary-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.result-card {
  margin-top: 18px;
  padding: 18px;
}

.result-card h2 {
  font-size: 22px;
  margin-bottom: 12px;
}

.share-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.share-row input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
}

.share-row button,
.share-row a,
.not-found a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
}

.reader-page {
  background: #fffaf1;
}

.article-shell {
  max-width: 820px;
  padding: 44px 0 64px;
}

.article {
  padding: 38px;
}

.article h1 {
  font-size: clamp(34px, 6vw, 58px);
}

.article-meta {
  margin: 12px 0 28px;
  color: #7b705f;
  font-size: 14px;
}

.article .markdown-body {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
}

.not-found-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.not-found {
  max-width: 520px;
  padding: 34px;
  text-align: center;
}

.not-found h1 {
  font-size: 34px;
}

.not-found p:not(.eyebrow) {
  color: #6a604f;
}

@media (max-width: 820px) {
  .composer-shell,
  .article-shell,
  .not-found {
    width: min(100vw - 24px, 1180px);
  }

  .composer-head,
  .status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .ttl-group {
    width: 100%;
  }

  .ttl-group label {
    flex: 1;
  }

  .ttl-group span {
    min-width: 0;
  }

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

  .editor-pane textarea,
  .markdown-body {
    min-height: 360px;
  }

  .share-row {
    grid-template-columns: 1fr;
  }

  .article {
    padding: 24px;
  }
}
