:root {
  color-scheme: light dark;
  --border: #d0d0d0;
  --accent: #2b5fb5;
}
body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  line-height: 1.5;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  /* Given a known, fixed height so main.application-page below can size
     itself against exactly "the rest of the viewport" via calc(100vh - ...)
     instead of guessing at a margin big enough to cover the header on every
     screen. */
  height: 3.5rem;
  box-sizing: border-box;
}
header .brand {
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.usage-meter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #888;
}
.usage-bucket {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.usage-bucket-label {
  font-weight: 600;
  color: inherit;
}
.usage-bar {
  width: 2.5rem;
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.25);
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  background: var(--accent);
}
.usage-warning {
  border-color: #b3821e;
  color: #b3821e;
}
.usage-warning .usage-bar-fill {
  background: #b3821e;
}
.usage-rejected {
  border-color: #b3261e;
  color: #b3261e;
}
.usage-rejected .usage-bar-fill {
  background: #b3261e;
}
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}
.error {
  color: #b3261e;
}
.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 480px;
}
.stacked-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.button, button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-size: 0.95rem;
}
.applications-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
.applications-table th, .applications-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}
/* Grid's default auto-flow is row-major -- fills left-to-right across the
   first row before wrapping to the second, i.e. normal reading order. Fixed
   to 5 columns deliberately: the dashboard always renders exactly 10 cards
   (Total, This week, 8 statuses), so 5 columns is an even, intentional 2x5
   split, not an approximation -- revisit this number if that count changes. */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.stat-card.stat-total {
  border-color: var(--accent);
}
.stat-card.stat-zero {
  opacity: 0.5;
}
.stat-count {
  font-size: 1.3rem;
  font-weight: 700;
}
.stat-card.stat-total .stat-count {
  color: var(--accent);
}
.stat-label {
  font-size: 0.75rem;
  color: #888;
  text-transform: capitalize;
  text-align: center;
}
.stat-substat {
  font-size: 0.7rem;
  color: #888;
  white-space: nowrap;
}

/* One color per stage, filling the whole card -- but only when that stage
   actually has something in it (:not(.stat-zero)) and only for stages that
   mean "in the pipeline"; withdrawn/rejected are terminal/inactive outcomes
   and deliberately stay plain regardless of count. --stage-text is picked
   per color (not a single fixed white/black) so every stage clears WCAG AA
   (>=4.5:1) for the small label text, not just the bold count -- some of
   these colors (submitted's green, the amber offer) read better with dark
   text than white despite being "colors", so this can't be one rule for all. */
/* Not scoped to .stat-card -- the status-badge component below (used on the
   application page) reuses the same --stage-color/--stage-text variables. */
