/* ------------------------------------------------------------------ *
 * Company-Wise LeetCode — editorial / warm-monochrome design
 *
 * Principles: warm bone canvas, hairline 1px borders, near-zero shadow,
 * one editorial serif for display headings, geometric system sans for UI,
 * mono for numbers. Muted pastel semantics only. Flat, document-like.
 * Fully fluid + responsive from phones to 4K.
 * ------------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  /* Warm monochrome — light */
  --bg:         #fbfbfa;   /* warm bone canvas */
  --panel:      #ffffff;   /* raised surface  */
  --panel-2:    #f4f3f0;   /* inset / hover   */
  --line:       #e6e4df;   /* hairline border */
  --line-soft:  #eeece8;
  --ink:        #22201c;   /* off-black text  */
  --ink-2:      #5f5c56;   /* secondary       */
  --ink-3:      #857f75;   /* muted / meta (kept AA on bone) */
  --link:       #22201c;
  --focus:      #a9a498;

  /* Muted pastel semantics */
  --easy-fg:   #3a7d44;  --easy-bg:   #eef3ec;
  --med-fg:    #9a6a00;  --med-bg:    #f7f0dd;
  --hard-fg:   #a33a34;  --hard-bg:   #f6e9e7;
  --freq:      #7c766a;  /* meter fill = warm graphite */

  --radius:    10px;
  --radius-sm: 7px;

  /* Fluid content width: comfortable on laptops, wider on big displays */
  --maxw: clamp(960px, 92vw, 1520px);
  --pad:  clamp(18px, 4vw, 48px);

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #171614;
    --panel:     #1d1c19;
    --panel-2:   #232220;
    --line:      #2f2d29;
    --line-soft: #292723;
    --ink:       #edece8;
    --ink-2:     #b3afa6;
    --ink-3:     #8b867c;
    --link:      #edece8;
    --focus:     #524e46;
    --easy-fg:  #7fc48c;  --easy-bg:  #1c2a20;
    --med-fg:   #d7a94a;  --med-bg:   #2b2416;
    --hard-fg:  #de7d76;  --hard-bg:  #2c1e1c;
    --freq:     #8c867a;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg:#fbfbfa;--panel:#ffffff;--panel-2:#f4f3f0;--line:#e6e4df;--line-soft:#eeece8;
  --ink:#22201c;--ink-2:#5f5c56;--ink-3:#857f75;--link:#22201c;--focus:#a9a498;
  --easy-fg:#3a7d44;--easy-bg:#eef3ec;--med-fg:#9a6a00;--med-bg:#f7f0dd;--hard-fg:#a33a34;--hard-bg:#f6e9e7;--freq:#7c766a;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:#171614;--panel:#1d1c19;--panel-2:#232220;--line:#2f2d29;--line-soft:#292723;
  --ink:#edece8;--ink-2:#b3afa6;--ink-3:#8b867c;--link:#edece8;--focus:#524e46;
  --easy-fg:#7fc48c;--easy-bg:#1c2a20;--med-fg:#d7a94a;--med-bg:#2b2416;--hard-fg:#de7d76;--hard-bg:#2c1e1c;--freq:#8c867a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
::selection { background: color-mix(in srgb, var(--ink) 14%, transparent); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad); }

/* ---------- Header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.2) blur(8px);
}
.site-head .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: baseline; gap: 10px; font-weight: 600; letter-spacing: -.01em; font-size: 15px; }
.brand .dot { width: 7px; height: 7px; border-radius: 2px; background: var(--ink); transform: translateY(-1px); }
.brand small { color: var(--ink-3); font-weight: 400; font-size: 12px; font-family: var(--mono); letter-spacing: 0; }
.head-spacer { flex: 1; }
.ghost-link { color: var(--ink-2); font-size: 13.5px; padding: 7px 11px; border-radius: var(--radius-sm); transition: color .15s, background .15s; }
.ghost-link:hover { color: var(--ink); background: var(--panel-2); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-2); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--focus); }
.theme-toggle:active { transform: scale(.96); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ---------- Hero / search ---------- */
.hero { padding: clamp(36px, 7vw, 72px) 0 clamp(18px, 3vw, 30px); }
.hero h1 {
  margin: 0 0 12px; font-family: var(--serif); font-weight: 500;
  font-size: clamp(30px, 5.2vw, 52px); line-height: 1.04; letter-spacing: -.02em;
  max-width: 18ch;
}
.hero p { margin: 0; color: var(--ink-2); max-width: 60ch; font-size: clamp(14.5px, 1.4vw, 16.5px); }
.hero p strong { color: var(--ink); font-weight: 600; }
.back-link { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-weight: 550; border-bottom: 1px solid var(--focus); padding-bottom: 1px; transition: gap .15s; }
.back-link:hover { gap: 10px; }
.back-link svg { width: 16px; height: 16px; }

