@import url('/tokens.css');
:root{font-family:var(--font)!important}body{background:var(--bg);-webkit-font-smoothing:antialiased;font-feature-settings:'tnum' 0}
:root{font-family:var(--font);color:var(--text);background:var(--surface-2);font-size:15px}*{box-sizing:border-box}body{margin:0;display:flex;min-height:100vh}aside{width:238px;padding:40px 24px;background:var(--surface-3);border-right:1px solid var(--border);display:flex;flex-direction:column;position:fixed;inset:0 auto 0 0}.brand{text-decoration:none;color:var(--accent);font-family:Georgia,serif;font-size:var(--fs-2xl);letter-spacing:-1px}.brand span{display:block;font:12px var(--font);letter-spacing:0;margin-top:12px;color:var(--text-2)}nav{margin-top:54px}nav a{display:block;background:var(--surface-3);padding:14px 12px;border-radius:7px;color:var(--accent);text-decoration:none;font-weight:600}.local{margin-top:auto;font-size:var(--fs-xs);color:var(--text-2)}.local p{color:var(--text-2);line-height:1.8}main{margin-left:238px;padding:45px 42px 20px;width:calc(100% - 238px)}header{display:flex;align-items:center;justify-content:space-between;gap:24px}.eyebrow{font-size:var(--fs-xs);letter-spacing:2px;color:var(--text-2);font-weight:600}h1{font-size:var(--fs-2xl);font-weight:700;letter-spacing:-0.02em;margin:14px 0}h2{font-size:var(--fs-xl);line-height:1.5}.muted{color:var(--text-2);line-height:1.7;font-size:var(--fs-sm)}button{background:var(--accent);color:white;border:1px solid transparent;border-radius:6px;padding:11px 18px;font:inherit;cursor:pointer}button:hover{filter:brightness(.94)}button:disabled{opacity:.5;cursor:wait}.secondary{background:white;color:var(--text-2);border-color:var(--border-strong)}input,select,textarea{font:inherit;border:1px solid var(--border);border-radius:5px;padding:11px;background:var(--surface);color:var(--text);width:100%}input:focus,textarea:focus,select:focus,button:focus-visible{outline:2px solid var(--text-3);outline-offset:2px}.toolbar{display:flex;gap:12px;align-items:center;margin-top:30px;border-top:1px solid var(--border);padding-top:24px}.toolbar input{flex:1}.toolbar select{width:155px}#count{white-space:nowrap;color:var(--text-2);font-size:var(--fs-xs)}#message{min-height:20px;font-size:var(--fs-sm);color:var(--warning)}.workspace{display:grid;grid-template-columns:minmax(240px, .85fr) minmax(320px,1.4fr);gap:22px;min-height:480px}#items{display:flex;flex-direction:column;gap:10px;max-height:76vh;overflow:auto}.paper{display:block;text-align:left;background:white;color:var(--text);padding:20px;border:1px solid var(--border);border-radius:8px;width:100%}.paper.selected{border-color:var(--text-2);background:var(--surface-3)}.paper h3{margin:10px 0;font-size:var(--fs-lg);line-height:1.6;overflow-wrap:anywhere}.paper p{margin:4px 0;color:var(--text-2);font-size:var(--fs-xs);line-height:1.6}.badge{color:var(--text-2);font-size:var(--fs-xs);letter-spacing:.5px}#detail{background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:28px;overflow-wrap:anywhere}.welcome{text-align:center;margin:95px auto;color:var(--text-2)}.welcome p{font-size:var(--fs-sm);line-height:1.9}.book{font-size:45px;color:var(--text-3)}.detail-meta{font-size:var(--fs-sm);color:var(--text-2);line-height:1.8}.detail-fields{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:25px 0 14px}label{display:block;font-size:var(--fs-xs);color:var(--text-2);margin:14px 0}label input,label select,label textarea{display:block;margin-top:7px}textarea{resize:vertical;min-height:150px;line-height:1.8}.actions{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}.pdf-box{border-top:1px solid var(--border);margin-top:25px;padding-top:14px}.pdf-box a{color:var(--accent)}iframe{width:100%;height:560px;border:1px solid var(--border);margin-top:15px}.empty{padding:25px;line-height:1.8;color:var(--text-2);font-size:var(--fs-md)}footer{display:flex;justify-content:space-between;border-top:1px solid var(--border);margin-top:30px;padding-top:18px;font-size:var(--fs-xs);color:var(--text-3)}dialog{border:1px solid var(--border-strong);border-radius:12px;padding:28px;width:min(570px,94vw);color:var(--text)}dialog::backdrop{background:#20312566}.fields{display:grid;grid-template-columns:120px 1fr;gap:14px}#form-error{color:var(--danger);font-size:var(--fs-sm)}.error{color:var(--danger)}@media(max-width:1050px){aside{width:190px;padding:28px 18px}main{margin-left:190px;width:calc(100% - 190px);padding:28px 22px}.workspace{grid-template-columns:1fr}#items{max-height:310px}.welcome{margin:50px auto}}@media(max-width:620px){body{display:block}aside{position:static;width:100%;padding:18px;display:block}.brand{font-size:var(--fs-2xl)}.brand span{display:none}nav{margin-top:18px}.local{margin-top:16px}.local p{display:none}main{margin:0;width:100%;padding:22px 16px}h1{font-size:var(--fs-2xl)}header{align-items:start}header button{font-size:var(--fs-xs);white-space:nowrap;padding:11px}.toolbar{flex-wrap:wrap}.toolbar input{flex-basis:100%}#detail{padding:20px}.detail-fields{grid-template-columns:1fr}footer span{display:none}}
nav a{margin-bottom:8px}nav a:not([aria-current]){background:transparent}.conflicts{background:var(--warning-soft);border:1px solid var(--warning-border);border-radius:10px;padding:14px 18px;margin:10px 0 18px}.conflicts h2{font-size:var(--fs-lg);margin:0 0 4px}.conflict{border-top:1px solid var(--warning-border);padding:10px 0}.conflict p{margin:4px 0;font-size:var(--fs-sm);overflow-wrap:anywhere}.conflict-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px}
.analyses{margin-top:22px;border-top:1px solid var(--border);padding-top:6px}.analyses h3{font-size:var(--fs-lg)}.analyses details{margin:8px 0}.analyses summary{cursor:pointer;font-weight:600;font-size:var(--fs-sm);color:var(--text-2)}.analysis-body{font-size:var(--fs-sm);line-height:1.65;overflow-wrap:anywhere}.analysis-body h4{margin:14px 0 4px;font-size:var(--fs-sm)}.analysis-warning{background:var(--warning-soft);border:1px solid var(--warning-border);border-radius:6px;padding:7px 10px}.analysis-values{width:100%;border-collapse:collapse;font-size:var(--fs-xs)}.analysis-values th,.analysis-values td{border-bottom:1px solid var(--border);padding:5px 6px;text-align:left;vertical-align:top}.analysis-values th{color:var(--text-2);font-weight:600}
.toolbar select{flex:0 0 auto}#sort{width:110px}#direction{width:105px}.view-switch{display:inline-flex;border:1px solid var(--border-strong);border-radius:6px;overflow:hidden;flex:none}.view-switch button{background:transparent;color:var(--accent);border:0;border-radius:0;padding:9px 13px;font-size:var(--fs-sm)}.view-switch button[aria-pressed=true]{background:var(--accent);color:var(--surface)}#count{white-space:nowrap}
#items.list{gap:0;background:var(--surface);border:1px solid var(--border);border-radius:8px}.paper-row{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px;row-gap:3px;width:100%;text-align:left;background:transparent;color:var(--text);border:0;border-bottom:1px solid var(--border);border-radius:0;padding:11px 14px}.paper-row:last-child{border-bottom:0}.paper-row:hover{background:var(--surface-2);filter:none}.paper-row.selected{background:var(--surface-3)}.row-title{font-size:var(--fs-md);font-weight:600;line-height:1.4;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.row-meta{grid-column:1;font-size:var(--fs-xs);color:var(--text-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.row-status{grid-column:2;grid-row:1;font-size:var(--fs-xs);color:var(--text-2);white-space:nowrap}
.paper .authors{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}#items.card .paper{flex:none}
.open-pdf{display:inline-block;background:var(--accent);color:var(--surface);border-radius:6px;padding:10px 18px;text-decoration:none;font-size:var(--fs-md);margin-bottom:6px}.open-pdf:hover{filter:brightness(.94)}

