/* The word list and the word page. Loaded after shell.css, which owns the
   design tokens, the reset and the tab bar.

   TWO LAYOUTS, ONE MARKUP. On a wide screen the list is a six-column table;
   under 760px each row folds into a two-line card, because six columns at
   375px gives every one of them about 50px and the definition — the reason
   you are reading the row at all — becomes an ellipsis. The fold is a CSS
   grid-template change, not different markup, so there is one render path.

   The row height differs between the two, and the list is virtualised, so JS
   has to know it: --row-h is read back by words.js. Change it here only. */
/* --list-chrome is everything above the scroller: the nav bar, the page
   toolbar and the count strip. It differs per breakpoint because the toolbar
   wraps differently and the nav bar moves to the bottom. */
:root{ --row-h:44px; --list-chrome:220px }
@media (max-width:760px){ :root{ --row-h:68px; --list-chrome:122px } }

/* ---- chrome ------------------------------------------------------------- */
header.top{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:10px 16px; background:var(--surface); border-bottom:1px solid var(--line);
  position:sticky; top:var(--top-h); z-index:20;
}
header.top h1{font-size:17px; font-weight:600; margin:0; letter-spacing:-0.01em}
header.top h1 .sub{font-weight:400; color:var(--faint); font-size:13px; margin-left:8px}
header.top .sp{flex:1}
header.top .grow{flex:1 1 190px; min-width:0}
label.field{display:inline-flex; align-items:center; gap:6px; font-size:12.5px;
            color:var(--muted); white-space:nowrap}

/* The filter row is its own line on desktop and a slide-down sheet on mobile,
   where six controls would otherwise push the list off the screen entirely. */
#filters{display:flex; align-items:center; gap:10px; flex-wrap:wrap}
@media (max-width:760px){
  header.top{padding:8px 12px}
  header.top h1{font-size:16px}
  #filters{
    display:none; width:100%; flex-direction:column; align-items:stretch;
    gap:9px; padding:11px 0 3px; border-top:1px solid var(--line-2); margin-top:2px;
  }
  #filters.open{display:flex}
  #filters label.field{justify-content:space-between; font-size:13px}
  #filters select{flex:0 0 62%}
}
@media (min-width:761px){ #filtersBtn{display:none} }

/* ---- status pills ------------------------------------------------------- */
.pill{
  display:inline-block; padding:1px 9px; border-radius:999px; font-size:12px;
  font-weight:500; border:1px solid currentColor; white-space:nowrap; line-height:1.55;
}
.k-unseen{color:var(--k-unseen)} .k-learning{color:var(--k-learning)}
.k-relearning{color:var(--k-relearning)} .k-young{color:var(--k-young)}
.k-mature{color:var(--k-mature)} .k-known{color:var(--k-known)}
.shelf{
  display:inline-block; padding:1px 8px; border-radius:5px; font-size:11.5px;
  background:var(--surface-2); border:1px solid var(--line-2); color:var(--muted);
}
.shelf.s-priority{color:var(--k-young); border-color:var(--k-young)}
.shelf.s-suspended,.shelf.s-ignored{opacity:.75}
.tag{
  display:inline-block; padding:1px 8px; border-radius:5px; font-size:11.5px;
  background:var(--surface-2); border:1px solid var(--line-2); color:var(--ink-2);
  white-space:nowrap;
}
.leech{color:var(--k-relearning); font-weight:600}

/* ---- summary strip ------------------------------------------------------ */
.strip{
  display:flex; gap:6px; padding:9px 16px; background:var(--surface);
  border-bottom:1px solid var(--line);
  /* Seven buttons do not fit at 375px. Scrolling them beats wrapping to three
     rows, which would push the list itself below the fold. */
  overflow-x:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch;
}
.strip::-webkit-scrollbar{display:none}
.strip button{
  background:none; border:1px solid var(--line); border-radius:9px; cursor:pointer;
  font:inherit; font-size:12px; padding:6px 11px; color:var(--muted);
  display:inline-flex; align-items:baseline; gap:7px; white-space:nowrap; flex:none;
  min-height:34px;
}
.strip button:hover{background:var(--surface-2)}
.strip button[aria-pressed="true"]{border-color:currentColor; background:var(--surface-2)}
.strip button b{font-size:13px; font-variant-numeric:tabular-nums; color:var(--ink)}
.strip .dot{width:8px; height:8px; border-radius:50%; background:currentColor;
            align-self:center; flex:none}

/* ---- the list ----------------------------------------------------------- */
.wrap{max-width:1180px; margin:0 auto; padding:0 16px}
@media (max-width:760px){ .wrap{padding:0} }
#scroller{
  height:calc(100dvh - var(--list-chrome)); overflow:auto; position:relative;
  overscroll-behavior:contain;
}
@media (max-width:760px){
  #scroller{height:calc(100dvh - var(--list-chrome) - var(--nav-h) - env(safe-area-inset-bottom))}
}
#spacer{position:relative; width:100%}

