:root {
  --bg: #f3efe6;
  --surface: #f8f4eb;
  --surface-strong: #fffdf8;
  --border: #d6cdc0;
  --border-strong: #b6ab9b;
  --text: #2d261f;
  --muted: #675d4f;
  --accent: #6a5035;
  --accent-soft: #ece1d2;
  --code-bg: #eee6da;
  --shadow: 0 10px 30px rgba(49, 38, 27, 0.06);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.85), rgba(243, 239, 230, 0.92)),
    repeating-linear-gradient(
      90deg,
      rgba(214, 205, 192, 0.12) 0,
      rgba(214, 205, 192, 0.12) 1px,
      transparent 1px,
      transparent 24px
    );
  color: var(--text);
  font-family: "Avenir Next", "Helvetica Neue", "Noto Sans", sans-serif;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

.app-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 16px auto;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(240px, 1fr) auto;
  gap: 20px;
  align-items: end;
  padding: 20px 24px;
  background: rgba(248, 244, 235, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-block h1,
.panel-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
}

.brand-block p,
.panel-header p,
.status-label {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.title-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-strong);
}

.title-input:focus,
.editor:focus {
  outline: 2px solid rgba(106, 80, 53, 0.18);
  border-color: var(--accent);
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.action-button {
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-strong);
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.action-button:hover,
.action-button:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  outline: none;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.status-item,
.panel {
  background: rgba(248, 244, 235, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.status-item {
  padding: 14px 16px;
}

.status-item strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 650;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 14px;
  margin-top: 14px;
  min-height: calc(100vh - 220px);
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.editor,
.preview {
  flex: 1;
  min-height: 0;
  padding: 20px;
}

.editor {
  border: 0;
  resize: none;
  background: transparent;
  line-height: 1.7;
  font-size: 1rem;
}

.preview {
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(249, 246, 240, 0.98));
  line-height: 1.7;
}

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

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  line-height: 1.25;
  margin: 1.6em 0 0.55em;
}

.preview p,
.preview ul,
.preview ol,
.preview blockquote,
.preview pre,
.preview table {
  margin: 0 0 1em;
}

.preview a {
  color: var(--accent);
}

.preview code {
  padding: 0.12em 0.35em;
  border-radius: 6px;
  background: var(--code-bg);
  font-family: "SFMono-Regular", "Consolas", monospace;
  font-size: 0.92em;
}

.preview pre {
  padding: 14px 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
}

.preview pre code {
  padding: 0;
  background: transparent;
}

.preview blockquote {
  padding-left: 16px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}

.preview table {
  width: 100%;
  border-collapse: collapse;
}

.preview th,
.preview td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.preview th {
  background: rgba(236, 225, 210, 0.55);
}

.preview img {
  max-width: 100%;
  border-radius: 8px;
}

.task-list {
  list-style: none;
  padding-left: 0;
}

.task-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.task-box {
  width: 16px;
  height: 16px;
  margin-top: 0.25em;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  flex: 0 0 auto;
}

.task-box.checked {
  background: var(--accent-soft);
  border-color: var(--accent);
  position: relative;
}

.task-box.checked::after {
  content: "";
  position: absolute;
  inset: 2px 4px 4px 2px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .action-bar {
    justify-content: flex-start;
  }

  .status-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .editor-panel,
  .preview-panel {
    min-height: 48vh;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 100%);
    margin: 10px auto;
  }

  .topbar,
  .panel-header,
  .editor,
  .preview {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .action-bar {
    gap: 8px;
  }
}
