:root {
  --bg: #f4f1ea;
  --ink: #1c1916;
  --muted: #6b645c;
  --card: #fffdf8;
  --line: #e4ddd2;
  --accent: #1f4d3a;
  --alert: #8b2e2e;
  --ok: #1f4d3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  background: var(--accent);
  color: #fff;
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.top-nav a {
  color: #fff;
  text-decoration: none;
}

.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

h1 { font-size: 1.8rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }

.muted { color: var(--muted); }

.cards {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
}

.ok { color: var(--ok); font-weight: 700; }
.bad { color: var(--alert); font-weight: 700; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font: inherit;
}

.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
}

.flash { padding: 0.6rem 0.8rem; border-radius: 8px; }
.flash-alert { background: #f8e4e4; color: var(--alert); }
.flash-notice { background: #e5f0ea; color: var(--ok); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.6rem;
}

.login-card form { display: grid; gap: 0.7rem; }
.login-card input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.embed-body {
  --embed-bg: #eef2f4;
  --embed-card: #fff;
  --embed-text: #333;
  --embed-muted: #828b95;
  --embed-line: #dfe3e6;
  --embed-input: #c6cdd3;
  --embed-blue: #0075ff;
  --embed-blue-hover: #1b6edc;
  --embed-cyan: #2fc6f6;
  --embed-cyan-soft: #e5f9fe;
  --embed-radius: 12px;
  background: var(--embed-bg);
  color: var(--embed-text);
  overflow-x: hidden;
  overflow-y: auto;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
.embed-body .muted { color: var(--embed-muted); }
.embed-page {
  max-width: none;
  padding: 12px 14px 16px;
}
.embed-page h1 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.embed-page .flash {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.embed-page .flash-alert {
  background: #ffe8e8;
  color: #c21f24;
  border: 1px solid #ffc8c8;
}
.embed-page .flash-notice {
  background: var(--embed-cyan-soft);
  color: #0b6e8a;
  border: 1px solid #bcedfc;
}
.embed-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.embed-nav a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--embed-line);
  border-radius: 8px;
  background: #fff;
  color: #525c69;
  font-weight: 600;
  text-decoration: none;
}
.embed-nav a:hover {
  border-color: #a8b0b8;
  color: #333;
}
.embed-nav a[aria-current="page"] {
  background: var(--embed-blue);
  border-color: var(--embed-blue);
  color: #fff;
}
.embed-lede {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--embed-cyan-soft);
  border: 1px solid #bcedfc;
  border-left: 3px solid var(--embed-cyan);
  border-radius: 2px 10px 10px 2px;
  color: #525c69;
  line-height: 1.4;
}
.embed-page .dept-rows {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
  margin: 0 0 12px;
}
.embed-page .dept-rows .card,
.source-rail > .card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin: 0;
  padding: 14px 14px 16px;
  background: var(--embed-card);
  border: 1px solid var(--embed-line);
  border-radius: var(--embed-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.embed-page .dept-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 0 0 8px;
  border-bottom: 1px solid #f0f2f4;
}
.embed-page .dept-rows h2,
.source-rail h2,
.mark-log h2 {
  margin: 0;
  padding: 0 0 8px;
  border-bottom: 1px solid #f0f2f4;
  color: #333;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.embed-page .dept-head h2 {
  padding: 0;
  border-bottom: 0;
}
.embed-page .dept-new-form { display: contents; }
.embed-page .dept-rows .card.dept-new {
  border: 1.5px dashed #b7c0c8;
  box-shadow: none;
}
.embed-page .dept-delete { margin: 0; }
.embed-page .embed-ctl-name {
  flex-direction: column;
  align-items: stretch;
}
.embed-page .embed-ctl-element.is-text {
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}
.embed-page .embed-ctl-element.is-rop {
  width: auto;
  min-width: 168px;
  max-width: 100%;
  padding-right: 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}
