/* Components shared by the UPSC Prep pages. Tokens, header, footer and
   base controls come from site.css, which loads first. */

.layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.sticky { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 132px); }
@media (max-width: 900px) { .sticky { position: static; } }

/* Paper picker: one tap per paper */
.papers {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px;
  padding: 4px; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px;
}
.papers label { position: relative; text-align: center; cursor: pointer; }
.papers input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.papers span { display: block; padding: 8px 2px; border-radius: 8px; font: 500 0.8125rem var(--mono); white-space: nowrap; color: var(--muted); transition: background 0.15s, color 0.15s; }
.papers label:hover span { color: var(--ink); }
.papers input:checked + span { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }
.papers input:focus-visible + span { outline: 2px solid var(--route); outline-offset: 1px; }
.auto { margin: 0; font-size: 0.8125rem; color: var(--route); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.auto button { padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; font-weight: 400; font-size: 0.8125rem; }
.autofilled { border-color: var(--route) !important; background: var(--route-soft) !important; }

/* Keyword chips */
.chipbox {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 46px;
  background: var(--field); border: 1px solid var(--rule); border-radius: var(--radius-sm);
}
.chipbox:focus-within { border-color: var(--route); box-shadow: 0 0 0 3px var(--route-soft); }
.chipbox input { flex: 1 1 140px; border: 0; padding: 5px 6px; background: transparent; box-shadow: none; min-width: 0; }
.chipbox input:focus { box-shadow: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 11px;
  background: var(--route-soft); border: 1px solid color-mix(in srgb, var(--route) 35%, transparent); border-radius: 999px;
  font-size: 0.875rem;
}
.chip button { border: 0; background: transparent; color: var(--route); padding: 0 6px; font-size: 1rem; line-height: 1; }

/* Suggestions */
.suggest { border: 1px solid var(--rule); border-radius: 12px; background: var(--field); display: grid; overflow: hidden; }
.suggest-head { padding: 9px 14px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 8px; background: var(--paper); }
.sug { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.sug:last-child { border-bottom: 0; }
.sug .kw { font-weight: 600; overflow-wrap: anywhere; }
.sug .meta { grid-column: 1; font: 400 0.75rem var(--mono); color: var(--muted); }
.sug .acts { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; flex-wrap: wrap; justify-content: end; }
.sug.done .acts button.accent { background: var(--ok); border-color: var(--ok); }
.freq {
  font: 500 0.75rem var(--mono); font-variant-numeric: tabular-nums;
  padding: 1px 7px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); white-space: nowrap;
}
.freq.hot { border-color: color-mix(in srgb, var(--route) 40%, transparent); color: var(--route); background: var(--route-soft); }

/* Ledger */
.ledger-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: end; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.filters .field { gap: 5px; }
.filters .wide { grid-column: 1 / -1; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stats > div { padding: 10px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); min-width: 110px; }
.stats strong { display: block; font: 700 1.5rem/1.1 var(--display); font-variant-numeric: tabular-nums; margin-top: 4px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--route) 3%, transparent); }
th { font: 500 0.7rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--paper); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.date { font: 400 0.8125rem var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
td a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--route); }
.paper { font: 500 0.75rem var(--mono); white-space: nowrap; }
tr.fresh td { background: var(--ok-soft); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.del { visibility: hidden; }
tr:hover .del, tr:focus-within .del, .del.confirm { visibility: visible; }
@media (hover: none) { .del { visibility: visible; } }
.del.confirm { color: var(--err); border-color: var(--err); }

/* Sign-in */
.auth { max-width: 440px; width: 100%; margin-inline: auto; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; }
.tabs button { flex: 1; background: transparent; color: var(--muted); border: 0; border-radius: 8px; }
.tabs button[aria-selected="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Segmented toggles used across the pages */
.views { display: flex; gap: 4px; padding: 4px; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; }
.views button { background: transparent; color: var(--muted); border: 0; border-radius: 8px; padding: 7px 14px; font: 500 0.8125rem var(--body); }
.views button[aria-pressed="true"] { background: var(--sheet); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

/* Add Keyword page: the form alone in one narrow column. */
.narrow-col { max-width: 600px; width: 100%; margin-inline: auto; display: grid; gap: 20px; }
