/* Citation generator.

   This page runs the same shell as the paraphraser, summarizer, translator and the
   rest: aiwa-tools.css → aiwa-command.css → aiwa-app-shell.css → aiwa-paraphrase.css
   give it the command bar, the two panes, the action bar, the mobile tabs and the
   whole dark theme. Only what is specific to citations lives in this file. */

.citation-page [hidden] { display: none !important; }

/* ------------------------------------------------------------------ command bar */

.cg-name {
  display: block; width: 100%; max-width: 46vw; padding: 1px 6px; margin-left: -6px;
  border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--aiwa-ink); font: inherit; font-size: 16px; font-weight: 740;
  letter-spacing: -0.02em; text-overflow: ellipsis;
}
.cg-name:hover { border-color: var(--aiwa-line); }
.cg-name:focus { outline: 0; border-color: var(--aiwa-brand); background: #fff; box-shadow: 0 0 0 3px rgba(19, 122, 61, .14); }
.cg-name::placeholder { color: var(--aiwa-muted); font-weight: 600; }

/* The same pill the grammar checker uses for its word count, so the right end of
   the command bar reads the same on every tool. */
.cg-count {
  margin-left: auto; order: 99; flex: 0 0 auto;
  min-height: 40px; display: inline-flex; align-items: center; gap: 4px; padding: 0 12px;
  border-radius: 10px; background: var(--aiwa-bg);
  color: var(--aiwa-muted); font-size: 13px; font-weight: 650; white-space: nowrap;
}
.cg-count b { color: var(--aiwa-ink); font-weight: 760; }

/* The style picker is the paraphraser's mode dropdown with a search box on top,
   because 10,861 styles do not fit in a list you scroll. The paraphraser's mode
   button sits on the left of its bar and drops down-left; ours sits on the right,
   so it has to hang off the right edge or it pushes the page sideways. */
@media (min-width: 901px) { .cg-app .pp-mode-menu { left: auto; right: 0; width: 380px; } }

/* The style picker is the paraphraser's mode dropdown with a search box on top,
   because 10,861 styles do not fit in a list you scroll. */
.cg-style-search {
  display: flex; align-items: center; gap: 8px; height: 38px; margin-bottom: 6px;
  padding: 0 11px; border: 1px solid var(--aiwa-line); border-radius: 10px; background: var(--aiwa-bg);
}
.cg-style-search .aiwa-ui-icon { flex: 0 0 auto; width: 14px; height: 14px; opacity: .7; }
.cg-style-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent;
  color: var(--aiwa-ink); font: inherit; font-size: 13px; outline: 0;
}
.cg-style-search input::-webkit-search-cancel-button { cursor: pointer; }
.pp-mode-list .cg-style-none { margin: 0; padding: 16px 12px; color: var(--aiwa-muted); font-size: 13px; }
.cg-style-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--aiwa-muted); font-size: 11.5px; }
.cg-style-tag {
  flex: 0 0 auto; margin-left: auto; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--aiwa-line); color: var(--aiwa-muted); font-size: 10.5px; font-weight: 700;
}
.pp-mode-list button[aria-selected="true"] .cg-style-tag { border-color: var(--aiwa-brand); color: var(--aiwa-brand-dark); }

/* --------------------------------------------------------------- sources pane */