.dept-user-link {
  margin-left: 6px;
  color: var(--embed-blue);
  font-size: 12px;
  font-weight: 600;
}
.embed-ctl {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
}
.embed-ctl-title {
  color: #525c69;
  font-size: 13px;
  font-weight: 400;
}
.embed-ctl-element {
  display: block;
  width: 92px;
  height: 38px;
  margin: 0;
  padding: 0 10px;
  background: #fff;
  border: 1px solid var(--embed-input);
  border-radius: 8px;
  color: #333;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 36px;
  text-align: center;
}
.embed-ctl-stack {
  flex-direction: column;
  align-items: stretch;
}
.embed-ctl-wide {
  width: 100%;
  height: auto;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
}
.embed-lines {
  min-height: 72px;
  resize: vertical;
  font-weight: 400;
}
.tag-list-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--embed-input);
  border-radius: 8px;
  cursor: text;
}
.tag-list-box:focus-within {
  border-color: var(--embed-blue);
  box-shadow: 0 0 0 3px rgba(0, 117, 255, 0.18);
}
.tag-list-chips {
  display: contents;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 2px;
  padding: 2px 2px 2px 8px;
  border-radius: 6px;
  background: #e8f3ff;
  color: #0d4f9c;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.tag-chip-text {
  overflow-wrap: anywhere;
}
.tag-chip-remove {
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #0d4f9c;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.tag-chip-remove:hover { background: rgba(0, 117, 255, 0.12); }
.tag-list-entry {
  flex: 1 0 140px;
  min-width: 140px;
  height: 28px;
  margin: 0;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: #333;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
}
.tag-list-entry:focus { outline: 0; }
.tag-list-entry::placeholder { color: var(--embed-muted); }
.embed-check {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--embed-blue);
}
.embed-ctl-element:hover { border-color: #a8b0b8; }
.embed-ctl-element:focus {
  outline: 0;
  border-color: var(--embed-blue);
  box-shadow: 0 0 0 3px rgba(0, 117, 255, 0.18);
}
.marketing-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: var(--embed-card);
  border: 1px solid var(--embed-line);
  border-radius: var(--embed-radius);
}
.marketing-bar .embed-ctl { flex: 1 1 auto; }
.source-rail {
  display: flex;
  gap: 12px;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: 520px;
  margin: 0 0 16px;
  padding: 2px 2px 12px;
}
.source-rail > .card {
  flex: 0 0 360px;
  max-height: 500px;
  overflow-x: hidden;
  overflow-y: auto;
}
.mark-log { margin-top: 4px; }
.mark-log h2 { margin-bottom: 8px; }
.mark-table-wrap {
  overflow-x: auto;
  background: var(--embed-card);
  border: 1px solid var(--embed-line);
  border-radius: var(--embed-radius);
}
.mark-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.mark-table th,
.mark-table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.mark-table th {
  color: #525c69;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--embed-line);
}
.mark-table td { border-top: 1px solid #f0f2f4; }
.mark-table a { color: var(--embed-blue); font-weight: 600; }
.mark-table time { color: var(--embed-muted); white-space: nowrap; }
.mark-table th:nth-child(n + 5),
.mark-table td:nth-child(n + 5) { white-space: nowrap; }
.mark-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 10px;
  font-size: 13px;
}
.mark-pager-range { color: #525c69; }
.mark-pager-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.mark-pager-jump label { color: #525c69; }
.mark-pager-jump input {
  width: 64px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--embed-line);
  border-radius: 8px;
  background: #fff;
  color: #333;
  font: inherit;
  font-size: 13px;
}
.mark-pager-jump input:focus {
  outline: 0;
  border-color: var(--embed-blue);
  box-shadow: 0 0 0 3px rgba(0, 117, 255, 0.18);
}
.mark-pager-btn {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--embed-line);
  border-radius: 8px;
  background: #fff;
  color: #525c69;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
a.mark-pager-btn:hover,
button.mark-pager-btn:hover {
  border-color: #a8b0b8;
  color: #333;
}
.mark-pager-btn.is-disabled {
  color: #a8b0b8;
  cursor: default;
}
.embed-actions { margin: 0 0 4px; }
.embed-page .btn {
  min-width: 140px;
  height: 38px;
  padding: 0 18px;
  background: var(--embed-blue);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 75, 170, 0.18);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}
