:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5f6b7a;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --soft: #e8f5f3;
  --danger: #b42318;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.reader {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 760;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.78fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(22, 32, 42, 0.06);
}

.editor-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
  min-height: 680px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

label.fill {
  grid-column: 1 / -1;
  min-height: 470px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

textarea {
  min-height: 100%;
  resize: vertical;
  font-family: var(--mono);
  line-height: 1.55;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #25313f;
}

button.ghost,
button.icon-btn {
  background: #eef2f5;
  color: var(--text);
}

button.ghost:hover,
button.icon-btn:hover {
  background: #dfe7ee;
}

.result {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-all;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 16px;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.preview-panel {
  overflow: hidden;
}

.markdown {
  padding: 18px;
  line-height: 1.68;
  word-break: break-word;
}

.preview-panel .markdown {
  max-height: 626px;
  overflow: auto;
}

.markdown.empty {
  color: var(--muted);
}

.markdown h1,
.markdown h2,
.markdown h3 {
  margin: 1.1em 0 0.45em;
  line-height: 1.25;
}

.markdown h1:first-child,
.markdown h2:first-child,
.markdown h3:first-child {
  margin-top: 0;
}

.markdown p,
.markdown ul,
.markdown ol,
.markdown blockquote,
.markdown pre {
  margin: 0.75em 0;
}

.markdown code {
  font-family: var(--mono);
  background: #eef2f5;
  border-radius: 4px;
  padding: 2px 5px;
}

.markdown pre {
  overflow: auto;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 14px;
}

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

.markdown blockquote {
  border-left: 4px solid var(--accent);
  background: var(--soft);
  padding: 8px 12px;
  color: #24433f;
}

.markdown img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.list-panel {
  margin-top: 16px;
}

.list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.item-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.image-item {
  grid-template-columns: 86px minmax(0, 1fr) auto;
}

.image-thumb {
  display: block;
  width: 76px;
  height: 76px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f5;
}

.image-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-info {
  min-width: 0;
}

.mini {
  padding: 8px 10px;
  font-size: 13px;
}

.danger {
  background: #fee4e2;
  color: var(--danger);
}

.danger:hover {
  background: #fecdca;
}

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

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

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

  .image-item {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .image-item .item-actions {
    grid-column: 1 / -1;
  }

  .item-actions {
    justify-content: flex-start;
  }
}