.cg-add {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 16px 18px 6px 26px;
}
.cg-add-field { position: relative; flex: 1 1 auto; min-width: 0; }
.cg-add-input {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--aiwa-line-strong);
  border-radius: 10px; background: #fff; color: var(--aiwa-ink); font: inherit; font-size: 14px;
}
.cg-add-input::placeholder { color: #8a958e; }
.cg-add-input:focus { outline: 0; border-color: var(--aiwa-brand); box-shadow: 0 0 0 3px rgba(19, 122, 61, .14); }
.cg-add .tool-btn { flex: 0 0 auto; min-height: 42px; }
.cg-add .tool-btn .aiwa-ui-icon { width: 15px; height: 15px; margin-right: 6px; filter: brightness(0) invert(1); }
.cg-add .tool-btn.is-busy { position: relative; color: transparent; pointer-events: none; }
.cg-add .tool-btn.is-busy .aiwa-ui-icon, .cg-add .tool-btn.is-busy span { visibility: hidden; }
.cg-add .tool-btn.is-busy::after {
  content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: cg-spin .7s linear infinite;
}
@keyframes cg-spin { to { transform: rotate(360deg); } }

.cg-hint { flex: 0 0 auto; min-height: 17px; padding: 0 18px 0 27px; color: var(--aiwa-muted); font-size: 11.5px; }

.cg-scroll { flex: 1 1 auto; min-height: 0; position: relative; overflow-y: auto; scrollbar-gutter: stable; padding: 4px 18px 18px 26px; }

.cg-sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cg-listfoot { padding-top: 10px; }
.cg-ghost-add {
  display: inline-flex; align-items: center; gap: 7px; width: 100%; justify-content: center;
  min-height: 40px; padding: 8px 14px; border: 1px dashed var(--aiwa-line-strong);
  border-radius: 10px; background: transparent; color: var(--aiwa-muted);
  font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
  transition: border-color 140ms var(--aiwa-ease), color 140ms var(--aiwa-ease), background-color 140ms var(--aiwa-ease);
}
.cg-ghost-add:hover { border-color: var(--aiwa-brand); background: var(--aiwa-brand-soft); color: var(--aiwa-brand-dark); }
.cg-ghost-add .aiwa-ui-icon { width: 13px; height: 13px; opacity: .8; }
.cg-src {
  padding: 11px 12px; border: 1px solid var(--aiwa-line); border-radius: 12px; background: #fff;
  transition: border-color 140ms var(--aiwa-ease), box-shadow 140ms var(--aiwa-ease);
}
.cg-src:hover { border-color: var(--aiwa-line-strong); }
.cg-src.is-new { border-color: var(--aiwa-brand); box-shadow: 0 0 0 3px rgba(19, 122, 61, .12); }
.cg-src-top { display: flex; align-items: flex-start; gap: 9px; }
.cg-src-ic {
  flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 9px; background: var(--aiwa-brand-soft);
}
.cg-src-ic .aiwa-ui-icon { width: 15px; height: 15px; filter: invert(35%) sepia(70%) saturate(680%) hue-rotate(97deg) brightness(91%); }
.cg-src-body { flex: 1 1 auto; min-width: 0; }
.cg-src-title { display: block; color: var(--aiwa-ink); font-size: 13.5px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.cg-src-meta { display: block; margin-top: 2px; color: var(--aiwa-muted); font-size: 11.5px; line-height: 1.45; overflow-wrap: anywhere; }
.cg-src-tools { flex: 0 0 auto; display: flex; align-items: center; gap: 3px; }
.cg-icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center; padding: 0;
  border: 1px solid transparent; border-radius: 7px; background: transparent; cursor: pointer;
}
.cg-icon-btn:hover { border-color: var(--aiwa-line); background: var(--aiwa-bg); }
.cg-icon-btn.is-danger:hover { border-color: #f0c1bd; background: #fef2f2; }
.cg-icon-btn .aiwa-ui-icon { width: 14px; height: 14px; opacity: .75; }

.cg-src-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 8px; }
.cg-flag {
  padding: 2px 8px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-size: 10.5px; font-weight: 750; cursor: pointer;
}
.cg-flag-fix { background: #fff7ed; border-color: #f0bd8c; color: #7c3a08; }
.cg-flag-missing { background: #fef2f2; border-color: #f0c1bd; color: var(--aiwa-danger); }
.cg-flag-src { background: var(--aiwa-bg); border-color: var(--aiwa-line); color: var(--aiwa-muted); cursor: default; font-weight: 650; }

.cg-fixes { display: grid; gap: 6px; margin-top: 8px; }
.cg-fix { padding: 8px 10px; border-left: 3px solid #d97706; border-radius: 0 8px 8px 0; background: var(--aiwa-bg); }
.cg-fix b { display: block; color: var(--aiwa-ink); font-size: 12px; }
.cg-fix span { display: block; margin-top: 2px; color: var(--aiwa-muted); font-size: 11.5px; line-height: 1.5; }
.cg-fix-was { color: var(--aiwa-text) !important; }
.cg-fix-note { border-left-color: var(--aiwa-focus); }
.cg-fix .pane-action { margin-top: 7px; min-height: 26px; padding: 3px 9px; font-size: 11px; }

/* lookup candidates */
.cg-candidates { display: grid; gap: 6px; margin-bottom: 10px; }
.cg-cand-head { margin: 0; color: var(--aiwa-muted); font-size: 11.5px; font-weight: 700; }
.cg-cand {
  display: block; width: 100%; padding: 9px 11px; text-align: left; cursor: pointer;
  border: 1px solid var(--aiwa-line); border-radius: 10px; background: var(--aiwa-bg);
  color: var(--aiwa-ink); font: inherit;
}
.cg-cand:hover { border-color: var(--aiwa-brand); background: var(--aiwa-brand-soft); }
.cg-cand b { display: block; font-size: 13px; font-weight: 700; line-height: 1.4; }
.cg-cand small { display: block; margin-top: 2px; color: var(--aiwa-muted); font-size: 11.5px; }
.cg-cand-manual { background: transparent; border-style: dashed; }
.cg-noresult { padding: 12px; border: 1px solid var(--aiwa-line); border-radius: 10px; background: var(--aiwa-bg); }
.cg-noresult b { display: block; font-size: 13px; }
.cg-noresult p { margin: 5px 0 10px; color: var(--aiwa-muted); font-size: 12.5px; line-height: 1.55; }

/* --------------------------------------------------------------- output pane */

.cg-output { padding: 20px 26px 40px; font-size: 15px; line-height: 1.7; }
.cg-output.empty { display: grid; place-content: center; justify-items: center; }
.cg-output .csl-bib-body { color: var(--aiwa-ink); }
.cg-entry + .cg-entry { margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--aiwa-line); }
.cg-entry.is-new .cg-bib { background: var(--aiwa-brand-soft); border-radius: 8px; box-shadow: 0 0 0 6px var(--aiwa-brand-soft); }
.cg-bib { overflow-wrap: anywhere; transition: background-color 400ms var(--aiwa-ease); }
.cg-bib .csl-entry { margin: 0; }

.cg-intext {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px;
  padding: 6px 10px; border: 1px solid var(--aiwa-line); border-radius: 9px; background: var(--aiwa-bg);
  font-size: 13px;
}
.citation-page[data-intext="off"] .cg-intext { display: none; }
.cg-intext-label {
  flex: 0 0 auto; padding: 1px 7px; border-radius: 999px; background: var(--aiwa-brand-soft);
  color: var(--aiwa-brand-dark); font-size: 10px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
}
.cg-intext-val { flex: 1 1 auto; min-width: 0; color: var(--aiwa-text); overflow-wrap: anywhere; }
.cg-intext .cg-icon-btn { background: #fff; }
.cg-locator-btn {
  flex: 0 0 auto; padding: 2px 9px; border: 1px solid var(--aiwa-line); border-radius: 999px;
  background: #fff; color: var(--aiwa-muted); font: inherit; font-size: 11px; font-weight: 700; cursor: pointer;
}
.cg-locator-btn:hover { border-color: var(--aiwa-brand); color: var(--aiwa-brand-dark); }
.cg-locator {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px;
  padding: 10px; border: 1px solid var(--aiwa-line); border-radius: 9px; background: var(--aiwa-bg);
}
.cg-locator select, .cg-locator input[type="text"] {
  height: 34px; padding: 0 9px; border: 1px solid var(--aiwa-line); border-radius: 8px;
  background: #fff; color: var(--aiwa-ink); font: inherit; font-size: 12.5px;
}
.cg-locator select { min-width: 110px; }
.cg-locator input[type="text"] { width: 130px; }
.cg-loc-sup { display: inline-flex; align-items: center; gap: 6px; color: var(--aiwa-text); font-size: 12px; }

.cg-dropped { margin-top: 16px; padding: 11px 12px; border: 1px dashed var(--aiwa-line-strong); border-radius: 10px; background: var(--aiwa-bg); }
.cg-dropped b { display: block; font-size: 13px; color: var(--aiwa-ink); }
.cg-dropped p { margin: 4px 0 0; color: var(--aiwa-muted); font-size: 12px; line-height: 1.55; }

/* The CPAL notice has to be visible whenever the tool is on screen, but it is a
   caption, not a second toolbar — hence the hairline rule rather than a filled bar. */
.cg-credit {
  flex: 0 0 auto; margin: 0; padding: 9px 26px 11px; border-top: 1px solid var(--aiwa-line);
  color: var(--aiwa-muted); font-size: 10.5px; line-height: 1.55;
}
.cg-credit a { color: var(--aiwa-muted); text-decoration: underline; text-underline-offset: 2px; }
.cg-credit a:hover { color: var(--aiwa-brand-dark); }

/* ------------------------------------------------------------------- add form */

.cg-modal { position: fixed; inset: 0; z-index: 120; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; }
.cg-modal-veil { position: absolute; inset: 0; background: rgba(9, 16, 12, .5); }
.cg-modal-box {
  position: relative; width: min(680px, 100%); max-height: 92vh; display: flex; flex-direction: column;
  border: 1px solid var(--aiwa-line); border-radius: 16px; background: #fff;
  box-shadow: 0 18px 48px rgba(10, 40, 24, .22); overflow: hidden;
}
.cg-modal-head { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; border-bottom: 1px solid var(--aiwa-line); background: #fbfcfb; }
.cg-modal-head h2 { flex: 1 1 auto; margin: 0; font-size: 15px; font-weight: 750; }
.cg-modal-body { flex: 1 1 auto; padding: 16px; overflow-y: auto; }
.cg-modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 58px; padding: 10px 16px; border-top: 1px solid var(--aiwa-line); background: #fbfcfb; }
body.cg-modal-open { overflow: hidden; }

.cg-field { margin-bottom: 13px; }
.cg-field > label { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; color: var(--aiwa-ink); font-size: 12.5px; font-weight: 700; }
.cg-req { padding: 1px 6px; border-radius: 999px; background: var(--aiwa-brand-soft); color: var(--aiwa-brand-dark); font-size: 9.5px; font-weight: 750; letter-spacing: .03em; text-transform: uppercase; }
.cg-input {
  width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--aiwa-line);
  border-radius: 9px; background: #fff; color: var(--aiwa-ink); font: inherit; font-size: 13.5px;
}
.cg-input:focus { outline: 0; border-color: var(--aiwa-brand); box-shadow: 0 0 0 3px rgba(19, 122, 61, .14); }
.cg-input-short { max-width: 240px; }
.cg-area { min-height: 70px; resize: vertical; }
.cg-hint-line { display: block; margin-top: 4px; color: var(--aiwa-muted); font-size: 11.5px; }
.cg-names { display: grid; gap: 6px; }
.cg-name-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cg-name-row .cg-input { flex: 1 1 130px; min-width: 0; }
.cg-name-toggle, .cg-name-del {
  flex: 0 0 auto; min-height: 38px; padding: 0 10px; border: 1px solid var(--aiwa-line);
  border-radius: 9px; background: var(--aiwa-bg); color: var(--aiwa-muted); font: inherit;
  font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.cg-name-del { width: 38px; padding: 0; font-size: 16px; line-height: 1; }
.cg-name-toggle:hover, .cg-name-del:hover { border-color: var(--aiwa-brand); color: var(--aiwa-brand-dark); }
.cg-name-add {
  margin-top: 6px; padding: 4px 11px; border: 1px dashed var(--aiwa-line-strong); border-radius: 999px;
  background: transparent; color: var(--aiwa-muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.cg-name-add:hover { border-color: var(--aiwa-brand); color: var(--aiwa-brand-dark); }
.cg-form-type { margin-bottom: 16px; }
.cg-form-type label { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 700; }

/* the notice doubles as the undo prompt after a delete */
.notice .cg-undo {
  margin-left: 10px; padding: 3px 11px; border: 1px solid currentColor; border-radius: 999px;
  background: transparent; color: inherit; font: inherit; font-size: 12px; font-weight: 750; cursor: pointer;
}

/* --------------------------------------------------------------------- mobile */

/* This page has two export buttons where the paraphraser has five, so the labels
   can stay visible far longer than the shared 1560px cut-off allows. */
@media (min-width: 1101px) {
  .citation-page .pp-result-actions .pane-action span { display: inline; }
  .citation-page .pp-result-actions .pane-action { padding: 5px 10px; }
  /* The shared bar drops this label at 1560px because the paraphraser has five
     controls fighting for the space. This bar has two. */
  .citation-page .pp-switch-text { display: inline; }
}

@media (max-width: 900px) {
  /* The shared bar hides the result actions until there is a result and then lays
     them out in five columns. Here they are always useful and there are only two. */
  .citation-page .pp-action-bar { grid-template-columns: auto minmax(0, 1fr); }
  .citation-page .pp-bar-left { display: none; }
  .citation-page .pp-result-actions { display: flex; gap: 5px; grid-column: auto; grid-row: auto; }
  .citation-page .pp-result-actions .pane-action { height: 44px; padding: 0 12px; }
  .citation-page .pp-run-wrap { justify-content: flex-end; }
  .cg-copy-long { display: none; }
  .cg-add { padding: 10px 12px 4px 16px; }
  .cg-hint { padding: 0 12px 0 16px; }
  .cg-scroll { padding: 4px 12px 16px 16px; }
  .cg-output { padding: 16px; font-size: 14.5px; }
  .cg-name { max-width: none; font-size: 15px; }
  .cg-style-search { height: 40px; }
  .cg-modal { padding: 0; }
  .cg-modal-box { width: 100%; max-height: 100dvh; height: 100dvh; border: 0; border-radius: 0; }
}
@media (max-width: 560px) {
  .cg-add { flex-wrap: wrap; }
  .cg-add .tool-btn { flex: 1 1 auto; }
}

/* ----------------------------------------------------------------- dark theme */
/* The shell's own dark rules cover the panes, bars and menus. These are the
   surfaces this file introduces. */

html[data-theme="dark"] .cg-name:focus { background: var(--aiwa-card); }
html[data-theme="dark"] .cg-count { background: #1b241f; border-color: var(--aiwa-line); color: var(--aiwa-text); }
html[data-theme="dark"] .cg-add-input { background: var(--aiwa-card); border-color: var(--aiwa-line-strong); }
html[data-theme="dark"] .cg-add .tool-btn.primary { color: #08130c; }
html[data-theme="dark"] .cg-add .tool-btn.primary .aiwa-ui-icon { filter: brightness(0); }
html[data-theme="dark"] .cg-add .tool-btn.is-busy::after { border-color: rgba(8, 19, 12, .3); border-top-color: #08130c; }
html[data-theme="dark"] .cg-src { background: var(--aiwa-card); border-color: var(--aiwa-line); }
html[data-theme="dark"] .cg-src:hover { border-color: var(--aiwa-line-strong); }
html[data-theme="dark"] .cg-src-ic .aiwa-ui-icon { filter: invert(63%) sepia(38%) saturate(560%) hue-rotate(93deg) brightness(96%); }
html[data-theme="dark"] .cg-icon-btn .aiwa-ui-icon { filter: invert(.85); }
html[data-theme="dark"] .cg-icon-btn:hover { background: var(--aiwa-bg); }
html[data-theme="dark"] .cg-flag-fix { background: rgba(154, 77, 12, .2); border-color: rgba(240, 189, 140, .38); color: #f0b878; }
html[data-theme="dark"] .cg-flag-missing { background: rgba(180, 35, 24, .2); border-color: rgba(240, 193, 189, .35); color: #f3a09b; }
html[data-theme="dark"] .cg-fix { border-left-color: #f0b878; }
html[data-theme="dark"] .cg-cand { background: var(--aiwa-bg); border-color: var(--aiwa-line); color: var(--aiwa-ink); }
html[data-theme="dark"] .cg-noresult { background: var(--aiwa-bg); border-color: var(--aiwa-line); }
html[data-theme="dark"] .cg-style-search { background: var(--aiwa-bg); border-color: var(--aiwa-line); }
html[data-theme="dark"] .cg-intext { background: var(--aiwa-bg); border-color: var(--aiwa-line); }
html[data-theme="dark"] .cg-intext .cg-icon-btn, html[data-theme="dark"] .cg-locator-btn { background: var(--aiwa-card); }
html[data-theme="dark"] .cg-locator { background: var(--aiwa-bg); border-color: var(--aiwa-line); }
html[data-theme="dark"] .cg-locator select, html[data-theme="dark"] .cg-locator input[type="text"] { background: var(--aiwa-card); border-color: var(--aiwa-line-strong); color: var(--aiwa-ink); }
html[data-theme="dark"] .cg-dropped { background: var(--aiwa-bg); border-color: var(--aiwa-line-strong); }
html[data-theme="dark"] .cg-modal-veil { background: rgba(0, 0, 0, .68); }
html[data-theme="dark"] .cg-modal-box { background: var(--aiwa-card); border-color: var(--aiwa-line); }
html[data-theme="dark"] .cg-modal-head, html[data-theme="dark"] .cg-modal-foot { background: var(--aiwa-bg); border-color: var(--aiwa-line); }
html[data-theme="dark"] .cg-input { background: var(--aiwa-card); border-color: var(--aiwa-line-strong); color: var(--aiwa-ink); }
html[data-theme="dark"] .cg-name-toggle, html[data-theme="dark"] .cg-name-del { background: var(--aiwa-bg); border-color: var(--aiwa-line-strong); }

/* ---------------------------------------------------------------- explainer

   The SEO block below the tool runs on the shared wx-* system in aiwa-seo.css.
   Only two things are specific to this page. Both are prefixed .cite-explainer,
   because a bare .wx-sub rule here would reach into every other tool page. */

.cite-explainer .cite-note { max-width: 820px; margin: 18px auto 0; text-align: center; }
.cite-explainer .cite-note.is-loose { margin-top: 34px; }
.cite-explainer .cite-note a { color: var(--aiwa-brand-dark); text-decoration: underline; text-underline-offset: 2px; }
.cite-explainer .cite-note a:hover { color: var(--aiwa-ink); }
html[data-theme="dark"] .cite-explainer .cite-note a { color: var(--aiwa-brand); }
html[data-theme="dark"] .cite-explainer .cite-note a:hover { color: var(--aiwa-ink); }
