:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --line: #dbe2ea;
  --text: #1d2733;
  --muted: #6b7a8a;
  --accent: #2b6cb0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", "Noto Sans KR", sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
}

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

.topbar h1 {
  margin: 0;
  font-size: 18px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#fileInput {
  display: none;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover {
  border-color: #c7d1dc;
}

.btn.secondary {
  min-width: 46px;
}

.workspace {
  display: grid;
  gap: 8px;
  padding: 8px;
  height: calc(100% - 62px);
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}

.pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.pane-title {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

#editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #0f1722;
  background: #fcfdff;
}

.preview {
  padding: 12px;
  overflow: auto;
  line-height: 1.6;
  font-size: 14px;
}

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  margin-top: 1.1em;
  margin-bottom: 0.5em;
}

.preview p {
  margin: 0.5em 0;
}

.preview pre {
  background: #0f1722;
  color: #ecf2f9;
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
}

.preview code {
  background: #eef4fb;
  border-radius: 5px;
  padding: 1px 4px;
}

.preview pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
}

.preview blockquote {
  margin: 0.6em 0;
  padding: 6px 10px;
  border-left: 4px solid #c0d2e7;
  color: #3b4f66;
  background: #f7fbff;
}

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

@media (min-width: 768px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
  }
}

@media print {
  .topbar,
  .editor-pane {
    display: none;
  }

  .workspace {
    display: block;
    height: auto;
    padding: 0;
  }

  .preview-pane {
    border: none;
  }

  .pane-title {
    display: none;
  }

  .preview {
    padding: 0;
    font-size: 12pt;
  }
}
