:root {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #e8f2ee;
  background: #0d191b;
  font-synthesis: none;
  --bg: #0d191b;
  --surface: #122225;
  --surface-raised: #1a3031;
  --line: #2c4647;
  --text: #e8f2ee;
  --muted: #a7beb6;
  --accent: #6bd6ad;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, .button {
  cursor: pointer;
  border: 1px solid #376255;
  border-radius: 9px;
  background: #275b4c;
  color: #f7fffa;
  padding: 9px 13px;
  font-weight: 650;
}
button:hover, .button:hover { background: #32705c; }
button:disabled { opacity: .46; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
a { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.brand { font-size: .84rem; font-weight: 900; letter-spacing: .08em; white-space: nowrap; }
.brand span { color: var(--accent); font-weight: 600; letter-spacing: .03em; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  background: #172729;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.top-actions { display: flex; align-items: center; gap: 16px; }
#progress { color: var(--muted); font-size: .79rem; white-space: nowrap; }
.team-menu { position: relative; }
.team-menu > summary {
  cursor: pointer;
  list-style: none;
  border: 1px solid #46695e;
  border-radius: 9px;
  background: #203a38;
  padding: 8px 12px;
  color: #def8ea;
  font-size: .81rem;
  font-weight: 700;
  white-space: nowrap;
}
.team-menu > summary::-webkit-details-marker, .assignment-popover > summary::-webkit-details-marker { display: none; }
.team-menu > summary::after { content: "⌄"; margin-left: 13px; color: var(--accent); }
.team-menu[open] > summary { background: #2b5045; }
.team-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 9px);
  width: min(320px, calc(100vw - 24px));
  padding: 17px;
  display: grid;
  gap: 10px;
  background: #1a2d2f;
  border: 1px solid #45615c;
  border-radius: 14px;
  box-shadow: 0 18px 55px #0009;
  z-index: 50;
}
.team-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.team-heading strong { font-size: .94rem; }
.team-heading span { color: var(--muted); font-size: .7rem; white-space: nowrap; }
.team-popover label { color: #b6d3c5; font-size: .73rem; font-weight: 750; }
.team-popover select, .team-popover input, .sidebar input, .sidebar select, .assignment-panel select {
  width: 100%;
  min-width: 0;
  border: 1px solid #46625d;
  border-radius: 8px;
  background: #0d1c1e;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}
.team-popover select:focus, .team-popover input:focus, .sidebar input:focus, .sidebar select:focus { border-color: var(--accent); }
.team-divider { margin-top: 7px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .73rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.reviewer-add { display: flex; gap: 7px; }
.reviewer-add input { flex: 1; }
.reviewer-add button, .distribute { font-size: .76rem; padding: 8px 10px; }
.distribute { width: 100%; background: transparent; border-color: #4b6b61; }
#reviewer-message { margin: 0; color: var(--muted); font-size: .73rem; line-height: 1.4; }
.team-links { display: flex; gap: 14px; margin-top: 5px; padding-top: 12px; border-top: 1px solid var(--line); }
.team-links a { color: #bdebd4; font-size: .77rem; text-decoration: none; }
.team-links a:hover { text-decoration: underline; }

.workspace { height: calc(100vh - 64px); min-height: 0; display: grid; grid-template-columns: 290px minmax(0,1fr); }
.sidebar {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 13px 10px;
  background: #132326;
  border-right: 1px solid var(--line);
}
.sidebar-head { display: flex; justify-content: space-between; align-items: end; gap: 8px; padding: 0 5px 5px; }
.sidebar-eyebrow { display: block; color: #7faf9a; font-size: .64rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.sidebar h2 { font-size: 1.12rem; line-height: 1.2; margin: 3px 0 0; }
#visible-count { min-width: 32px; text-align: center; padding: 4px 7px; background: #284238; border-radius: 999px; color: #c5edd7; font-size: .72rem; font-weight: 800; }
.sidebar input { height: 39px; }
.sidebar select { height: 38px; color: #cbe1d7; }
.article-list { overflow: auto; min-height: 0; flex: 1; margin: 3px -4px 0; padding: 0 4px 12px; }
.article-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0;
  padding: 10px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #d4e4dc;
  text-align: left;
  font-size: .82rem;
  line-height: 1.34;
  font-weight: 550;
}
.article-item:hover { background: #203637; border-color: #2e4a48; }
.article-item.selected { background: #285044; border-color: #457b63; color: #fff; }
.badge { flex: 0 0 auto; color: #829e96; font-size: 1.08rem; line-height: 1; }
.badge.done { color: var(--accent); }
.article-labels { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.article-item-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.article-owner { font-size: .69rem; color: #90b6a5; font-weight: 650; }
.article-item.selected .article-owner { color: #ceeedc; }
.list-empty { margin: 24px 8px; color: var(--muted); font-size: .83rem; line-height: 1.5; }

.editor { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 100px;
  padding: 15px 21px;
  background: #101d20;
  border-bottom: 1px solid var(--line);
}
.article-heading { min-width: 0; }
.article-meta { display: flex; align-items: center; gap: 12px; color: #8eb5a4; font-size: .72rem; }
.filename { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }
.editor-head h1 { margin: 7px 0 0; font-size: clamp(1.02rem,1.25vw,1.3rem); line-height: 1.3; font-weight: 760; max-width: 80ch; }
.assignment-popover { position: relative; flex: 0 0 auto; }
.assignment-popover > summary {
  cursor: pointer;
  list-style: none;
  padding: 4px 9px;
  border: 1px solid #426353;
  border-radius: 999px;
  background: #1b3b32;
  color: #bff0d4;
  font-size: .71rem;
  font-weight: 750;
}
.assignment-popover > summary::after { content: "⌄"; margin-left: 8px; }
.assignment-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 235px;
  padding: 13px;
  display: grid;
  gap: 10px;
  border: 1px solid #45615c;
  border-radius: 11px;
  background: #1b3030;
  box-shadow: 0 14px 42px #0009;
  z-index: 25;
}
.assignment-panel label { color: #b6d3c5; font-size: .73rem; font-weight: 750; }
.assignment-panel button { font-size: .77rem; }
.editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
.editor-actions #save-status { max-width: 195px; color: var(--muted); font-size: .74rem; line-height: 1.25; text-align: right; }
.editor-actions button { padding: 8px 10px; font-size: .78rem; white-space: nowrap; }
.editor-actions #save { background: transparent; border-color: #587267; }
.error-text { color: #ffaaaa !important; }

.image-panel { flex: 0 0 auto; max-height: 245px; overflow: auto; background: #17292b; border-bottom: 1px solid var(--line); }
.image-panel > summary { cursor: pointer; display: flex; align-items: center; gap: 9px; list-style: none; padding: 10px 21px; color: #bce8d2; font-size: .78rem; font-weight: 760; }
.image-panel > summary::-webkit-details-marker { display: none; }
.image-panel > summary::before { content: "▸"; color: var(--accent); }
.image-panel[open] > summary::before { content: "▾"; }
.image-panel #image-count { color: var(--muted); font-size: .73rem; font-weight: 500; }
.image-gallery { display: flex; gap: 11px; overflow-x: auto; padding: 0 21px 13px; }
.image-card { width: 198px; flex: 0 0 198px; padding: 7px; border: 1px solid #3d5851; border-radius: 9px; background: #223737; }
.image-card.is-used { border-color: var(--accent); }
.image-card .image-open { display: block; width: 100%; height: 100px; overflow: hidden; border: 0; border-radius: 6px; padding: 0; background: transparent; }
.image-card .image-open:hover { background: transparent; }
.image-card img { display: block; width: 100%; height: 100%; object-fit: cover; }
.image-card-info { display: flex; justify-content: space-between; gap: 5px; padding: 7px 1px; color: #c4d8cf; font-size: .71rem; }
.image-card-info .used { color: #84e5b3; }
.image-card input { display: block; width: 100%; padding: 7px; border: 1px solid #4c6b61; border-radius: 6px; background: #0d1c1e; color: #fff; font-size: .75rem; }
.image-card .insert-image { display: block; width: 100%; margin-top: 7px; padding: 7px 8px; font-size: .73rem; }
.image-dialog { max-width: min(96vw,1250px); max-height: 95vh; padding: 14px; border: 1px solid #789b8b; border-radius: 12px; background: #14201f; color: white; }
.image-dialog::backdrop { background: #000c; }
.image-dialog img { display: block; max-width: 100%; max-height: 85vh; object-fit: contain; }
.image-dialog button { position: absolute; right: 18px; top: 18px; padding: 4px 10px; border-radius: 100%; background: #14201fdd; }

.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.source-pane, .preview-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.source-pane { border-right: 1px solid var(--line); }
.pane-heading { flex: 0 0 42px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--line); background: #142326; color: #deefe4; font-size: .74rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.pane-heading span { color: #92b3a7; font-size: .68rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.source-pane textarea { flex: 1; min-height: 0; width: 100%; resize: none; border: 0; outline: none; padding: 19px; background: #0d181b; color: #e4eee8; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.65; tab-size: 2; }
.source-pane textarea[readonly] { color: #aebeb8; }
.preview-pane iframe { flex: 1; width: 100%; border: 0; background: #172326; }
.preview-error { padding: 9px 14px; background: #7d3b3b; color: white; font-size: .82rem; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%,440px); padding: 34px; border: 1px solid #3b5550; border-radius: 18px; background: #1c2b2d; box-shadow: 0 20px 70px #0006; }
.login-card h1 { font-size: 1.7rem; margin: 30px 0 5px; }
.login-card p { color: #b9ccc5; line-height: 1.5; }
.login-card form { display: grid; gap: 11px; margin-top: 28px; }
.login-card label { font-size: .84rem; font-weight: 700; }
.login-card input { padding: 13px; border: 1px solid #547369; border-radius: 9px; background: #0f1818; color: #fff; }
.login-card button { margin-top: 8px; padding: 13px; }
.error { padding: 10px; background: #733838; border-radius: 8px; color: #fff !important; }

@media (max-width: 1150px) {
  .workspace { grid-template-columns: 245px minmax(0,1fr); }
  .editor-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .editor-actions { width: 100%; }
}
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 60px; padding: 11px 13px; }
  .brand { font-size: .68rem; white-space: normal; }
  .top-actions { gap: 8px; }
  #progress { display: none; }
  .workspace { height: auto; display: block; }
  .sidebar { height: 238px; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .sidebar-head { padding-bottom: 0; }
  .sidebar h2 { font-size: 1rem; }
  .article-list { max-height: 110px; }
  .editor { height: calc(100vh - 300px); min-height: 640px; }
  .editor-head { padding: 12px 15px; }
  .editor-head h1 { font-size: 1rem; }
  .editor-actions { justify-content: flex-start; flex-wrap: wrap; }
  .editor-actions #save-status { text-align: left; max-width: none; margin-right: auto; }
  .panes { grid-template-columns: 1fr; grid-template-rows: minmax(230px,1fr) minmax(260px,1fr); }
  .source-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .pane-heading span { display: none; }
  .team-popover { right: -3px; }
  .assignment-panel { left: auto; right: 0; }
}