:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #687386;
  --line: #dbe2ea;
  --panel: #f8fafc;
  --paper: #ffffff;
  --blue: #2563eb;
  --teal: #0f766e;
  --rose: #be123c;
  --amber: #b45309;
  --green: #15803d;
  --shadow: 0 18px 45px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #edf2f7;
  font-family: Inter, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a.command {
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand,
.top-actions,
.format-bar,
.panel-title {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  font-weight: 800;
  font-size: 18px;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

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

.launch-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: #ecfeff;
  border-bottom: 1px solid #bae6fd;
}

.launch-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.launch-copy strong {
  font-size: 13px;
}

.launch-copy span {
  color: var(--muted);
  font-size: 12px;
}

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

.launch-actions .command {
  min-height: 32px;
  padding: 0 10px;
}

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

.command,
.icon-command,
.mini-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.command {
  padding: 0 13px;
}

.icon-command,
.mini-button {
  width: 38px;
  padding: 0;
}

.mini-button {
  width: 30px;
  min-height: 30px;
}

.command:hover,
.icon-command:hover,
.mini-button:hover {
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.command:disabled,
.icon-command:disabled,
.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.command.primary {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.command.github-cta {
  color: #fff;
  border-color: #111827;
  background: #111827;
  font-weight: 700;
}

.command.github-cta:hover {
  border-color: #0f766e;
  background: #0f766e;
}

.command.share-cta {
  color: #0f172a;
  border-color: #99f6e4;
  background: #ccfbf1;
  font-weight: 700;
}

.command.share-cta:hover {
  border-color: #14b8a6;
  background: #99f6e4;
}

.command svg,
.icon-command svg,
.mini-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(420px, 1fr) minmax(260px, 320px);
  gap: 14px;
  padding: 14px;
}

.left-panel,
.right-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.panel-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.panel-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-grid div {
  min-height: 66px;
  padding: 10px;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid #e6edf4;
}

.stat-grid span,
.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.stat-grid strong {
  font-size: 22px;
}

.outline-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
}

.outline-list button {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 7px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-list button:hover {
  background: #eef6ff;
  border-left-color: var(--blue);
}

.field {
  display: block;
  margin-top: 10px;
}

.field input,
.format-bar select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.small-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.editor-stage {
  min-width: 0;
  min-height: calc(100vh - 92px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.format-bar {
  gap: 8px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  position: sticky;
  top: 78px;
  z-index: 10;
}

.format-bar select {
  width: 130px;
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.drop-zone,
.document-surface {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}

.drop-zone {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 38px;
  text-align: center;
}

.drop-zone.hidden {
  display: none;
}

.drop-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e6f4f1;
  color: var(--teal);
  border: 1px solid #c8e5df;
}

.drop-mark svg {
  width: 34px;
  height: 34px;
}

.drop-zone h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 44px);
}

.drop-zone p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.document-surface {
  display: none;
  padding: 28px 16px 60px;
  overflow: auto;
}

.document-surface.active {
  display: block;
}

.paper-page {
  width: min(100%, 820px);
  min-height: 1060px;
  margin: 0 auto 18px;
  padding: 64px 72px;
  background: #fff;
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.paragraph {
  min-height: 28px;
  padding: 3px 5px;
  margin: 0 0 6px;
  border-radius: 4px;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
}

.paragraph:hover,
.paragraph:focus {
  background: #eef6ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.paragraph.title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 18px;
}

.paragraph.notice {
  padding: 10px 12px;
  border: 1px solid #c7d2fe;
  background: #f5f7ff;
}

.paragraph.report {
  border-left: 4px solid var(--teal);
  padding-left: 12px;
  font-weight: 700;
}

.inline-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.inline-table td {
  min-width: 100px;
  min-height: 36px;
  border: 1px solid #94a3b8;
  padding: 8px;
  vertical-align: top;
  outline: none;
}

.source-table {
  background: #fff;
}

.source-table .paragraph {
  min-height: 24px;
  margin: 0;
  padding: 2px 4px;
  line-height: 1.55;
}

.source-table .paragraph + .paragraph {
  margin-top: 4px;
}

.quality-list,
.change-list,
.package-summary,
.package-explorer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quality-item,
.package-item,
.explorer-row {
  display: grid;
  grid-template-columns: 9px 1fr;
  gap: 9px;
  align-items: start;
  padding: 9px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid #e6edf4;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.quality-item i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--green);
}

.quality-item.warn i,
.package-item.warn i,
.explorer-row.warn i {
  background: var(--amber);
}

.quality-item.info i,
.package-item.info i,
.explorer-row.info i {
  background: var(--blue);
}

.quality-item.danger i,
.package-item.danger i,
.explorer-row.danger i {
  background: var(--rose);
}

.package-item i,
.explorer-row i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-top: 5px;
  background: var(--blue);
}

.package-item strong,
.explorer-row strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.package-item span,
.explorer-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.package-tools {
  margin: 10px 0 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.package-tools select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
}

.package-tools .command {
  min-height: 34px;
  padding: 0 10px;
}

.change-item {
  width: 100%;
  border: 1px solid #e6edf4;
  border-radius: 8px;
  background: var(--panel);
  padding: 9px;
  text-align: left;
}

.change-item strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 3px;
}

.change-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-controls {
  display: grid;
  grid-template-columns: 30px minmax(56px, auto) 30px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.preview-controls strong {
  text-align: center;
  font-size: 13px;
  white-space: nowrap;
}

.zoom-control {
  min-width: 0;
  min-height: 30px;
  display: grid;
  grid-template-columns: 18px minmax(70px, 1fr) 42px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.zoom-control svg {
  width: 17px;
  height: 17px;
}

.zoom-control input {
  width: 100%;
  min-height: 24px;
}

.preview-pane {
  min-height: 220px;
  max-height: 460px;
  overflow: auto;
  display: grid;
  place-items: center;
  background: #eef2f7;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 10px;
}

.preview-pane svg {
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 8px 26px rgba(31, 41, 55, 0.12);
}

.preview-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.export-grid button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.export-grid button:hover {
  border-color: #94a3b8;
}

mark.search-hit {
  background: #fde68a;
  color: inherit;
  border-radius: 3px;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 230px minmax(360px, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-rows: auto auto 1fr;
  }

  .topbar,
  .launch-strip,
  .workspace,
  .right-panel {
    display: flex;
    flex-direction: column;
  }

  .topbar,
  .launch-strip {
    align-items: stretch;
    padding: 12px;
  }

  .top-actions,
  .launch-actions {
    justify-content: flex-start;
  }

  .format-bar {
    top: 0;
  }

  .paper-page {
    min-height: 820px;
    padding: 32px 22px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .left-panel,
  .right-panel,
  .format-bar,
  .drop-zone {
    display: none !important;
  }

  .workspace,
  .editor-stage,
  .document-surface {
    display: block;
    padding: 0;
    border: 0;
    background: #fff;
  }

  .paper-page {
    box-shadow: none;
    width: auto;
    min-height: 0;
    padding: 0;
  }
}
