:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #565656;
  --line: #dedede;
  --line-strong: #111111;
  --soft: #f5f5f5;
  --good: #1f7a45;
  --warn: #9a5a00;
  --bad: #a22727;
  --focus: #005fcc;
  --pad: 18px;
  --gap: 12px;
  --font-sans: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", "Songti SC", "Songti TC", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--text);
  color: var(--bg);
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: var(--bg);
  color: var(--text);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

button[disabled] {
  border-color: var(--line);
  background: var(--soft);
  color: var(--muted);
  cursor: not-allowed;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  padding: 10px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

label span {
  color: var(--muted);
  font-size: 0.82rem;
}

.studio-shell {
  min-height: 100vh;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: var(--pad);
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: var(--gap);
  border: 1px solid var(--line-strong);
  padding: clamp(20px, 5vw, 36px);
}

.login-panel img {
  width: 120px;
  height: auto;
}

.login-panel h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 8vw, 4rem);
  line-height: 1;
}

#login-message,
.status-line {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
}

.status-line[data-tone="error"] {
  color: #a32222;
}

.studio-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  border-bottom: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  padding: 10px var(--pad);
  backdrop-filter: blur(12px);
}

.studio-header div {
  display: flex;
  align-items: center;
  gap: var(--gap);
  min-width: 0;
  font-weight: 800;
}

.studio-header img {
  width: 92px;
  height: auto;
}

.studio-header nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(420px, 1.35fr) minmax(360px, 1fr);
  gap: var(--gap);
  padding: var(--gap);
}

.article-sidebar,
.editor-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--bg);
}

.article-sidebar,
.preview-panel {
  align-self: start;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 84px);
  overflow: auto;
}

.sidebar-head,
.preview-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  border-bottom: 1px solid var(--line);
  padding: 12px var(--pad);
}

.sidebar-head h2,
.preview-head h2,
.section-title h3 {
  margin: 0;
  font-size: 1rem;
}

.article-list {
  display: grid;
}

.article-list button {
  display: grid;
  min-height: auto;
  justify-items: start;
  gap: 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 12px var(--pad);
  text-align: left;
}

.article-list button.is-active {
  background: var(--text);
  color: var(--bg);
}

.article-list small {
  color: var(--muted);
  font-weight: 600;
}

.article-list button.is-active small {
  color: color-mix(in srgb, var(--bg) 72%, transparent);
}

.editor-panel {
  display: grid;
  gap: var(--gap);
  padding: var(--pad);
}

.article-meta-grid,
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

.language-tabs,
.preview-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.language-tabs button,
.preview-mode button {
  min-height: 34px;
  background: var(--bg);
  color: var(--muted);
}

.language-tabs button.is-active,
.preview-mode button.is-active {
  background: var(--text);
  color: var(--bg);
}

.editor-form {
  display: grid;
  gap: var(--gap);
}

.image-editor {
  display: grid;
  gap: var(--gap);
  border-top: 1px solid var(--line);
  padding-top: var(--gap);
}

.upload-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line-strong);
  padding: 0 12px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.preview-panel {
  padding-bottom: var(--pad);
}

.article-preview {
  width: 100%;
  margin: 0 auto;
  padding: var(--pad);
}

.article-preview.is-mobile {
  max-width: 390px;
}

.article-preview .article-detail-eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.article-preview h1 {
  margin: 8px 0 0;
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  line-height: 1.02;
}

.article-preview .summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
}

.article-preview .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  border-bottom: 1px solid var(--line);
  margin-top: 14px;
  padding-bottom: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.article-preview section {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.article-preview h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.25;
}

.article-preview p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.8;
}

.article-preview figure {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: var(--gap);
  align-items: end;
  margin: 28px 0;
}

.article-preview img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--soft);
}

.article-preview figcaption {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.article-preview .faq {
  border-top: 1px solid var(--line);
  margin-top: 32px;
  padding-top: 20px;
}

.article-preview .faq article {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.article-preview .faq h3 {
  margin: 0;
  font-size: 1rem;
}

.article-preview.is-mobile figure {
  grid-template-columns: 1fr;
}

@media (max-width: 1120px) {
  .studio-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .studio-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .studio-header nav {
    justify-content: flex-start;
    width: 100%;
  }

  .studio-header nav button {
    flex: 1 1 140px;
  }

  .studio-layout {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .article-sidebar {
    position: static;
    max-height: 280px;
  }

  .article-meta-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }
}