.row{
  position:absolute; left:0; right:0; height:var(--row-h);
  display:grid; align-items:center; gap:14px; padding:0 14px;
  grid-template-columns:58px minmax(120px,1.1fr) minmax(180px,3fr) 116px minmax(110px,1.3fr) 92px 78px;
  grid-template-areas:"rank lemma def st tags added num";
  border-bottom:1px solid var(--line-2); background:var(--surface); cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.row:hover{background:var(--surface-2)}
.row.sel{background:color-mix(in srgb, var(--focus) 9%, var(--surface))}
.row .rank{grid-area:rank; color:var(--faint); font-size:12px; text-align:right}
.row .lemma{grid-area:lemma; font-weight:600; font-size:15px; overflow:hidden;
            text-overflow:ellipsis; white-space:nowrap}
.row .lemma .pos{font-weight:400; font-size:11.5px; color:var(--faint); margin-left:7px}
.row .def{grid-area:def; color:var(--ink-2); overflow:hidden; text-overflow:ellipsis;
          white-space:nowrap; min-width:0}
.row .def .sep{color:var(--faint); padding:0 5px}
.row .def .none{color:var(--faint); font-style:italic}
.row .st{grid-area:st; min-width:0}
.row .tags{grid-area:tags; display:flex; gap:4px; overflow:hidden; white-space:nowrap}
.row .num{grid-area:num; text-align:right; color:var(--muted); font-size:12.5px}
.row .added{grid-area:added; color:var(--faint); font-size:12px;
            font-variant-numeric:tabular-nums; white-space:nowrap; overflow:hidden}

@media (max-width:760px){
  /* Two lines: identity and status on top, meaning underneath. Rank and recall
     ride along on the two lines rather than claiming columns of their own. */
  .row{
    grid-template-columns:1fr auto;
    grid-template-areas:"lemma st" "def num";
    gap:2px 10px; padding:9px 14px; align-content:center;
  }
  .row .rank{display:none}
  .row .tags{display:none}
  .row .added{display:none}
  .row .lemma{font-size:16px}
  .row .def{font-size:13px; white-space:nowrap}
  .row .st{text-align:right}
  .row .num{font-size:11.5px; align-self:center}
}

.head{
  display:grid; gap:14px; padding:9px 14px; font-size:12px; color:var(--muted);
  grid-template-columns:58px minmax(120px,1.1fr) minmax(180px,3fr) 116px minmax(110px,1.3fr) 92px 78px;
  border-bottom:1px solid var(--line); background:var(--ground);
}
.head button{background:none; border:0; padding:0; font:inherit; color:inherit;
             cursor:pointer; text-align:left}
.head button:hover{color:var(--ink)}
.head .r{text-align:right}
.head .on{color:var(--ink); font-weight:600}
@media (max-width:760px){ .head{display:none} }

.empty{padding:52px 20px; text-align:center; color:var(--muted)}

/* ---- selection and bulk actions ----------------------------------------- */
/* A checkbox column would cost 34px of a 375px row for something used rarely,
   so selection is a mode: turn it on and the rows respond to taps instead of
   navigating. The bar says so, and says how to leave. */
#bulk{
  position:sticky; bottom:0; z-index:15;
  display:flex; align-items:center; gap:9px; flex-wrap:wrap;
  padding:10px 16px; background:var(--surface); border-top:1px solid var(--line);
  box-shadow:0 -6px 18px rgba(20,28,36,.06);
}
@media (max-width:760px){
  #bulk{position:fixed; left:0; right:0;
        bottom:calc(var(--nav-h) + env(safe-area-inset-bottom))}
}
#bulk .n{font-weight:600; font-variant-numeric:tabular-nums}
#bulk .sp{flex:1}

/* ---- word page ---------------------------------------------------------- */
.sheet{max-width:1180px; margin:0 auto; padding:20px 16px 72px}
@media (max-width:760px){ .sheet{padding:14px 12px 84px} }
.hero{display:flex; align-items:flex-end; gap:16px; flex-wrap:wrap; margin-bottom:4px}
.hero .lemma{font:600 clamp(30px,8vw,42px)/1.1 "IBM Plex Sans",system-ui,sans-serif;
             letter-spacing:-0.02em; word-break:break-word}
.hero .meta{color:var(--faint); font-size:13px; padding-bottom:6px}
.hero .meta b{color:var(--muted); font-weight:500}
.cols{display:grid; grid-template-columns:repeat(auto-fit,minmax(320px,1fr)); gap:14px;
      margin-top:16px}