#settings [hidden], #settings[hidden] { display: none; }
.research-fields { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.research-fields h3 { margin-top: 0; }
.research-fields-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.research-fields-list:empty, #research-fields-status:empty { display: none; }
.research-field-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 5px 8px; }
.research-field-chip span { overflow-wrap: anywhere; }
.research-field-chip button { flex: none; padding: 4px 7px; }
#research-field-form { max-width: 420px; margin-top: 12px; }

button.danger { background: var(--danger); color: white; }

#organization { margin-block: 16px; }
#organization summary { cursor: pointer; font-weight: 600; }
#organization input, #organization select { max-width: 100%; }
#organization ul { padding-inline-start: 20px; }
#organization li { margin-block: 6px; overflow-wrap: anywhere; }
.paper-figure { margin-block: 14px; }
.paper-figure canvas { display: block; max-width: 100%; height: auto; margin-bottom: 6px; }
#bulk-collection-items { max-height: 45vh; overflow-y: auto; }
#bulk-collection-items label { margin-block: 6px; }

.document-settings { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-top: 12px; padding: 12px 16px; }
.document-settings summary { cursor: pointer; font-weight: 600; }
.document-settings .actions { flex-wrap: wrap; }
.document-settings li { margin-block: 6px; overflow-wrap: anywhere; }
.document-settings pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.document-settings textarea { min-height: 84px; }
.account-export label { display: flex; align-items: center; gap: 8px; }
.account-export input[type=checkbox] { width: auto; margin: 0; }
.account-export progress { width: 100%; margin-top: 12px; }

/* Icon rail (U1): replaces the wide sidebar on every page; a bottom tab bar on phones. */
aside.rail { width: 76px; padding: 14px 6px; align-items: center; }
aside.rail nav { margin: 0; display: flex; flex-direction: column; gap: 4px; height: 100%; width: 100%; }
.rail-item { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; padding: 9px 2px; border-radius: 10px;
  background: transparent; color: var(--text-2); text-decoration: none; font-size: var(--fs-xs); font-weight: 600; line-height: 1.2; text-align: center; }
