/* The palette and furniture are books-portal's, so the two staff pages read as one suite. */
:root {
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f9fafb;
  --card: #ffffff;
  --accent: #1c4e80;
  --orange: #c4622d;
  --danger: #b42318;
  --warn: #b54708;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1 { font-size: 18px; margin: 0; }
h1 a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 3;
}
.who { display: flex; align-items: center; gap: 12px; }
.link {
  border: 0; background: none; color: var(--accent);
  font: inherit; cursor: pointer; padding: 0;
}

.notice {
  margin: 0; padding: 10px 20px; background: #fef3f2; color: var(--danger);
  border-bottom: 1px solid #fecdca; font-size: 14px;
}

main { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.toolbar input {
  flex: 1 1 260px; min-width: 0;
  padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); font: inherit;
}

table.documents {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.documents th, table.documents td {
  text-align: left; padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top;
}
table.documents thead th {
  border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); font-weight: 500; background: var(--bg);
}
td.title a { color: inherit; font-weight: 500; text-decoration: none; }
td.title a:hover { text-decoration: underline; }
td.course { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
td .when { display: block; color: var(--muted); font-size: 12.5px; }

.tag {
  display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; margin-top: 4px;
}
.tag.warn { border-color: #fedf89; color: var(--warn); background: #fffaeb; }

@media (max-width: 640px) {
  table.documents thead { display: none; }
  table.documents tr { display: block; border-top: 1px solid var(--line); padding: 8px 0; }
  table.documents td { display: block; border: 0; padding: 2px 14px; }
}

/* The editor: the workbook's pages down the middle, the edit card beside them. */
#editor-view { min-height: calc(100vh - 57px); display: flex; flex-direction: column; }
#editor-view[hidden] { display: none; }
.editor-head {
  display: flex; align-items: baseline; gap: 14px; padding: 12px 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 57px; z-index: 2;
}
.editor-head h2 { font-size: 17px; margin: 0; }
.editor-head .back { color: var(--accent); text-decoration: none; }
.editor-body { display: flex; gap: 20px; padding: 20px; align-items: flex-start; }
.pages { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; gap: 18px; min-width: 0; }
.page {
  position: relative; width: min(100%, 820px); background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1); cursor: text;
}
.page canvas { display: block; width: 100%; height: 100%; }
.page .overlay { position: absolute; inset: 0; pointer-events: none; }
.page .selected {
  position: absolute; border: 2px solid var(--accent); border-radius: 6px;
  background: rgba(28, 78, 128, .06);
}

.editor-head .status { margin-left: auto; color: var(--muted); font-size: 13.5px; }
.editor-head .status[data-tone="bad"] { color: var(--danger); }
.unbuildable .pages { opacity: .6; }

.conflict {
  display: flex; align-items: center; gap: 14px; padding: 10px 20px;
  background: #fffaeb; border-bottom: 1px solid #fedf89; color: var(--warn); font-size: 14px;
}
.conflict[hidden] { display: none; }

button.primary {
  padding: 8px 15px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font: inherit; cursor: pointer;
}
button.secondary {
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); font: inherit; cursor: pointer;
}
button.primary:disabled, button.secondary:disabled { opacity: .5; cursor: default; }

/* The edit card */
.card {
  flex: 0 0 360px; position: sticky; top: 126px; max-height: calc(100vh - 146px); overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.card[hidden] { display: none; }
.card h3 { font-size: 15px; margin: 0; }
.card .field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 4px; }
.card .rich .ProseMirror {
  min-height: 2.4em; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  outline: none; white-space: pre-wrap; font-size: 15px; line-height: 1.5;
}
.card .rich .ProseMirror:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28, 78, 128, .12); }
.card .rich p { margin: 0; }
.card .rich p + p { margin-top: .6em; }
.card .rich ol { margin: 0; padding-left: 1.4em; }

.tools { display: flex; flex-wrap: wrap; gap: 4px; }
.tool {
  min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer;
}
.tool.bold { font-weight: 700; }
.tool.italic { font-style: italic; }
.tool.underline { text-decoration: underline; }
.tool.on { background: #eef4fb; border-color: #b9cfe6; color: var(--accent); }

.chip { display: inline-block; vertical-align: middle; }
.chip.math { padding: 0 3px; border-radius: 5px; cursor: pointer; }
.chip.math:hover { background: #eef4fb; }
.chip.math math-field { display: inline-block; border: 0; padding: 0; font-size: 15px; background: transparent; pointer-events: none; }
.chip.blank { height: 1em; border-bottom: 1.5px solid var(--ink); margin: 0 2px; }
.chip.fill { color: var(--muted); padding: 0 4px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { width: 32px; height: 30px; border: 0; background: var(--bg); font: inherit; cursor: pointer; }
.stepper .value { min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; }

.card .thumb { display: block; max-width: 100%; max-height: 160px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 6px; }

/* The formula popover */
.maths-pop {
  position: absolute; z-index: 10; width: 360px; padding: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 24px -6px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .1);
  display: flex; flex-direction: column; gap: 10px;
}
.maths-pop math-field { width: 100%; font-size: 20px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.maths-pop .problem { margin: 0; color: var(--danger); font-size: 13.5px; }
.maths-pop .actions { display: flex; justify-content: flex-end; gap: 8px; }

/* The publish sheet */
.scrim {
  position: fixed; inset: 0; z-index: 20; background: rgba(16, 24, 40, .35);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.sheet {
  width: min(440px, 100%); background: var(--card); border-radius: 14px; padding: 22px;
  box-shadow: 0 24px 48px -12px rgba(16, 24, 40, .25); display: flex; flex-direction: column; gap: 10px;
}
.sheet h3 { margin: 0; font-size: 17px; }
.sheet p { margin: 0; }
.sheet .error { color: var(--danger); }
.sheet .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.sheet .progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; position: relative; }
.sheet .progress::after {
  content: ""; position: absolute; inset: 0 60% 0 0; background: var(--accent); border-radius: 2px;
  animation: progress 1.1s ease-in-out infinite;
}
@keyframes progress { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.editor-head .primary { margin-left: 12px; }
