/* DigitConnection Publishing Center - Layout */
/* Notion / Medium style */

:root {
  --bg: #f7f7f7;
  --text: #222;
  --border: #e5e5e5;
  --panel-bg: #fff;
  --accent: #2383e2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}
.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}
.header a.btn { text-decoration: none; }
.header-breadcrumb { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.header-breadcrumb .header-back { font-size: 0.8125rem; color: #6b7280; text-decoration: none; }
.header-breadcrumb .header-back:hover { color: #111; }
.header-breadcrumb .header-sep { color: #9ca3af; font-size: 0.875rem; }
.header-desc {
  padding: 0 24px 12px;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--gray-600, #6b7280);
  border-bottom: 1px solid var(--border);
}

/* Toolbars */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
}
.toolbar-bottom {
  border-bottom: none;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover {
  background: var(--bg);
  border-color: #ccc;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #666;
}

/* Main: Editor + Preview */
.main.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.editor-panel {
  flex: 0 0 50%;
  display: flex;
  min-width: 0;
}

#editor {
  width: 100%;
  min-height: 400px;
  padding: 20px;
  font-family: monospace;
  font-size: 14px;
  line-height: 1.6;
  border: none;
  border-right: 1px solid var(--border);
  background: #fafafa;
  resize: none;
  outline: none;
  color: var(--text);
}

.preview-panel {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: var(--bg);
}

#preview-wrap {
  margin: 0 auto;
}

/* Print Mode: A4 page */
body.print-mode #preview-wrap {
  max-width: 210mm;
}
body.print-mode .page {
  width: 210mm;
  min-height: 297mm;
  padding: 25mm;
  margin: 0 auto;
  background: white;
  box-shadow: 0 0 8px rgba(0,0,0,0.1);
  font-family: "Times New Roman", serif;
  line-height: 1.8;
  text-align: justify;
}
body.print-mode .page h1 { font-size: 22pt; margin: 1em 0 0.5em; }
body.print-mode .page h2 { font-size: 18pt; margin: 1.25em 0 0.5em; }
body.print-mode .page h3 { font-size: 16pt; margin: 1em 0 0.5em; }
body.print-mode .page p { margin: 0.5em 0; }
body.print-mode .page img {
  max-width: 100%;
  height: auto;
}

/* Web Mode */
body.web-mode #preview-wrap {
  width: 100%;
  max-width: 1200px;
  margin: auto;
}
body.web-mode .page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px;
  background: white;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
}
body.web-mode .page h1 { font-size: 2em; }
body.web-mode .page h2 { font-size: 1.5em; }
body.web-mode .page h3 { font-size: 1.25em; }
body.web-mode .page img {
  max-width: 100%;
  height: auto;
}

/* Default: print-mode */
body:not(.web-mode) #preview-wrap {
  max-width: 210mm;
}
.page {
  box-sizing: border-box;
}
.page .placeholder {
  color: #999;
}

/* TOC */
.toc-container {
  max-width: 210mm;
  margin: 0 auto 16px;
  padding: 16px 20px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.toc-container[aria-hidden="true"] {
  display: none;
}
.toc-container h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}
.toc-list {
  margin: 0;
  padding-left: 20px;
}
.toc-list li { margin: 4px 0; }
.toc-list a {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}
.toc-list a:hover { text-decoration: underline; }

/* Table & figure */
.page table { border-collapse: collapse; width: 100%; margin: 0.5em 0; }
.page th, .page td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.page figure, .page table { page-break-inside: avoid; }

/* Responsive */
@media (max-width: 900px) {
  .main.editor-container {
    flex-direction: column;
  }
  .editor-panel {
    flex: 0 0 auto;
    min-height: 300px;
  }
  #editor {
    min-height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .preview-panel {
    padding: 16px;
  }
}