nav a.rail-item:not([aria-current]) { background: transparent; }
.rail-item[hidden] { display: none; }
.rail-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rail-item:hover { background: var(--surface-3); color: var(--accent); }
.rail-item[aria-current] { background: var(--surface-3); color: var(--accent); }
.rail-item[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); }
.rail-item:focus-visible { outline: 2px solid var(--text-3); outline-offset: 1px; }
.rail-end { margin-top: auto; }
.rail-item .logo-mark g { stroke-width: 8; }
.logo-n { stroke: var(--logo-ink); }
.logo-ring { stroke: var(--logo-ring); }
main { margin-left: 76px; width: calc(100% - 76px); }
@media (max-width: 1050px) { aside.rail { width: 76px; padding: 14px 6px; } main { margin-left: 76px; width: calc(100% - 76px); } }
@media (max-width: 620px) {
  body { display: block; }
  aside.rail { position: fixed; inset: auto 0 0 0; width: 100%; height: auto; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border); z-index: 20; display: block; }
  aside.rail nav { flex-direction: row; justify-content: space-around; height: auto; }
  .rail-item { flex: 1; padding: 6px 0; min-width: 0; }
  .rail-end { margin-top: 0; }
  main { margin: 0; width: 100%; padding-bottom: 84px; }
}

/* Settings page */
.settings-page #settings { max-width: 720px; }
.settings-group { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin: 0 0 16px; }
.settings-group > h2 { font-size: 15px; margin: 0 0 10px; color: var(--text-2); }
.settings-group h3 { font-size: 15px; margin-top: 0; }
.settings-group > .document-settings { border: 0; padding: 0; margin: 0; background: none; }
.settings-group > .document-settings > summary { font-size: 15px; color: var(--text-2); margin-bottom: 10px; }
.settings-fold > summary { cursor: pointer; }
.template-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.template-toolbar > details > summary { cursor: pointer; padding: 8px 2px; color: var(--text-2); }
.template-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border); }
.template-row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 !important; }
.template-open { flex: 1; display: grid; gap: 2px; text-align: left; background: transparent; color: var(--text); border: 0; border-radius: 8px; padding: 10px 8px; }
.template-open:hover:not(:disabled) { background: var(--surface-3); filter: none; }
.template-open .muted { font-size: var(--fs-sm); }
.template-editor h3 { margin: 4px 0 8px; }
.item-set-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 12px; margin-bottom: 12px; }
.template-editor > button[type=submit] { margin-right: 6px; }
.settings-fold > summary h2 { display: inline; font-size: 15px; margin: 0; color: var(--text-2); }
.settings-fold[open] > summary { margin-bottom: 12px; }
.settings-fold .document-settings { border: 0; padding: 0; margin: 0 0 16px; background: none; }
.settings-group label:has(> input[type=checkbox]) { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.settings-group label:has(> input[type=checkbox]) > input { width: auto; margin: 0; }
.settings-row { display: block; color: var(--accent); text-decoration: none; font-weight: 600; padding: 6px 0; }
.settings-row::after { content: '›'; float: right; color: var(--text-3); }
#settings-account-email:empty { display: none; }
#settings-status:empty { display: none; }

/* Library (U2): list with the PDF beside it, or a grid of cards. */
.library { padding-top: 22px; }
.library-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.library-head h1 { margin: 0; font-size: var(--fs-2xl); flex: none; }
.library-tools { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; min-width: 0; }
.library-tools #search { flex: 1; max-width: 360px; min-width: 120px; padding: 8px 10px; }
.library-tools #filter { width: auto; padding: 8px; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 8px; background: transparent;
  color: var(--accent); border: 1px solid transparent; cursor: pointer; list-style: none; flex: none; }
.icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover { background: var(--surface-3); filter: none; }
.icon-button[aria-pressed=true] { background: var(--accent); color: var(--surface); }
.icon-button.primary { background: var(--accent); color: var(--surface); }
summary.icon-button::-webkit-details-marker { display: none; }
.view-switch { display: inline-flex; gap: 2px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 2px; }
.view-switch .icon-button { width: 32px; height: 30px; padding: 0; border-radius: 7px; }
.view-switch button[aria-pressed=true] { background: var(--accent); color: var(--surface); }
details.menu { position: relative; flex: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px #23383122; padding: 6px; display: grid; gap: 2px; }
.menu-panel label { margin: 6px 8px; }
.menu-item { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); border: 0; border-radius: 7px; padding: 9px 10px; }
.menu-item:hover { background: var(--surface-3); filter: none; }
#message:empty { display: none; }
.library .workspace { margin-top: 16px; grid-template-columns: 300px minmax(0, 1fr); align-items: start; min-height: 0; }
.library .workspace.cards { grid-template-columns: 1fr; }
.library-count { margin: 0 0 6px; font-size: var(--fs-xs); color: var(--text-2); }
#items.list { max-height: calc(100vh - 120px); position: sticky; top: 12px; }
#pane { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; position: sticky; top: 12px; display: flex; flex-direction: column;
  height: calc(100vh - 120px); min-height: 420px; }