[data-status="researching"] { --stage-color: #2563eb; --stage-text: #ffffff; }
[data-status="drafting"] { --stage-color: #9333ea; --stage-text: #ffffff; }
[data-status="in_review"] { --stage-color: #ea580c; --stage-text: #1a1200; }
[data-status="submitted"] { --stage-color: #22c55e; --stage-text: #052e12; }
[data-status="interview"] { --stage-color: #16a34a; --stage-text: #04150a; }
[data-status="offer"] { --stage-color: #ca8a04; --stage-text: #1a1200; }
.stat-card[data-status="researching"]:not(.stat-zero),
.stat-card[data-status="drafting"]:not(.stat-zero),
.stat-card[data-status="in_review"]:not(.stat-zero),
.stat-card[data-status="submitted"]:not(.stat-zero),
.stat-card[data-status="interview"]:not(.stat-zero),
.stat-card[data-status="offer"]:not(.stat-zero) {
  background: var(--stage-color);
  border-color: var(--stage-color);
}
.stat-card[data-status="researching"]:not(.stat-zero) .stat-count,
.stat-card[data-status="researching"]:not(.stat-zero) .stat-label,
.stat-card[data-status="researching"]:not(.stat-zero) .stat-substat,
.stat-card[data-status="drafting"]:not(.stat-zero) .stat-count,
.stat-card[data-status="drafting"]:not(.stat-zero) .stat-label,
.stat-card[data-status="drafting"]:not(.stat-zero) .stat-substat,
.stat-card[data-status="in_review"]:not(.stat-zero) .stat-count,
.stat-card[data-status="in_review"]:not(.stat-zero) .stat-label,
.stat-card[data-status="in_review"]:not(.stat-zero) .stat-substat,
.stat-card[data-status="submitted"]:not(.stat-zero) .stat-count,
.stat-card[data-status="submitted"]:not(.stat-zero) .stat-label,
.stat-card[data-status="submitted"]:not(.stat-zero) .stat-substat,
.stat-card[data-status="interview"]:not(.stat-zero) .stat-count,
.stat-card[data-status="interview"]:not(.stat-zero) .stat-label,
.stat-card[data-status="interview"]:not(.stat-zero) .stat-substat,
.stat-card[data-status="offer"]:not(.stat-zero) .stat-count,
.stat-card[data-status="offer"]:not(.stat-zero) .stat-label,
.stat-card[data-status="offer"]:not(.stat-zero) .stat-substat {
  color: var(--stage-text);
}
/* Same color language as the dashboard's stat cards, as a pill next to the
   application title -- withdrawn/rejected fall back to a plain neutral pill
   (no --stage-color defined for them, same "terminal outcome" exception as
   the dashboard) via the var() fallback values below rather than always
   being colored. */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--stage-color, var(--border));
  background: var(--stage-color, transparent);
  color: var(--stage-text, inherit);
}
/* Deliberately not one of the stage colors above (a pink/magenta none of
   them use) -- this is a link to an external site, not a pipeline stage, and
   shouldn't be mistaken for one at a glance. */
.portal-badge {
  border-color: #db2777;
  background: #db2777;
  color: #ffffff;
  text-decoration: none;
}
.portal-badge:hover {
  background: #be185d;
  border-color: #be185d;
}
/* Resume-vs-posting keyword match coverage: one slim fill-bar row per
   category (hard/soft skills), same visual language as the header's
   .usage-bar meter -- deliberately not another .status-badge pill, since two
   stacked pills full of a colored fill would be visually heavier than this
   is meant to be. */
.keyword-meter {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.4rem 0 0.9rem;
  max-width: 320px;
}
.keyword-meter-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 3rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #888;
}
.keyword-meter-label {
  white-space: nowrap;
}
.keyword-meter-bar {
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.25);
  overflow: hidden;
}
.keyword-meter-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--meter-color, var(--accent));
}
.keyword-meter-count {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
/* Colors distinct from the pipeline-stage palette above, so this doesn't
   read as another status -- same red/amber/green coverage semantics as
   before, just driving a fill bar's width now instead of a badge's color. */
.keyword-meter-row[data-tier="low"] { --meter-color: #dc2626; }
.keyword-meter-row[data-tier="mid"] { --meter-color: #ca8a04; }
.keyword-meter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: #888;
}
.keyword-meter-refresh-form {
  margin: 0;
}
/* A quiet text-link style, not the primary .button/button look -- this is a
   secondary, infrequent action tucked under a small meter, not a page-level
   call to action. */
.keyword-meter-refresh {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 0.72rem;
  cursor: pointer;
  text-decoration: underline;
}
.keyword-meter-refresh:hover {
  opacity: 0.8;
}
.keyword-meter-row[data-tier="high"] { --meter-color: #22c55e; }
.dashboard-collapsed {
  margin-top: 2rem;
}
.dashboard-collapsed summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.5rem 0;
}
.dashboard-collapsed[open] summary {
  margin-bottom: 0.5rem;
}
.file-list {
  list-style: none;
  padding: 0;
}
.file-list li {
  padding: 0.25rem 0;
}
.note {
  color: #666;
  font-style: italic;
}
/* The application page needs room for a wide chat pane alongside the file
   list, same reasoning as the edit-docx page's own width override below.
   It's also height-bounded to exactly "the rest of the viewport below the
   header" (box-sizing: border-box means main's own 1.5rem padding is
   included in that calc, not added on top of it) with overflow hidden, so
   the page itself never scrolls -- only .application-main and .chat-log
   (below) scroll internally. Without this, the chat's input/Send button
   could end up below the viewport fold, forcing a whole-page scroll just to
   reach it. */
main.application-page {
  max-width: 1400px;
  height: calc(100vh - 3.5rem);
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.application-layout {
  display: flex;
  gap: 1.5rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}
.application-main {
  flex: 0 0 26rem;
  min-width: 0;
  overflow-y: auto;
}
.application-chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* Wraps the "Chat" heading + #chat-panel so the pair can be shown/hidden as
   a unit (via the hidden attribute) when #file-pane takes over the same
   spot -- #chat-panel itself is never removed from the DOM, see file-pane.js. */
#chat-panel-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
/* The ID selector above beats the browser's default `[hidden] { display:
   none }` UA rule (an ID beats a plain attribute selector on specificity),
   so #chat-panel-wrap stayed visible even after file-pane.js set its hidden
   attribute. This selector's own specificity (ID + attribute) wins the tie
   back. */
#chat-panel-wrap[hidden] {
  display: none;
}
.chat-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex: 1;
  min-height: 0;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}
.chat-message {
  margin: 0.4rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  max-width: 85%;
}
.chat-message p {
  margin: 0.2rem 0;
}
.chat-message ul, .chat-message ol {
  margin: 0.3rem 0;
  padding-left: 1.4rem;
}
.chat-message pre {
  background: rgba(127, 127, 127, 0.15);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.85rem;
}
.chat-message code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.chat-message :not(pre) > code {
  background: rgba(127, 127, 127, 0.15);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.chat-message blockquote {
  margin: 0.3rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  color: #888;
}
.chat-message a {
  color: inherit;
}
.chat-message > *:first-child {
  margin-top: 0;
}
.chat-message > *:last-child {
  margin-bottom: 0;
}
.chat-user {
  background: var(--accent);
  color: white;
  margin-left: auto;
}
.chat-assistant {
  background: rgba(127, 127, 127, 0.15);
}
.chat-tool {
  background: none;
  color: #888;
  font-size: 0.85rem;
  font-style: italic;
  max-width: 100%;
}
.chat-question {
  background: rgba(43, 95, 181, 0.12);
  border: 1px solid var(--accent);
  max-width: 100%;
}
.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.chat-option {
  padding: 0.3rem 0.7rem;
  font-size: 0.9rem;
}
.chat-error {
  background: rgba(179, 38, 30, 0.12);
  color: #b3261e;
  max-width: 100%;
}
.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.chat-status {
  margin: 0;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  color: #888;
}
.edit-textarea {
  width: 100%;
  min-height: 24rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-sizing: border-box;
  resize: vertical;
}
.superdoc-toolbar {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  min-height: 2.5rem;
  overflow: hidden;
}
.superdoc-container .super-editor {
  max-width: 100% !important;
  width: 100% !important;
}
.superdoc-container .editor-element {
  width: 100% !important;
  min-width: unset !important;
  transform: none !important;
}
/* The file pane replaces the chat panel in place (see application_detail.html
   / file-pane.js) -- same box/flex shape as .chat-panel so swapping between
   them doesn't shift the surrounding layout. */
.file-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.file-pane[hidden] {
  display: none;
}
.file-pane-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
}
.file-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.file-pane-title {
  margin: 0;
  font-size: 1rem;
  word-break: break-all;
}
.file-pane-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.3rem;
  color: inherit;
}
.file-pane-status {
  margin: 0 0 0.4rem;
  min-height: 1em;
  font-size: 0.8rem;
  color: #888;
}
.file-pane-actions {
  margin-top: 0.5rem;
}
/* Both the textarea and the SuperDoc mount need to fill whatever's left of
   the pane's height rather than the fixed sizes those elements use when
   bounded by a whole page (.edit-textarea's min-height, .superdoc-container's
   old calc(100vh - ...)) -- the pane itself is already height-bounded by
   .application-chat/.chat-panel's flex layout. */
.file-pane-textarea {
  flex: 1;
  min-height: 0;
  resize: none;
}
.file-pane-body .superdoc-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0 0 4px 4px;
}