.embed-page .btn:hover { background: var(--embed-blue-hover); }
.embed-page .dept-head .btn {
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.embed-page .btn.btn-quiet {
  background: transparent;
  color: #c21f24;
  border: 1px solid #f0b4b4;
  box-shadow: none;
}
.embed-page .btn.btn-quiet:hover { background: #fff5f5; }
.embed-page .btn:focus {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(0, 117, 255, 0.22);
}

.embed-logs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.embed-logs .share-log { margin-top: 0; }
.share-log {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
  padding: 14px 14px 8px;
  background: var(--embed-card);
  border: 1px solid var(--embed-line);
  border-radius: var(--embed-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  min-height: 0;
}
.share-log h2 {
  margin: 0 0 4px;
  color: #333;
  font-size: 14px;
  font-weight: 600;
}
.share-log ol {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.share-log li {
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid #f0f2f4;
  font-size: 13px;
  line-height: 1.35;
}
.share-log li:last-child { padding-bottom: 6px; }
.share-log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
}
.share-log time { color: var(--embed-muted); }
.share-log-who { color: var(--embed-blue); font-weight: 600; }
.share-log-what { margin: 2px 0 0; color: #333; overflow-wrap: anywhere; }
.share-log-what a { color: var(--embed-blue); font-weight: 600; }
.share-log > .muted {
  margin: 0 0 8px;
  padding: 8px 0 4px;
  border-top: 1px solid #f0f2f4;
}
.assign-filter {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0 0 10px;
  border-bottom: 1px solid #f0f2f4;
}
.assign-filter-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}
.assign-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  color: #525c69;
  font-size: 12px;
}
.assign-filter-date {
  width: 140px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--embed-input);
  border-radius: 8px;
  background: #fff;
  color: #333;
  font: inherit;
  font-size: 13px;
}
.assign-filter-date:focus {
  outline: 0;
  border-color: var(--embed-blue);
  box-shadow: 0 0 0 3px rgba(0, 117, 255, 0.18);
}
.assign-filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.assign-preset {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--embed-line);
  border-radius: 8px;
  background: #fff;
  color: #525c69;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.assign-preset:hover {
  border-color: #a8b0b8;
  color: #333;
}
.assign-preset.is-active {
  background: var(--embed-blue);
  border-color: var(--embed-blue);
  color: #fff;
}
.assign-preset.is-active:hover {
  background: var(--embed-blue-hover);
  border-color: var(--embed-blue-hover);
  color: #fff;
}
#assignments-panel[aria-busy="true"] {
  opacity: 0.65;
  pointer-events: none;
}
.assign-counts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  font-size: 13px;
}
.assign-counts-list li {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  font-size: 13px;
  line-height: 1.3;
}
.assign-counts-name { color: #525c69; }
.assign-counts-list strong { color: #333; font-weight: 700; }
.assign-counts-total {
  margin-left: auto;
  padding-left: 8px;
  border-left: 1px solid var(--embed-line);
}
.assign-truncated {
  margin: 0 0 6px;
  padding: 6px 0 2px;
  border-top: 1px solid #f0f2f4;
  font-size: 12px;
}

@media (max-width: 520px) {
  .embed-page .dept-rows { grid-template-columns: 1fr; }
  .embed-logs { grid-template-columns: 1fr; }
  .embed-page .btn { width: 100%; }
  .embed-page .dept-head .btn { width: auto; }
  .assign-counts-total {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
}

.wiki h2 { margin: 1.6rem 0 0.6rem; font-size: 1.2rem; }
.wiki h3 { margin: 1.1rem 0 0.4rem; font-size: 1.02rem; }
.wiki p, .wiki li { line-height: 1.45; }
.wiki ol, .wiki ul { margin: 0.4rem 0 0.9rem; padding-left: 1.2rem; }
.wiki-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin: 1rem 0 1.4rem;
}
.wiki-toc a { color: var(--accent); }
.wiki table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0 1rem;
  font-size: 0.95rem;
}
.wiki th, .wiki td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
.wiki th { background: var(--card); }
.wiki pre {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.4;
}

a.btn { text-decoration: none; }

.page:has(.wiki-shell) { max-width: 1100px; }

.wiki-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.wiki-nav .btn { margin-bottom: 0.8rem; }

.wiki-tree {
  list-style: none;
  margin: 0;
  padding-left: 0.9rem;
}

.wiki-tree a { color: var(--accent); }
.wiki-tree a.is-current { font-weight: 700; }

.wiki-form {
  display: grid;
  gap: 0.8rem;
}

.wiki-form label {
  display: grid;
  gap: 0.3rem;
}

.wiki-form label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dialog-list, .dialog-thread {
  display: grid;
  gap: 0.8rem;
  padding: 0;
  list-style: none;
}

.dialog-body {
  white-space: pre-wrap;
}

.dialog-tool .dialog-body {
  color: var(--muted);
  font-size: 0.92rem;
}

.dialog-meta {
  margin: 0 0 0.2rem;
}

.dialog-call {
  white-space: pre-wrap;
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
}

.wiki-form input[type="text"],
.wiki-form input[type="password"],
.wiki-form textarea,
.wiki-form select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: var(--card);
}

.wiki-missing { color: var(--alert); }

@media (max-width: 720px) {
  .wiki-shell { grid-template-columns: 1fr; }
}