@media (max-width:760px){ .cols{grid-template-columns:1fr; gap:12px} }
.panel{
  background:var(--surface); border:1px solid var(--line); border-radius:12px;
  padding:14px 16px; box-shadow:var(--shadow); min-width:0;
}
.panel.wide{grid-column:1/-1}
.panel h2{
  font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.07em;
  color:var(--faint); margin:0 0 11px;
}
.panel .sub{color:var(--faint); font-size:12px; margin-top:10px}
/* A select inside a panel must be allowed to shrink. Its longest option here is
   "Suspended — paused until you unsuspend it", which sets the intrinsic width
   and pushed the control clean off a 375px screen until min-width:0 let the
   flex item go narrower than its content. */
.panel label.field{display:flex; align-items:center; gap:9px; margin-top:12px}
.panel label.field select{flex:1 1 auto; min-width:0}
@media (max-width:760px){
  .panel label.field{flex-direction:column; align-items:stretch; gap:5px;
                     white-space:normal}
  .panel label.field select{width:100%}
}
/* ---- the study settings on Home ------------------------------------------
   A row per setting: a label and its explanation on the left, the control on
   the right. The explanation is not a tooltip -- every one of these settings
   changes what the Study screen asks you, and a switch whose effect you have to
   discover by flipping it is a switch nobody flips. */
.opts{display:flex; flex-direction:column; gap:14px}
.opt{display:grid; grid-template-columns:1fr auto; gap:4px 14px; align-items:start}
.opt b{font-size:13.5px; font-weight:600}
.opt .why{grid-column:1; color:var(--muted); font-size:12px; line-height:1.45}
.opt select{
  grid-row:1 / span 2; grid-column:2; align-self:center;
  font:inherit; padding:6px 8px; border-radius:8px; max-width:190px;
  border:1px solid var(--line); background:var(--surface); color:var(--ink);
}
@media (max-width:420px){
  /* At 375px a 190px control beside a two-line explanation leaves the label
     three words wide. Stack instead. */
  .opt{grid-template-columns:1fr}
  .opt select{grid-row:auto; grid-column:1; max-width:none; margin-top:4px}
}

dl.kv{display:grid; grid-template-columns:auto 1fr; gap:6px 16px; margin:0; font-size:13px}
dl.kv dt{color:var(--muted)}
dl.kv dd{margin:0; text-align:right; overflow-wrap:anywhere}
.gloss-main{font-size:clamp(17px,4.6vw,19px); font-weight:500; line-height:1.35}
.gloss-main .sep{color:var(--faint); font-weight:400; padding:0 7px}
.gloss-en{margin-top:4px; font-size:14px; line-height:1.4; color:var(--muted)}
.ph{font-size:15px; color:var(--ink-2); margin-bottom:6px; letter-spacing:.02em}
.lemma .art, h1 .art{color:var(--faint); font-weight:400}
ol.senses{margin:12px 0 0; padding-left:20px; color:var(--ink-2); font-size:13.5px}
ol.senses li{margin:3px 0}
.chips{display:flex; flex-wrap:wrap; gap:6px; align-items:center}
.chip-x{background:none; border:0; color:var(--faint); cursor:pointer; font:inherit;
        padding:0 0 0 6px; line-height:1; min-width:22px; min-height:22px}
.chip-x:hover{color:var(--k-relearning)}
.tag.editable{display:inline-flex; align-items:center; padding:3px 5px 3px 9px}
.nbrow{display:flex; align-items:baseline; gap:10px; padding:5px 0;
       border-bottom:1px solid var(--line-2); min-width:0}
.nbrow:last-child{border-bottom:0}
.nbrow a{font-weight:500; text-decoration:none; flex:none}
.nbrow a:hover{text-decoration:underline}
.nbrow .g{color:var(--muted); font-size:12.5px; flex:1; overflow:hidden;
          text-overflow:ellipsis; white-space:nowrap; min-width:0}
.nbrow .sc{color:var(--faint); font-size:12px; flex:none}
.bar{height:5px; border-radius:3px; background:var(--line-2); overflow:hidden; margin-top:8px}
.bar i{display:block; height:100%}