#pane[hidden] { display: none; }
#pane-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
#pane-title { flex: 1; min-width: 0; font-weight: 600; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pane-back { display: none; }
#reader-frame { flex: 1; width: 100%; height: auto; border: 0; margin: 0; }
#pane #detail { flex: 1; overflow: auto; border: 0; border-radius: 0; }
#pane #detail[hidden], #reader-frame[hidden], #pane-info[hidden], #pane-full[hidden] { display: none; }
#items.card { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; max-height: none; overflow: visible; }
#items.card .library-count, #items.card .empty, #items.card .library-empty { grid-column: 1 / -1; }
.paper-card { display: flex; flex-direction: column; text-align: left; padding: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; }
.paper-card:hover { filter: none; border-color: var(--border-strong); }
.paper-card.selected { outline: 2px solid var(--text-2); }
.card-figure { display: grid; place-items: center; aspect-ratio: 1.6; background: var(--surface-3); overflow: hidden; }
.card-figure canvas { max-width: 100%; max-height: 100%; }
.card-figure.no-figure svg { width: 34px; height: 34px; fill: none; stroke: var(--text-3); stroke-width: 1.4; }
.card-body { display: grid; gap: 6px; padding: 14px 16px 16px; }
.card-journal { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title { font-family: var(--font); font-weight: 600; letter-spacing: -0.01em; font-size: var(--fs-lg); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; min-height: 4.05em; }
.card-author { font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-date { font-size: var(--fs-xs); color: var(--text-2); }
.library-empty { text-align: center; padding: 70px 20px; color: var(--text-2); }
.library-empty svg { width: 46px; height: 46px; fill: none; stroke: var(--text-3); stroke-width: 1.4; }
.library-empty .actions { justify-content: center; flex-wrap: wrap; }
@media (max-width: 1050px) {
  .library .workspace { grid-template-columns: 1fr; }
  .library .workspace.reading:not(.cards) #items { display: none; }
  #pane-back { display: inline-grid; }
  #items.list, #pane { position: static; max-height: none; }
  #pane { height: calc(100vh - 150px); }
}
@media (max-width: 620px) {
  .library-head { gap: 10px; }
  .library-tools { flex-wrap: wrap; justify-content: flex-start; }
  .library-tools #search { flex-basis: 100%; max-width: none; }
  #items.card { grid-template-columns: 1fr; }
  #pane { height: calc(100vh - 190px); }
}
#items.list .library-count { padding: 8px 14px 6px; margin: 0; border-bottom: 1px solid var(--border); }
@media (max-width: 620px) { .library-head h1 { flex-basis: 100%; } .library-tools { flex-basis: 100%; } }

.required-item{display:flex;gap:.5rem;align-items:start;flex-wrap:wrap;margin:.5rem 0}.required-item>input{flex:1;min-width:8rem}.required-item details{flex-basis:100%}.required-item select{max-width:100%}

/* Settings and AI pages (U3): full width, quiet card surfaces, buttons ranked by importance.
   Filled = the one action that finishes the card; white = secondary; text = occasional; icon = row menu. */
.settings-page { font-size: var(--fs-sm); letter-spacing: -.005em; -webkit-font-smoothing: antialiased; }
.settings-page > header h1 { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.4px; margin: 0 0 18px; }
.settings-page #settings { max-width: 1320px; }
.settings-page .muted { font-size: var(--fs-xs); }
.settings-page p { line-height: 1.6; }
:where(.settings-page) input:not([type=checkbox], [type=radio], [type=file]), :where(.settings-page) :is(select, textarea) {
  font-size: var(--fs-sm); border-color: #1f2d261f; border-radius: 8px; box-shadow: inset 0 1px 2px #1f2d260a; }
:where(.settings-page) input:not([type=checkbox], [type=radio], [type=file]), :where(.settings-page) select { padding: 7px 10px; }
:where(.settings-page) label { font-size: var(--fs-xs); color: var(--text-2); margin: 12px 0; }

:where(.settings-page) button:where(:not([class]), [class=""], .danger, .secondary, .text-button), :where(.settings-page) a.button-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 30px; padding: 0 12px; border: 0; border-radius: 8px;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap; }
:where(.settings-page) button:where(:not([class]), [class=""]) { background: var(--accent); color: var(--surface);
  box-shadow: inset 0 1px 0 #ffffff26, 0 0 0 1px var(--accent), 0 1px 2px #1f2d2633; }
:where(.settings-page) :where(button, a).secondary { background: var(--surface); color: var(--text); font-weight: 500;
  box-shadow: 0 0 0 1px #1f2d261a, 0 1px 2px #1f2d260f; }
:where(.settings-page) .text-button { background: transparent; color: var(--text-2); font-weight: 500; padding: 0 8px; box-shadow: none; }
:where(.settings-page) button.danger { background: var(--danger); color: var(--surface); box-shadow: inset 0 1px 0 #ffffff26, 0 0 0 1px var(--danger); }
:where(.settings-page) button:hover:not(:disabled) { filter: none; }
:where(.settings-page) button:where(:not([class]), [class=""]):hover:not(:disabled) { background: var(--accent); }
:where(.settings-page) .secondary:hover:not(:disabled) { background: var(--surface-2); }
:where(.settings-page) .text-button:hover:not(:disabled) { background: #1f2d260a; color: var(--text); }
:where(.settings-page) button:disabled { opacity: .45; cursor: default; }
.settings-page .research-field-chip { border: 0; background: var(--surface-2); box-shadow: inset 0 0 0 1px #1f2d260f; border-radius: 6px; padding: 3px 4px 3px 9px; font-size: var(--fs-xs); }
.settings-page .research-field-chip button { height: 20px; padding: 0 6px; font-size: var(--fs-xs); box-shadow: none; background: transparent; color: var(--text-2); }

.settings-page .settings-group { background: var(--surface); border: 0; border-radius: 12px; padding: 16px 18px; margin: 0 0 16px;
  box-shadow: 0 0 0 1px #1f2d2612, 0 1px 2px #1f2d260d, 0 2px 6px #1f2d2608; }
.settings-page .settings-group > h2, .settings-page .settings-group h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin: 0 0 12px; }
.settings-page .settings-group h4 { font-size: var(--fs-xs); font-weight: 600; margin: 16px 0 6px; }
.settings-page :is(.document-settings, .settings-fold) > summary { list-style: none; display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text); cursor: pointer; margin: 0; }
.settings-page .settings-fold > summary h2 { font-size: var(--fs-sm); color: var(--text); }
.settings-page :is(.document-settings, .settings-fold) > summary::-webkit-details-marker { display: none; }
.settings-page :is(.document-settings, .settings-fold) > summary::before { content: ''; flex: none; width: 6px; height: 6px; margin: 0 4px 0 1px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(-45deg); transition: transform .15s; }
.settings-page :is(.document-settings, .settings-fold)[open] > summary::before { transform: rotate(45deg); }
.settings-page :is(.document-settings, .settings-fold)[open] > summary { margin-bottom: 12px; }
.settings-page :is(.template-list, .template-row) { border-color: #1f2d260f; }
.settings-page .template-open { padding: 10px 4px; }
.settings-page .template-open strong { font-size: var(--fs-sm); font-weight: 500; }
.settings-page .template-open .muted { font-size: var(--fs-xs); }
.settings-page .template-row .icon-button { width: 28px; height: 28px; color: var(--text-3); }

/* AI page: provider and key on the left, templates and wording on the right. */
.settings-page .field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings-page .field-pair label { margin: 0 0 12px; }
.settings-page .settings-group input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 28px; height: 16px; margin: 0; padding: 0;
  border: 0; border-radius: 8px; background: var(--border-strong); position: relative; box-shadow: none; cursor: pointer; transition: background .15s; }
.settings-page .settings-group input.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px #0003; transition: left .15s; }
.settings-page .settings-group input.switch:checked { background: var(--accent); }
.settings-page .settings-group input.switch:checked::after { left: 14px; }
.settings-page .settings-group input.switch:disabled { opacity: .45; cursor: default; }
.settings-page .settings-group label.switch-row { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; gap: 12px;
  margin: 0; padding: 10px 0; border-top: 1px solid #1f2d260f; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.settings-page .switch-row + .muted { margin: -4px 0 8px; }
.settings-page .card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 14px; }
.settings-page .card-actions > .text-button:first-child { margin-right: auto; margin-left: -8px; }
/* 새 템플릿 and 파일 가져오기 sit on the card's title line; an opened import gets its own row below. */
.settings-page #ai-templates .template-toolbar { position: relative; justify-content: flex-end; align-items: center; gap: 4px; margin: -36px 0 12px;
  pointer-events: none; }
.settings-page #ai-templates .template-toolbar > * { pointer-events: auto; }
.settings-page #ai-templates .template-toolbar > div { order: -1; }
.settings-page #ai-templates .template-toolbar > div:has(> details[open]) { order: 2; flex-basis: 100%; margin-top: 8px; }
.settings-page .template-toolbar > div > details > summary { list-style: none; display: inline-flex; align-items: center; height: 30px; padding: 0 8px; border-radius: 8px;
  color: var(--text-2); font-size: var(--fs-xs); font-weight: 500; }
.settings-page .template-toolbar > div > details > summary::-webkit-details-marker { display: none; }
.settings-page .template-toolbar > div > details > summary:hover { background: #1f2d260a; color: var(--text); }

/* Settings page: the short cards side by side at one height, each with its action at the bottom right. */
.settings-top { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.settings-top > .settings-group { display: flex; flex-direction: column; min-height: 140px; margin: 0; }
.settings-top > .settings-group > :is(a.button-link, #research-field-add, #research-field-refresh) { margin-top: auto; align-self: flex-end; }
.settings-top #settings-account-email { margin: 0; font-size: var(--fs-sm); }
.settings-top #settings-local { margin: 0; }
@media (max-width: 1050px) {
}
@media (max-width: 860px) {
  .settings-top { grid-auto-flow: row; }
  .settings-top > .settings-group { min-height: 0; }
}
/* 기록·비교: the card title on top; its parts are quieter rows split by lines, their contents indented under the name. */
.settings-page .settings-fold > summary h2 { font-size: var(--fs-md); }
.settings-page .settings-fold .document-settings { margin: 0; padding: 0; border-top: 1px solid #1f2d260f; border-radius: 0; }
.settings-page .settings-fold .document-settings > summary { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); padding: 11px 0; }
.settings-page .settings-fold .document-settings[open] > summary { margin: 0; }
.settings-page .settings-fold .document-settings > summary::before { width: 5px; height: 5px; }
.settings-page .settings-fold .document-settings > :not(summary) { margin-left: 18px; }
.settings-page .settings-fold .document-settings[open] { padding-bottom: 14px; }
/* Nothing here finishes a task at rest, so its add buttons are secondary; form submits stay filled. */
:where(.settings-page) .settings-fold button:where(:not([class]), [class=""]):not([type=submit]) { background: var(--surface); color: var(--text); font-weight: 500;
  box-shadow: 0 0 0 1px #1f2d261a, 0 1px 2px #1f2d260f; }
:where(.settings-page) .settings-fold button:where(:not([class]), [class=""]):not([type=submit]):hover:not(:disabled) { background: var(--surface-2); }

/* Full screen pane: the reader grows over the library in the same tab. */
body.pane-expanded { overflow: hidden; }
body.pane-expanded #pane:not([hidden]) { position: fixed; inset: 0; z-index: 60; height: auto; max-height: none; min-height: 0; border: 0; border-radius: 0; }
body.pane-expanded #pane-back { display: none; }

/* AI tab editors (U4): template and extraction-set forms as one calm column, sets as pills, one action row. */
.settings-page .template-editor { display: grid; gap: 14px; }
.settings-page .template-editor > h3 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.settings-page .template-editor label { display: grid; gap: 6px; margin: 0; }
.settings-page .template-editor h4 { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin: 6px 0 -6px; }
.settings-page .template-editor textarea { min-height: 220px; font-size: var(--fs-sm); line-height: 1.65; padding: 10px 12px; border-radius: 10px; resize: vertical; }
.settings-page .field-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 12px; }
.settings-page .template-editor [data-required-items] { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 16px; }
.settings-page .template-editor [data-required-items]:empty { display: none; }
/* One line per item: name, its link (opens below), remove. */
.settings-page .template-editor .required-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 2px; align-items: center; margin: 0; }
.settings-page .required-item > details { order: 1; font-size: var(--fs-xs); color: var(--text-2); }
.settings-page .required-item > .text-button { order: 2; padding: 0 6px; color: var(--text-3); font-weight: 400; }
.settings-page .required-item > details[open] { order: 3; grid-column: 1 / -1; display: grid; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.settings-page .required-item > details > summary { list-style: none; cursor: pointer; padding: 0 6px; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.settings-page .required-item > details > summary::-webkit-details-marker { display: none; }
.settings-page .required-item > details > summary:hover { color: var(--text); }
.settings-page .required-item > details[open] > summary { padding: 0; max-width: none; }
.settings-page .add-row { justify-self: start; margin-left: -8px; }
.settings-page .pill-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.settings-page .template-editor label.choice-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; position: relative;
  border-radius: 14px; background: var(--surface); box-shadow: 0 0 0 1px #1f2d261f; font-size: var(--fs-xs); color: var(--text); cursor: pointer; }
.settings-page .choice-pill input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.settings-page .template-editor label.choice-pill { flex-direction: row; justify-content: flex-start; }
.settings-page .choice-pill small { font-size: var(--fs-xs); color: var(--text-3); font-weight: 400; }
.settings-page .choice-pill:hover { background: var(--surface-2); }
.settings-page .choice-pill:has(input:checked) { background: var(--surface-3); box-shadow: 0 0 0 1px #2f5a3f59; color: var(--text); font-weight: 500; }
.settings-page .choice-pill:has(input:checked)::before { content: '✓'; font-size: var(--fs-xs); }
.settings-page .choice-pill:has(input:focus-visible) { outline: 2px solid var(--text-3); outline-offset: 2px; }
.settings-page .inline-fold > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); }
.settings-page .inline-fold > summary::-webkit-details-marker { display: none; }
.settings-page .inline-fold > summary::before { content: ''; width: 5px; height: 5px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg); transition: transform .15s; }
.settings-page .inline-fold[open] > summary::before { transform: rotate(45deg); }
.settings-page .inline-fold[open] > summary { margin-bottom: 8px; }
.settings-page .form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; padding-top: 14px; border-top: 1px solid #1f2d260f; }
.settings-page .form-actions > .danger-text { margin-right: auto; margin-left: -8px; color: var(--danger); }
.settings-page .form-actions > .danger-text:hover:not(:disabled) { background: #a52f2f0f; color: var(--danger); }
.settings-page .tag-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 38px; padding: 5px 6px; border-radius: 8px; background: var(--surface);
  box-shadow: 0 0 0 1px #1f2d261f, inset 0 1px 2px #1f2d260a; cursor: text; }
.settings-page .tag-field:focus-within { box-shadow: 0 0 0 1px var(--text-2), 0 0 0 3px #5d8a6822; }
.settings-page .tag-field .chip-list { display: contents; }
.settings-page .tag-field input { flex: 1; min-width: 140px; border: 0; box-shadow: none; background: transparent; padding: 4px 6px; }
.settings-page .tag-field input:focus { outline: none; }
.settings-page .tag-field .chip { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 2px 0 9px; border-radius: 6px;
  background: var(--surface-3); color: var(--text); font-size: var(--fs-xs); }
.settings-page .tag-field .chip .text-button { height: 20px; padding: 0 5px; font-size: var(--fs-sm); color: var(--text-2); }
.settings-page #ai-sets .template-toolbar { position: relative; justify-content: flex-end; align-items: center; margin: -36px 0 12px; pointer-events: none; }
.settings-page #ai-sets .template-toolbar > * { pointer-events: auto; }
@media (max-width: 620px) { .settings-page .field-row { grid-template-columns: minmax(0, 1fr); } }

/* PDF check marks (pdf-check-ui.mjs): one small icon next to a checked value, details on click. */
.check-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; margin-left: 4px; vertical-align: middle;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; }
.check-mark svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.check-mark[data-state="other_page"], .check-mark[data-state="value_missing"], .check-mark[data-state="not_found"], .check-mark[data-state="note"] { color: var(--warning); }
.check-mark:hover, .check-mark:focus-visible { background: rgba(0, 0, 0, .06); }
.check-detail { margin-top: 4px; font-size: var(--fs-xs); color: var(--text-2); }
.check-detail .text-button { padding: 0; min-height: 0; font-size: var(--fs-xs); }
.group-imports{list-style:none;padding:0;margin:0}.group-imports li{padding:8px 0;border-bottom:1px solid var(--border);display:grid;gap:4px}.group-imports small{color:var(--text-2)}.group-imports p{white-space:pre-wrap;margin:0}

/* Analysis start: "추출 항목" dropdown, styled like the prompt select; several sets can be ticked. */
.set-choice { display: grid; gap: 6px; margin: 12px 0; border: 0; padding: 0; }
.set-choice .value-label { font-size: var(--fs-xs); color: var(--text-2); }
.value-picker { position: relative; }
.value-picker > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: var(--fs-md);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.value-picker > summary::-webkit-details-marker { display: none; }
.value-picker > summary::after { content: "\2304"; color: var(--text-2); flex: none; }
/* In the flow under the field: the reader's narrow panel scrolls, so a floating menu would be cut off. */
.value-menu { margin-top: 4px; display: grid; gap: 2px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 2px 8px #2338311a; max-height: 50vh; overflow: auto; }
.value-menu > label, .value-menu > .value-none { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; margin: 0;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: var(--fs-sm); color: var(--text); background: transparent; border: 0; text-align: left; }
.value-menu > label > input { width: auto; margin: 0; grid-row: span 2; }
.value-menu > label > small { grid-column: 2; font-size: var(--fs-xs); color: var(--text-2); }
.value-menu > label > small:empty { display: none; }
.value-menu > .value-none { display: block; padding-left: 10px; }
.value-menu > .value-none.on::before { content: "\2713  "; color: var(--accent); }
.value-menu > label:hover, .value-menu > .value-none:hover { background: var(--surface-3); filter: none; }

/* AI tab: accuracy counts (A8). */
.quality-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.quality-table th, .quality-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #1f2d2612; }
.quality-table th { font-weight: 600; color: var(--text-2); }

/* Settings: AI and groups are reached from here (the rail keeps only the user's own material). */
.settings-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 0 0 16px; }
.settings-links[hidden], .settings-link[hidden] { display: none; }
.settings-link { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); text-decoration: none; }
.settings-link:hover { border-color: var(--border-strong); background: var(--surface-2); }
.settings-link span { font-size: var(--fs-sm); color: var(--text-3); }
.back-link { display: inline-block; font-size: var(--fs-sm); color: var(--text-3); text-decoration: none; margin-bottom: 4px; }
.back-link:hover { color: var(--accent); }

/* Paper page (library): title, labels, the AI's values, notes, then "더보기". */
#pane #detail { padding: 24px 28px 40px; }
.page-head h2 { font-size: var(--fs-xl); line-height: 1.35; letter-spacing: -0.01em; margin: 0 0 8px; }
.page-head .detail-meta { margin: 0; }
.page-props { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.page-props select, .page-props input { width: auto; padding: 5px 10px; font-size: var(--fs-sm); border-radius: 999px; border-color: var(--border); background: var(--surface); }
.page-props select { padding-right: 26px; }
.page-props input { flex: 1 1 160px; max-width: 320px; }
.page-section { margin-top: 26px; }
.page-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page-section-head h3 { margin: 0; font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.page-section > h3 { margin: 0 0 8px; font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.page-section textarea { min-height: 120px; font-size: var(--fs-md); line-height: 1.7; border-color: var(--border); }
.page-values { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.page-values th { text-align: left; font-weight: 500; color: var(--text-3); font-size: var(--fs-xs); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.page-values td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.page-values td:first-child { color: var(--text-2); width: 34%; }
.page-values td:nth-child(3), .page-values td:nth-child(4) { width: 1%; white-space: nowrap; }
.page-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.page-link:hover { text-decoration: underline; filter: none; }
.state-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: var(--fs-xs); }
.state-chip.ok { background: var(--accent-soft); color: var(--accent); }
.state-chip.wait { background: var(--warning-soft); color: var(--warning); }
.text-button { background: none; border: 0; padding: 0; color: var(--accent); font-size: var(--fs-sm); cursor: pointer; }
.text-button:hover { text-decoration: underline; filter: none; }
.page-summary { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.page-summary summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.page-summary h4 { font-size: var(--fs-sm); margin: 12px 0 2px; }
.page-summary p { font-size: var(--fs-sm); line-height: 1.7; margin: 0; color: var(--text-2); white-space: pre-wrap; }
.page-more { margin-top: 30px; border-top: 1px solid var(--border); padding-top: 10px; }
.page-more > summary { cursor: pointer; color: var(--text-3); font-size: var(--fs-sm); }
.page-more-body { display: grid; gap: 12px; justify-items: start; margin-top: 10px; }
.page-more-body > * { justify-self: stretch; }
.page-more-body > button { justify-self: start; }
.danger-text { color: var(--danger) !important; }
.pane-read { padding: 6px 14px; font-size: var(--fs-sm); border-radius: var(--radius); }
.pane-read.back { background: transparent; color: var(--accent); border-color: transparent; padding-left: 6px; }
.pane-read.back { order: -1; }
.page-head { display: block; }
.page-values.folded tbody tr:nth-child(n+9) { display: none; }
.page-values th { white-space: nowrap; }
.more-values { margin-top: 8px; }

/* ⌘K find box */
dialog.command { padding: 0; width: min(560px, 92vw); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); margin-top: 12vh; overflow: hidden; }
dialog.command::backdrop { background: rgba(20, 30, 25, .28); }
dialog.command input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 16px; font-size: var(--fs-lg); outline: none; }
dialog.command ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
dialog.command li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: var(--fs-md); }
dialog.command li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog.command li small { flex: none; color: var(--text-3); font-size: var(--fs-xs); }
dialog.command li[aria-selected=true] { background: var(--accent-soft); }
dialog.command li[data-group]::before { content: attr(data-group); display: none; }
dialog.command li[data-group] { margin-top: 18px; position: relative; }
dialog.command li[data-group]:first-child { margin-top: 18px; }
dialog.command li[data-group]::after { content: attr(data-group); position: absolute; top: -17px; left: 10px; font-size: var(--fs-xs); color: var(--text-3); }
/* ⌘K "찾기" at the top right of a page header (nav.mjs): looks like a search box, opens the finder. */
main > header > .find-button { margin-left: auto; flex: none; align-self: center; display: inline-flex; align-items: center; gap: 8px;
  width: 220px; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-md, 8px);
  background: var(--surface); color: var(--text-3); font: inherit; font-size: var(--fs-sm); box-shadow: none; cursor: pointer; white-space: nowrap; }
main > header > .find-button:hover { border-color: var(--border-strong); color: var(--text-2); background: var(--surface); }
main > header > .find-button svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
main > header > .find-button span { flex: 1; text-align: left; }
main > header > .find-button kbd { font: inherit; font-size: var(--fs-xs); color: var(--text-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
@media (max-width: 620px) { main > header > .find-button { width: 34px; padding: 0; justify-content: center; } main > header > .find-button :is(span, kbd) { display: none; } }
/* The paper list folds away beside an open paper (the button at the left of the paper's bar), and folds by itself
 * when the library has less room than list + PDF + its panel need (the question panel open, a smaller window). */
main.library { container: library / inline-size; }
.library .workspace.reading.list-folded:not(.cards) { grid-template-columns: minmax(0, 1fr); }
.library .workspace.reading.list-folded:not(.cards) #items { display: none; }
@container library (max-width: 1100px) {
  .workspace.reading:not(.cards):not(.list-open) { grid-template-columns: minmax(0, 1fr); }
  .workspace.reading:not(.cards):not(.list-open) #items { display: none; }
}
@media (max-width: 1050px) { #list-toggle { display: none; } }
#list-toggle svg { transform: scaleX(-1); }

/* AI 분석 시작 (ai-runtime.mjs planForm/startForm): prompts as cards, extraction sets as a folding checklist,
 * 취소 and the start button side by side. */
.plan-form { display: grid; gap: 14px; }
.plan-group { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.plan-group > legend { display: flex; justify-content: space-between; align-items: baseline; width: 100%; padding: 0; margin-bottom: 6px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.plan-group > legend small { font-weight: 400; color: var(--text-3); }
.plan-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--surface); }
.plan-card[hidden] { display: none; }
.plan-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 0.5px var(--accent); }
.plan-card > label { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin: 0; cursor: pointer; min-width: 0; }
.plan-card input[type=radio] { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.plan-card-text { display: grid; gap: 1px; min-width: 0; }
.plan-card-text strong { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.plan-card-text small { font-size: var(--fs-xs); color: var(--text-2); }
.plan-preview-toggle, .plan-more { border: 0; background: transparent; color: var(--accent); font-size: var(--fs-xs); font-weight: 600;
  padding: 11px 12px; cursor: pointer; }
.plan-preview-toggle:hover:enabled, .plan-more:hover:enabled { background: transparent; text-decoration: underline; }
.plan-more { justify-self: start; padding: 4px 2px; }
.plan-more[hidden] { display: none; }
.plan-preview { grid-column: 1 / -1; margin: 0 10px 10px; padding: 9px 11px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-2); }
.plan-preview p { margin: 0; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.plan-preview > div { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.plan-preview a { color: var(--accent); font-weight: 600; text-decoration: none; }
.plan-preview a:hover { text-decoration: underline; }
.plan-sets[hidden] { display: none; }
.plan-search { width: 100%; padding: 7px 10px; font-size: var(--fs-sm); border: 1px solid var(--border-strong); border-radius: 8px; }
.plan-search[hidden] { display: none; }
.plan-set-list { display: grid; gap: 0; }
.plan-set-list.open { max-height: 260px; overflow: auto; }
.plan-set { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 0;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.plan-set:hover { background: var(--surface-3); }
.plan-set input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.plan-set span { overflow-wrap: anywhere; }
.plan-set small { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.plan-actions { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.plan-cancel { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 8px; padding: 9px 16px; font-weight: 600; }
.plan-cancel:hover:enabled { background: var(--surface-3); }
.plan-start { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px;
  padding: 10px 14px; background: var(--accent); color: var(--surface); font-weight: 600; }
.plan-start:hover:enabled { background: var(--accent-hover, var(--accent)); }
.plan-start svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.plan-status { margin: 0; font-size: var(--fs-xs); color: var(--danger); }
.plan-status:empty { display: none; }

/* The AI start form: what the ticked sets add up to, and whether an analysis can start (docs/UX_WORKFLOW_PLAN.md §8). */
.plan-preview-items { margin-top: 8px; font-size: var(--fs-xs); color: var(--text-2); }
.plan-preview-items summary { cursor: pointer; }
.plan-preview-items p { margin: 6px 0 0; overflow-wrap: anywhere; }
.plan-ready { margin: 10px 0 0; font-size: var(--fs-sm); color: var(--warning); }
.plan-ready[hidden] { display: none; }
/* After an import: what to do with each paper next. */
.import-next { display: inline-flex; gap: 6px; margin-left: 6px; }
.settings-return { margin-left: auto; text-decoration: none; }
/* What each paper's records are (library-records.mjs): on its line, on its card, and the two record filters above the list. */
.row-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; grid-row: 1 / span 2; }
.records-count { font-size: var(--fs-xs); font-weight: 600; color: var(--text); }
.records-note { font-size: var(--fs-xs); color: var(--text-2); }
.records-note.wait { padding: 1px 8px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-weight: 600; }
.card-records { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.library-count { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.record-filters { display: inline-flex; gap: 6px; }
.record-filter { height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: var(--fs-xs); cursor: pointer; }
.record-filter.wait { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.record-filter[aria-pressed="true"] { border-color: var(--accent); color: var(--text); font-weight: 600; }
.card-figure.has-values { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 8px; padding: 14px 16px; background: var(--logo-ground); }
.card-value { display: flex; flex-direction: column; gap: 1px; text-align: left; min-width: 0; }
.card-value small { font-size: var(--fs-xs); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-value strong { font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