.stat-row { display: flex; gap: clamp(20px, 3vw, 40px); margin-top: clamp(20px, 3vw, 30px); flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: clamp(20px, 2.4vw, 26px); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat span { color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 500; }

.searchbar { position: relative; margin: clamp(26px, 3.5vw, 40px) 0 0; }
.searchbar svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.searchbar input {
  width: 100%; height: 52px; padding: 0 48px; font-size: 15.5px; font-family: var(--sans);
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.searchbar input::placeholder { color: var(--ink-3); }
.searchbar input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.searchbar kbd {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font: 500 11px/1 var(--mono); color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; background: var(--bg);
}
.result-count {
  color: var(--ink-3); font-size: 11.5px; margin: 18px 2px 0;
  text-transform: uppercase; letter-spacing: .07em; font-weight: 500; font-family: var(--mono);
}

/* ---------- Company grid ---------- *
 * Reads as one bordered ledger, not floating cards: shared thin frame,
 * inner hairlines, flat hover. */
.grid {
  display: grid; margin: 18px 0 clamp(56px, 8vw, 100px);
  grid-template-columns: repeat(auto-fill, minmax(clamp(280px, 24vw, 360px), 1fr));
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); overflow: hidden;
}
.card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; min-width: 0;
  border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  transition: background .14s;
}
.card:hover { background: var(--panel-2); }
.logo {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center; overflow: hidden;
  font-family: var(--mono); font-weight: 600; font-size: 13px; color: #fff; letter-spacing: -.03em;
  border: 1px solid var(--line-soft);
}
.logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.card-body { min-width: 0; flex: 1; }
.card-name { font-weight: 550; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.card-meta {
  display: flex; align-items: center; gap: 9px; margin-top: 5px;
  font-size: 12px; color: var(--ink-2); font-family: var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
}
.card-meta .n { color: var(--ink); font-weight: 600; }
.card-meta .lbl { color: var(--ink-3); }
.card-diff { color: var(--ink-2); }
.card-meta .sep { width: 1px; height: 10px; background: var(--line); flex: 0 0 auto; }
.card-diff { display: inline-flex; align-items: center; gap: 4px; }
.card-diff i { width: 5px; height: 5px; border-radius: 50%; flex: 0 0 auto; }
.card-diff .de { background: var(--easy-fg); }
.card-diff .dm { background: var(--med-fg); }
.card-diff .dh { background: var(--hard-fg); }
.chev { color: var(--ink-3); flex: 0 0 auto; width: 15px; height: 15px; transition: color .14s, transform .14s; }
.card:hover .chev { color: var(--ink); transform: translateX(2px); }

.empty { text-align: center; color: var(--ink-3); padding: 72px 0; font-family: var(--mono); font-size: 13.5px; }

/* ---------- Company page ---------- */
.crumb {
  display: flex; align-items: center; gap: 9px; color: var(--ink-3);
  font-size: 12.5px; padding: clamp(20px, 3vw, 32px) 0 0; font-family: var(--mono);
}
.crumb a { transition: color .15s; }
.crumb a:hover { color: var(--ink); }
.crumb span { color: var(--line); }
.co-head { display: flex; align-items: center; gap: 18px; padding: 18px 0 6px; }
.co-head .logo { width: 54px; height: 54px; border-radius: 12px; font-size: 20px; }
.co-head h1 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: clamp(26px, 4vw, 40px); letter-spacing: -.02em; line-height: 1.08; }
.co-head .sub { color: var(--ink-3); font-size: 12.5px; margin-top: 5px; font-family: var(--mono); }

