:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-alt: #fbfbfd;
  --ink: #111827;
  --muted: #667085;
  --soft: #98a2b3;
  --line: #d9dee7;
  --line-strong: #b8c0cc;
  --accent: #0b57d0;
  --accent-ink: #ffffff;
  --shadow: 0 16px 48px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard Variable", Pretendard, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  height: 100vh;
  min-height: 720px;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel-alt);
}

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

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand__mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.brand strong,
.brand span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 13px;
  line-height: 1.2;
}

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

.icon-button,
.plain-button,
.primary-button,
.block-tools button,
.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  line-height: 1;
}

.icon-button {
  width: 32px;
  padding: 0;
  font-size: 18px;
}

.plain-button {
  padding: 0 12px;
  font-size: 12px;
  font-weight: 650;
}

.primary-button {
  border-color: #111827;
  background: #111827;
  color: var(--accent-ink);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
}

.search-field {
  padding: 12px 14px 10px;
}

.search-field input,
.field input,
.field textarea,
.field select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-field input {
  height: 36px;
  padding: 0 11px;
  font-size: 13px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.field input,
.field select {
  height: 36px;
  padding: 0 10px;
}

.field textarea {
  min-height: 82px;
  padding: 10px;
  line-height: 1.55;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin: 0 14px 12px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f5;
}

.segmented button {
  min-height: 28px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.segmented button.is-active {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.article-list {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  padding: 0 10px 14px;
}

.article-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 12px 10px;
  text-align: left;
}

.article-row:hover,
.article-row.is-active {
  border-color: var(--line);
  background: #fff;
}

.article-row span,
.article-row em {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-style: normal;
}

.article-row strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.editor {
  display: grid;
  min-width: 0;
  grid-template-rows: 64px minmax(0, 1fr);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  padding: 0 18px;
}

.title-fields {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.title-input,
.subtitle-input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  padding: 0;
}

.title-input {
  color: var(--ink);
  font-size: 18px;
  font-weight: 720;
}

.subtitle-input {
  color: var(--muted);
  font-size: 12px;
}

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

.save-state {
  color: var(--muted);
  font-size: 12px;
}

.workarea {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(420px, 0.9fr) minmax(520px, 1.1fr);
}

.composer {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel + .panel {
  margin-top: 14px;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
}

.panel__head h2 {
  margin: 0;
  font-size: 13px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.field--wide {
  grid-column: 1 / -1;
}

.block-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.block-tools button {
  min-height: 28px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.block-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.block-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.block-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.09);
}

.block-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
  padding: 0 11px;
}

.block-card__head strong {
  font-size: 12px;
}

.block-card__head span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.block-card__meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.block-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.block-actions button {
  min-height: 25px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 650;
}

.block-actions button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.block-card__body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.block-card textarea {
  min-height: 92px;
}

.block-card[data-type="quote"] textarea {
  min-height: 70px;
  font-size: 17px;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rich-toolbar button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

.rich-toolbar button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.rich-editor {
  min-height: 180px;
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
  outline: none;
  line-height: 1.7;
}

.rich-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.12);
}

.rich-editor__node {
  min-height: 1.6em;
  margin: 0 0 12px;
}

.rich-editor__node:last-child {
  margin-bottom: 0;
}

.rich-editor__node[data-node-type="subheading"] {
  margin-top: 22px;
  font-size: 17px;
  font-weight: 760;
  line-height: 1.55;
}

.rich-editor a[data-link-type] {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.export-panel.is-collapsed {
  display: none;
}

.panel-state {
  color: var(--muted);
  font-size: 12px;
}

.pipeline-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 0.35fr);
  gap: 12px;
  padding: 14px;
}

.pipeline-actions {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 8px;
}

.image-grid {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
}

.image-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f0f2f5;
}

.image-thumb::after {
  content: "No image";
  color: var(--soft);
  font-size: 11px;
  font-weight: 650;
}

.image-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.image-actions button,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

.image-actions button:hover,
.upload-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.duo-editor {
  display: grid;
  gap: 12px;
}

.duo-editor__item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.duo-editor__item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.duo-editor__fields {
  display: grid;
  gap: 10px;
}

.preview {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 48px minmax(0, 1fr);
  background: #edf0f5;
}

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

.segmented--preview {
  width: 260px;
  margin: 0;
}

.viewport-slider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.viewport-slider input {
  width: 180px;
}

.preview__stage {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.device-frame {
  width: 1440px;
  min-height: 100%;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: width 160ms ease;
}

.device-frame iframe {
  display: block;
  width: 100%;
  height: calc(100vh - 136px);
  min-height: 620px;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .sidebar {
    display: none;
  }

  .workarea {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .composer {
    border-right: 0;
  }

  .preview {
    min-height: 720px;
  }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr;
    height: auto;
    align-items: start;
    padding: 12px;
  }

  .topbar__actions {
    justify-content: space-between;
  }

  .meta-grid,
  .image-grid,
  .pipeline-panel {
    grid-template-columns: 1fr;
  }

  .pipeline-actions {
    grid-column: auto;
  }

  .preview__toolbar {
    align-items: stretch;
    flex-direction: column;
    height: auto;
    padding: 10px;
  }

  .segmented--preview {
    width: 100%;
  }

  .viewport-slider input {
    width: 100%;
  }
}
