/* The Writer (relay/public/js/writer.js): its panel, its box, its menu and the
   marks it draws over the text. Loaded by the Relay and, through a symlink,
   by the Site Agent's side panel and the pages it writes in, so every colour
   names the Relay's token with the Relay's value beside it: a page that is not
   the Relay has none of the tokens. */

.writer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: var(--text-primary, #e6edf3);
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif);
  font-size: 13px;
}
.writer-off { display: none !important; }
/* Hidden means hidden, whatever display a class gives the element. */
.writer [hidden], .writer-box [hidden] { display: none !important; }
.writer-gap { flex: 1 1 auto; }

.writer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #30363d);
}
.writer-title { font-weight: 600; }
.writer-subject {
  padding: 2px 8px;
  border: 1px solid var(--border, #30363d);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary, #8b949e);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.writer-tabs {
  display: flex;
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  overflow: hidden;
}
.writer-tab {
  padding: 4px 10px;
  background: none;
  border: none;
  color: var(--text-secondary, #8b949e);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.writer-tab + .writer-tab { border-left: 1px solid var(--border, #30363d); }
.writer-tab.on { background: rgba(88, 166, 255, 0.14); color: var(--accent, #58a6ff); }

.writer-check {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
}
.writer-bar { display: flex; align-items: center; gap: 10px; }
.writer-btn, .writer-act, .writer-select {
  height: 30px;
  padding: 0 12px;
  background: none;
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  color: var(--text-primary, #e6edf3);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.writer-btn:hover, .writer-act:hover { border-color: var(--accent, #58a6ff); }
.writer-act { height: 26px; padding: 0 10px; font-size: 12px; }
.writer-act.primary {
  background: var(--go, #238636);
  border-color: var(--go-border, #2ea043);
  color: #ffffff;
}
.writer-act:disabled, .writer-btn:disabled, .writer-select:disabled { opacity: 0.5; cursor: default; }
.writer-select { background: var(--bg-primary, #0d1117); padding: 0 8px; }
.writer-link {
  background: none;
  border: none;
  color: var(--accent, #58a6ff);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.writer-meta { font-size: 12px; color: var(--text-secondary, #8b949e); }
.writer-note { font-size: 12px; color: var(--text-secondary, #8b949e); line-height: 1.5; }
.writer-note.warn { color: var(--status-busy, #d29922); }

.writer-list { display: flex; flex-direction: column; gap: 8px; }
.writer-row {
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  outline: none;
}
.writer-row:hover, .writer-row:focus-visible, .writer-row.lit {
  border-color: var(--accent, #58a6ff);
  background: rgba(88, 166, 255, 0.09);
}
.writer-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.writer-label {
  color: var(--accent, #58a6ff);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
/* A finding names its tell plainly and says how sure it is in words. */
.writer-name { color: var(--text-primary, #e6edf3); font-weight: 600; }
.writer-badge {
  padding: 1px 6px;
  border: 1px solid var(--border, #30363d);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary, #8b949e);
}
.writer-badge.likely { border-color: var(--status-busy, #d29922); color: var(--status-busy, #d29922); }
.writer-badge.very { border-color: var(--destructive, #f85149); color: var(--destructive, #f85149); }
.writer-quote { color: var(--text-secondary, #8b949e); }
.writer-row .writer-why { color: var(--text-primary, #e6edf3); font-size: 12px; }
.writer-fixline { color: var(--success, #3fb950); }
.writer-why { color: var(--text-secondary, #8b949e); font-size: 12px; }
/* The acts appear on the row being looked at, so the list reads as a list. */
.writer-acts { display: none; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.writer-row:hover .writer-acts, .writer-row:focus-within .writer-acts, .writer-row.lit .writer-acts { display: flex; }

.writer-section { font-size: 12px; font-weight: 600; margin-top: 6px; }
.writer-rule {
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.writer-eg.bad { color: var(--text-primary, #e6edf3); }
.writer-eg.good { color: var(--success, #3fb950); }

/* Style: the person's own rules and sentences, then the catalogue folded away. */
.writer-style-title { font-size: 15px; font-weight: 600; }
.writer-style-line { display: flex; align-items: flex-start; gap: 8px; }
.writer-gap-text { flex: 1 1 auto; }
.writer-x {
  background: none;
  border: none;
  color: var(--text-secondary, #8b949e);
  font: inherit;
  cursor: pointer;
  padding: 0 2px;
}
.writer-x:hover { color: var(--destructive, #f85149); }
.writer-add { display: flex; gap: 6px; margin-top: 4px; }
.writer-input {
  flex: 1 1 auto;
  height: 30px;
  box-sizing: border-box;
  background: var(--bg-primary, #0d1117);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  color: var(--text-primary, #e6edf3);
  font: inherit;
  font-size: 13px;
  padding: 0 10px;
}
.writer-input:focus { outline: none; border-color: var(--accent, #58a6ff); }
.writer-fold {
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 0 12px;
}
.writer-fold > summary { padding: 10px 0; cursor: pointer; font-size: 13px; }
.writer-fold[open] { padding-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.writer-check-line { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; cursor: pointer; }
.writer-check-line input { margin: 2px 0 0; }

/* The change against the words as they are. */
.writer-diff {
  background: var(--bg-primary, #0d1117);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.writer-diff del { color: var(--destructive, #f85149); text-decoration: line-through; }
.writer-diff ins { color: var(--success, #3fb950); text-decoration: none; background: rgba(63, 185, 80, 0.12); }

/* The redraft box: under the passage when it can be, in the panel otherwise. */
.writer-box {
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  background: var(--bg-secondary, #161b22);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text-primary, #e6edf3);
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: 13px;
  box-sizing: border-box;
}
.writer-box.floating {
  position: fixed;
  z-index: 2147483000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.writer-text {
  box-sizing: border-box;
  width: 100%;
  min-height: 64px;
  resize: vertical;
  background: var(--bg-primary, #0d1117);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  color: var(--text-primary, #e6edf3);
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  padding: 8px 10px;
}
.writer-status { font-size: 12px; color: var(--text-secondary, #8b949e); min-height: 1em; }
.writer-status.ok { color: var(--success, #3fb950); }
.writer-status.warn { color: var(--status-busy, #d29922); }
.writer-status.bad { color: var(--destructive, #f85149); }
.writer-box-row { display: flex; align-items: center; gap: 8px; }
.writer-box-row { flex-wrap: wrap; }
.writer-box-row .writer-act { height: 30px; font-size: 13px; }

/* The marks: boxes drawn over the words, never elements put into them. */
.writer-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147482000;
}
.writer-mark {
  position: fixed;
  box-sizing: border-box;
  border-bottom: 2px solid rgba(230, 170, 70, 0.75);
}
.writer-mark.soft { border-bottom: 1px dotted rgba(230, 170, 70, 0.55); }
.writer-mark.strong { border-bottom-color: rgba(224, 108, 108, 0.85); }
.writer-mark.lit { background: rgba(88, 166, 255, 0.18); }
/* Words the Writer put in, tinted while it is open (the Site Agent's Changes). */
.writer-mark.written { border-bottom: none; background: rgba(46, 160, 67, 0.15); }
.writer-mirror { position: fixed; visibility: hidden; pointer-events: none; }

/* The Writer's own menu, where the host lends none. */
.writer-menu {
  position: fixed;
  z-index: 2147483001;
  min-width: 240px;
  max-width: 340px;
  background: var(--bg-secondary, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 6px;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: 13px;
  color: var(--text-primary, #e6edf3);
}
.writer-menu-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: 5px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.writer-menu-item:hover { background: rgba(88, 166, 255, 0.12); }
.writer-menu-item.info { flex-direction: column; gap: 2px; cursor: default; font-size: 12px; font-weight: 600; }
.writer-menu-item.info:hover { background: none; }
.writer-menu-item.info .writer-menu-hint { font-weight: 400; }
.writer-menu-hint { color: var(--text-secondary, #8b949e); font-size: 12px; }
.writer-menu-sep { border-top: 1px solid var(--border, #30363d); margin: 4px 0; }