.tabs { display: flex; gap: 2px; margin: clamp(22px, 3vw, 34px) 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--ink-2); font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 11px 14px; border-bottom: 2px solid transparent; white-space: nowrap;
  margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab .badge { color: var(--ink-3); font-size: 11px; margin-left: 7px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .badge { color: var(--ink-2); }

.controls { display: flex; gap: 12px; align-items: center; margin: clamp(16px, 2.2vw, 22px) 0 0; flex-wrap: wrap; }
.controls .searchbar { margin: 0; flex: 1; min-width: 240px; }
.controls .searchbar input { height: 44px; }
.filter-group { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.filter-group button {
  appearance: none; border: 0; background: none; color: var(--ink-2);
  font: inherit; font-size: 12.5px; font-weight: 500; padding: 10px 15px; cursor: pointer;
  border-left: 1px solid var(--line); transition: background .13s, color .13s;
}
.filter-group button:first-child { border-left: 0; }
.filter-group button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }
.filter-group button:hover:not([aria-pressed="true"]) { background: var(--panel-2); color: var(--ink); }

/* ---------- Problem table ---------- */
.table-wrap {
  overflow-x: auto; margin: 16px 0 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
table.problems { width: 100%; border-collapse: collapse; min-width: 680px; }
.problems thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); background: var(--panel);
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; cursor: pointer; user-select: none; font-family: var(--mono);
}
.problems thead th.sortable:hover { color: var(--ink); }
.problems thead th .arrow {
  width: 13px; height: 13px; margin-left: 5px; vertical-align: -2px;
  opacity: 0; transition: opacity .13s, transform .13s;
}
.problems thead th.sortable:hover .arrow { opacity: .4; }
.problems thead th[data-dir] { color: var(--ink); }
.problems thead th[data-dir] .arrow { opacity: 1; }
.problems thead th[data-dir="asc"] .arrow { transform: rotate(180deg); }
.problems tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.problems tbody tr:last-child td { border-bottom: 0; }
.problems tbody tr { transition: background .12s; }
.problems tbody tr:hover { background: var(--panel-2); }
.col-idx { color: var(--ink-3); font-variant-numeric: tabular-nums; width: 48px; font-family: var(--mono); font-size: 12.5px; }
.p-title { font-weight: 500; letter-spacing: -.005em; }
.p-title a { display: inline-flex; align-items: center; gap: 8px; transition: color .13s; }
.p-title a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--focus); }
.ext { width: 13px; height: 13px; opacity: 0; color: var(--ink-3); transition: opacity .13s; flex: 0 0 auto; }
.p-title a:hover .ext { opacity: 1; }
.topics { color: var(--ink-3); font-size: 12px; margin-top: 3px; }

/* Difficulty as muted pastel pill — restrained, editorial */
.diff {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; font-family: var(--mono);
}
.diff.EASY   { color: var(--easy-fg); background: var(--easy-bg); }
.diff.MEDIUM { color: var(--med-fg);  background: var(--med-bg); }
.diff.HARD   { color: var(--hard-fg); background: var(--hard-bg); }

.freq-cell { width: 148px; }
.freq { display: flex; align-items: center; gap: 10px; }
.freq .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; min-width: 50px; }
.freq .bar > i { display: block; height: 100%; background: var(--freq); border-radius: 2px; }
.freq .val { font-size: 12px; color: var(--ink-2); font-family: var(--mono); font-variant-numeric: tabular-nums; width: 32px; text-align: right; }
.acc { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }

.skeleton { color: var(--ink-3); padding: 52px 0; text-align: center; font-family: var(--mono); font-size: 13px; }
.skeleton a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Pagination ---------- */
.pager {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 18px 0 0;
}
.pager-info { color: var(--ink-2); font-size: 12.5px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pager-info b { color: var(--ink); font-weight: 600; }
.pager-controls { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.pg {
  appearance: none; min-width: 34px; height: 34px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  font: 500 13px/1 var(--mono); font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background .13s, color .13s, border-color .13s;
}
.pg:hover:not(:disabled):not([aria-current="true"]) { background: var(--panel-2); color: var(--ink); border-color: var(--focus); }
.pg[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); cursor: default; }
.pg:disabled { opacity: .4; cursor: not-allowed; }
.pg svg { width: 15px; height: 15px; }
.pg-gap { color: var(--ink-3); padding: 0 2px; font-family: var(--mono); user-select: none; align-self: center; }
.pg-edge { padding: 0 11px; }
@media (max-width: 520px) {
  .pager-controls { margin-left: 0; width: 100%; justify-content: space-between; }
  .pg-edge span { display: none; }   /* icon-only Prev/Next on small screens */
}

/* ---------- Notes (bottom explainer) ---------- */
.notes {
  margin: clamp(44px, 7vw, 72px) 0 clamp(48px, 8vw, 90px);
  max-width: 68ch;
}
.notes h2 {
  margin: 0 0 12px; font-family: var(--serif); font-weight: 500;
  font-size: clamp(19px, 2.4vw, 23px); letter-spacing: -.01em; color: var(--ink);
}
.notes p { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; line-height: 1.65; }
.notes p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.site-foot {
  border-top: 1px solid var(--line); margin-top: 40px;
  padding: 28px 0; color: var(--ink-3); font-size: 12.5px; font-family: var(--mono);
}
.site-foot .wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-foot a { color: var(--ink-2); transition: color .15s; }
.site-foot a:hover { color: var(--ink); }
.site-foot .head-spacer { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 15px 16px; }
  .co-head .logo { width: 46px; height: 46px; border-radius: 10px; font-size: 17px; }
  .controls { gap: 10px; }
  .controls .filter-group { width: 100%; }
  .controls .filter-group button { flex: 1; }
  .stat-row { gap: 24px; }
}
@media (max-width: 420px) {
  .brand small { display: none; }
}

/* Give the ledger its right/bottom edge back (cards paint their own inner
 * hairlines; the outer frame provides the perimeter). */
@media (min-width: 641px) {
  /* Nothing extra — auto-fill columns share edges cleanly under overflow:hidden. */
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