/* ---- home --------------------------------------------------------------- */
.home{max-width:760px; margin:0 auto; padding:22px 16px 72px}
.home h1{font-size:clamp(24px,6vw,30px); margin:0 0 3px; letter-spacing:-0.02em}
.home .tagline{color:var(--muted); margin:0 0 20px}
.hero-card{
  background:var(--surface); border:1px solid var(--line); border-radius:14px;
  padding:18px; box-shadow:var(--shadow); margin-bottom:14px;
}
.hero-card .big{
  font:600 clamp(38px,11vw,52px)/1 "IBM Plex Sans",system-ui,sans-serif;
  letter-spacing:-0.03em; font-variant-numeric:tabular-nums;
}
.hero-card .cap{color:var(--muted); font-size:13.5px; margin-top:4px}
.hero-card .btn{margin-top:15px; width:100%; min-height:50px; font-size:15px}
.ladder{display:flex; flex-direction:column; gap:7px; margin-top:4px}
.ladder .lrow{display:grid; grid-template-columns:88px 1fr 52px; align-items:center;
              gap:10px; font-size:13px}
.ladder .lrow .nm{color:var(--muted)}
.ladder .lrow .n{text-align:right; font-variant-numeric:tabular-nums; color:var(--ink-2)}
.ladder .track{height:8px; border-radius:4px; background:var(--line-2); overflow:hidden}
.ladder .track i{display:block; height:100%}
.quick{display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px}
.quick a{
  background:var(--surface); border:1px solid var(--line); border-radius:12px;
  padding:13px 15px; text-decoration:none; color:var(--ink); display:block;
}
.quick a:hover{background:var(--surface-2)}
.quick a b{display:block; font-size:14.5px; font-weight:600; margin-bottom:2px}
.quick a span{color:var(--muted); font-size:12.5px}
.note{
  border-radius:11px; padding:12px 14px; font-size:13px; margin-bottom:14px;
  border:1px solid var(--hard); color:var(--hard); background:var(--surface);
}
#warn:not(:empty){margin-bottom:2px}
.note b{display:block; margin-bottom:3px}
.note .btn{margin-top:9px}

/* ---- a subset arriving from another screen ------------------------------- */
/* A cluster tapped on the map, the neighbours of a word, one part of speech.
   The list is suddenly 90 rows instead of 19,947, and without a line saying so
   that reads as a broken filter rather than an answered question. */
.subset{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  padding:9px 16px; background:var(--surface-2);
  border-bottom:1px solid var(--line);
}
.subset .slbl{font-size:13px; color:var(--ink-2)}
.subset .slbl b{font-weight:600; color:var(--ink)}
.subset .slbl em{font-style:normal; color:var(--muted)}
.subset .btn{padding:3px 10px; font-size:12px}
@media (max-width:760px){
  .subset{padding:8px 12px; gap:8px}
  .subset .slbl{font-size:12.5px}
}

/* ---- categorical groups as links ----------------------------------------- */
/* A word page that says a word is in "Animals & breeds" and gives no way to
   see the other 302 is describing a group it will not show you. */
.grow{display:inline-flex; align-items:baseline; gap:8px; flex-wrap:wrap}
.grow .gname{color:var(--focus); text-decoration:none; font-weight:500}
.grow .gname:hover{text-decoration:underline}
.grow .gmap{
  font-size:10.5px; color:var(--muted); text-decoration:none;
  border:1px solid var(--line); border-radius:6px; padding:0 5px; line-height:16px;
}
.grow .gmap:hover{color:var(--focus); border-color:var(--focus)}
/* The three most frequent members: the mechanical label the written name
   replaced, kept as the evidence beside the interpretation. */
.grow .ghead{color:var(--faint); font-size:11.5px; flex-basis:100%}
.mlink{color:var(--focus); text-decoration:none; font-weight:600}
.mlink:hover{text-decoration:underline}

/* ---- usage examples (word page) ------------------------------------------- */
/* Real sentences the word appears in, with their translations. Quieter than the
   meaning panel: evidence for it, not a competing answer. */
.eg{margin:0 0 11px; padding:9px 12px; border-radius:10px;
    background:var(--surface-2); border:1px solid var(--line-2)}
.eg:last-child{margin-bottom:0}
.eg .fi{margin:0; font-size:14.5px; line-height:1.45; color:var(--ink)}
.eg .fi b{font-weight:600; color:var(--k-mature, var(--focus))}
.eg .en{margin:4px 0 0; font-size:12.5px; line-height:1.4; color:var(--muted)}
/* Which source the sentence came from. Quiet — it qualifies the translation,
   it is not part of it. */
.eg .src{margin-left:8px; font-size:10.5px; letter-spacing:.04em;
         text-transform:uppercase; color:var(--faint); white-space:nowrap}

/* The YKI panel on Home: area names are longer than the ladder's states. */
#ykiRows .lrow{grid-template-columns:minmax(0,1.7fr) minmax(60px,1fr) 78px}
#ykiRows .lrow .nm{white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
#ykiRows .lrow:hover .nm{color:var(--ink)}
