:root {
  color-scheme: light;
  --info-bar-height: 174px;
  --bg: #f4f5f1;
  --surface: #ffffff;
  --surface-soft: #fafaf7;
  --surface-strong: #eef2f0;
  --ink: #1d2220;
  --muted: #66706b;
  --border: #d9ddd6;
  --border-strong: #bcc5bf;
  --accent: #24756d;
  --accent-dark: #1d5e58;
  --blue: #2f5f9f;
  --warm: #cf5f35;
  --soft-accent: #e2f1ee;
  --code-bg: #1e2524;
  --code-ink: #f5f1e8;
  --shadow: 0 12px 32px rgba(25, 34, 31, 0.09);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-family: var(--sans);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

body.legal-page {
  min-height: 100%;
  overflow: auto;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  height: calc(100vh - var(--info-bar-height));
  min-height: 0;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  border-right: 1px solid var(--border);
  background: #fbfbf8;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 780;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 14px;
}

.language-row {
  padding: 0 16px 14px;
}

.language-link {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--blue);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  font-size: 13px;
}

.file-panel-head {
  height: 40px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.file-list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.file-list::-webkit-scrollbar,
.preview::-webkit-scrollbar,
.editor::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.file-list::-webkit-scrollbar-thumb,
.preview::-webkit-scrollbar-thumb,
.editor::-webkit-scrollbar-thumb {
  background: #c9cec7;
  border-radius: 4px;
}

.file-card {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  margin-bottom: 4px;
}

.file-select {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 7px 6px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.file-card:hover {
  background: #f2f5f2;
}

.file-card.is-active {
  background: var(--soft-accent);
  border-color: #bad8d2;
}

.file-remove {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.file-remove:hover {
  background: #ffffff;
  border-color: #e2c3b5;
  color: var(--warm);
}

.file-remove svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 680;
  font-size: 13px;
}

.file-meta-line {
  margin-top: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--warm);
  opacity: 0;
}

.file-card.is-dirty .file-dot {
  opacity: 1;
}

.empty-list {
  min-height: 140px;
  display: grid;
  place-items: center;
  padding: 16px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}

.main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 76px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.doc-title {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.file-name-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
  font-weight: 780;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.dirty-light {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--warm);
  opacity: 0;
}

.dirty-light.is-visible {
  opacity: 1;
}

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

.button,
.icon-button,
.segment {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button {
  padding: 0 12px;
  min-width: 74px;
}

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

.button:hover,
.icon-button:hover,
.segment:hover {
  background: var(--surface-soft);
  border-color: var(--border-strong);
}

.button:active,
.icon-button:active,
.segment:active {
  transform: translateY(1px);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.button.secondary {
  color: var(--blue);
}

.button.warm {
  color: var(--warm);
}

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

.button svg,
.icon-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.segmented {
  height: 38px;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(52px, auto);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface);
}

.segment {
  min-width: 52px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
}

.segment:last-child {
  border-right: 0;
}

.segment.is-active {
  color: #ffffff;
  background: var(--blue);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.pane {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.pane-head {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

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

.metric {
  color: var(--muted);
  font-weight: 520;
  white-space: nowrap;
}

.editor {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: 0;
  padding: 22px;
  background: #fffefa;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
  tab-size: 2;
}

.editor:disabled,
.file-name-input:disabled {
  color: var(--muted);
}

.editor:disabled {
  background: #f8f8f4;
}

.preview {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 28px 32px 60px;
  background: #ffffff;
  line-height: 1.72;
}

.preview.theme-paper {
  background: #fffdf7;
  color: #25231f;
}

.preview.theme-focus {
  background: #f8fbfb;
}

.preview.theme-dark {
  background: #191f21;
  color: #edf0ec;
}

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  margin: 1.35em 0 0.55em;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
}

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

.preview h1 {
  font-size: 34px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.preview h2 {
  font-size: 25px;
}

.preview h3 {
  font-size: 20px;
}

.preview p,
.preview ul,
.preview ol,
.preview blockquote,
.preview pre,
.preview table {
  margin: 0 0 1em;
}

.preview a {
  color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.preview.theme-dark a {
  color: #8ab7ff;
}

.preview ul,
.preview ol {
  padding-left: 1.5em;
}

.preview li + li {
  margin-top: 0.28em;
}

.preview blockquote {
  margin-left: 0;
  margin-right: 0;
  border-left: 4px solid var(--accent);
  background: var(--soft-accent);
  padding: 10px 14px;
  color: #31403f;
  border-radius: 0 7px 7px 0;
}

.preview.theme-dark blockquote {
  background: #203331;
  color: #dce8e3;
}

.preview pre {
  overflow: auto;
  padding: 14px 16px;
  border-radius: 7px;
  background: var(--code-bg);
  color: var(--code-ink);
  line-height: 1.55;
}

.preview code {
  font-family: var(--mono);
  font-size: 0.92em;
}

.preview :not(pre) > code {
  background: #edf0eb;
  color: #293a37;
  padding: 0.16em 0.34em;
  border-radius: 5px;
}

.preview.theme-dark :not(pre) > code {
  background: #273031;
  color: #f5eadc;
}

.preview table {
  width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

.preview th,
.preview td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.preview.theme-dark th,
.preview.theme-dark td {
  border-color: #3e494b;
}

.preview th {
  background: var(--surface-soft);
  font-weight: 750;
}

.preview.theme-dark th {
  background: #222b2d;
}

.preview hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

.preview img {
  max-width: 100%;
  height: auto;
  border-radius: 7px;
}

.preview mark {
  background: #ffe3a3;
  color: inherit;
  padding: 0.08em 0.22em;
  border-radius: 4px;
}

.site-info {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  height: var(--info-bar-height);
  display: grid;
  grid-template-columns: minmax(320px, 1.35fr) minmax(220px, 0.78fr) minmax(260px, 1fr) minmax(220px, 0.82fr);
  gap: 10px;
  align-items: stretch;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(244, 245, 241, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 -12px 30px rgba(25, 34, 31, 0.08);
  overflow: auto;
}

.seo-copy,
.ad-panel,
.faq-panel,
.notice-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(25, 34, 31, 0.06);
}

.seo-copy {
  padding: 12px 14px;
  overflow: auto;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--warm);
  font-size: 11px;
  font-weight: 800;
}

.seo-copy h2,
.faq-panel h2,
.notice-panel h2 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.3;
  font-weight: 820;
}

.seo-copy p,
.faq-panel p,
.notice-panel p {
  margin: 0;
  color: #4d5752;
  font-size: 12px;
  line-height: 1.5;
}

.seo-copy p + p {
  margin-top: 6px;
}

.ad-panel {
  display: grid;
  gap: 8px;
  padding: 8px;
  background: #f8faf9;
}

.ad-slot {
  min-height: 70px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px;
  border: 1px dashed #aebbb5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.ad-slot.compact {
  min-height: 54px;
}

.ad-slot span {
  font-size: 12px;
  font-weight: 800;
  color: var(--blue);
}

.ad-slot strong {
  color: #303936;
  font-size: 12px;
  line-height: 1.35;
}

.faq-panel,
.notice-panel {
  padding: 12px 14px;
  overflow: auto;
}

.faq-panel details {
  border-top: 1px solid var(--border);
  padding: 7px 0;
}

.faq-panel details:last-child {
  padding-bottom: 0;
}

.faq-panel summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
}

.faq-panel details p {
  margin-top: 5px;
}

.notice-panel {
  background: #fffdf7;
}

.notice-panel a {
  color: var(--blue);
  font-weight: 700;
  text-underline-offset: 3px;
}

.legal-wrap {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.legal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.legal-nav a {
  color: var(--blue);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
}

.legal-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-card {
  padding: 32px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.legal-card h1 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 38px;
  line-height: 1.12;
  font-weight: 840;
}

.legal-updated {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.legal-card section {
  margin-top: 28px;
}

.legal-card h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.25;
  font-weight: 820;
}

.legal-card p,
.legal-card li {
  color: #4d5752;
  font-size: 15px;
  line-height: 1.76;
}

.legal-card p {
  margin: 0;
}

.legal-card p + p {
  margin-top: 12px;
}

.legal-card ul {
  margin: 0;
  padding-left: 22px;
}

.legal-card a {
  color: var(--blue);
  text-underline-offset: 3px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--info-bar-height) + 16px);
  transform: translateX(-50%) translateY(16px);
  z-index: 30;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 7px;
  background: #1f2523;
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.drop-zone {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: none;
  place-items: center;
  background: rgba(36, 117, 109, 0.1);
  border: 3px dashed var(--accent);
  color: var(--accent-dark);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 800;
  pointer-events: none;
}

.drop-zone.is-visible {
  display: grid;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }

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

  .toolbar {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  :root {
    --info-bar-height: 158px;
  }

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

  .sidebar {
    grid-template-rows: auto auto auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .file-list {
    display: none;
  }

  .file-panel-head {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
  }

  .pane {
    min-height: 0;
  }

  .site-info {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(260px, 84vw);
    gap: 8px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .seo-copy,
  .faq-panel,
  .notice-panel {
    padding: 10px 12px;
  }

  .legal-wrap {
    width: min(100% - 20px, 920px);
    padding: 16px 0 36px;
  }

  .legal-card {
    padding: 24px 18px;
  }

  .legal-card h1 {
    font-size: 30px;
  }

  body[data-view="edit"] .preview-pane,
  body[data-view="preview"] .editor-pane {
    display: none;
  }

  body[data-view="split"] .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    min-height: 0;
    padding: 12px;
  }

  .toolbar,
  .pane-tools {
    width: 100%;
  }

  .segmented {
    grid-auto-columns: minmax(0, 1fr);
    width: 100%;
  }

  .button {
    min-width: 0;
  }

  .preview {
    padding: 22px 18px 48px;
  }

  .preview h1 {
    font-size: 28px;
  }
}

@media (min-width: 821px) {
  body[data-view="edit"] .workspace,
  body[data-view="preview"] .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-view="edit"] .preview-pane,
  body[data-view="preview"] .editor-pane {
    display: none;
  }
}

@media print {
  body {
    background: #ffffff;
    overflow: visible;
  }

  .sidebar,
  .topbar,
  .editor-pane,
  .pane-head,
  .site-info,
  .toast,
  .drop-zone {
    display: none !important;
  }

  .shell,
  .main,
  .workspace,
  .pane {
    display: block;
    height: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .preview-pane {
    display: block !important;
  }

  .preview {
    overflow: visible;
    padding: 0;
  }
}
