/* App shell, controls and dialogs. */
.skip { position: absolute; left: 16px; top: -48px; padding: 8px 12px; background: var(--ink); color: var(--on-ink); border-radius: var(--r-control); z-index: 10; }
.skip:focus { top: 16px; }

.i { display: inline-block; flex: none; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
.logo-img { width: 16px; height: 16px; flex: none; }

.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }

/* ---- Sidebar ---- */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 24px 16px 16px; background: var(--surface); border-right: 1px solid var(--rule); overflow-y: auto; }
.brand { padding: 0 8px; font: 500 22px/28px var(--serif); letter-spacing: -0.01em; }
.group { display: flex; flex-direction: column; gap: 2px; }
.group-label { margin: 0 8px 8px; font: 400 13px/16px var(--sans); color: var(--ink-3); }
.nav-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: none; text-align: left; color: var(--ink-2); cursor: pointer; transition: background-color 140ms var(--ease), color 140ms var(--ease); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--surface-2); border-color: var(--rule); color: var(--ink); }
.nav-item .label { flex: 1; }
.count { font: 400 12px/16px var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.status { font: 400 12px/16px var(--mono); color: var(--ink-3); }
.status.is-on { color: var(--ink-2); }
.side-foot { margin-top: auto; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px; border: 1px solid var(--rule-strong); border-radius: var(--r-control); background: transparent; color: var(--ink); cursor: pointer; font-weight: 500; transition: background-color 140ms var(--ease), transform 90ms var(--ease), border-color 140ms var(--ease); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.danger { color: var(--accent); border-color: transparent; }
.btn.quiet { border-color: transparent; }
.btn.block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-control); background: none; color: var(--ink-2); cursor: pointer; transition: background-color 140ms var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---- Main ---- */
main { min-width: 0; padding: 32px 48px 64px; }
.main-inner { max-width: 1120px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 40px; }
.top h1 { margin: 0; font: 500 15px/24px var(--sans); color: var(--ink-2); }
.top .seg { width: auto; margin-left: auto; }
.top .seg .tab { flex: none; padding: 0 16px; }
.search { position: relative; width: 280px; }
.search .i { position: absolute; left: 12px; top: 10px; color: var(--ink-3); pointer-events: none; }
.search input[type=search] { padding-left: 36px; }

.blank { padding: 96px 0; max-width: 440px; }
.blank h2 { margin: 0 0 8px; font: 400 36px/40px var(--serif); }
.blank p { margin: 0 0 24px; color: var(--ink-2); }

/* ---- Fields ---- */
input[type=text], input[type=search], input[type=date], input[type=password], select, textarea { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: var(--r-control); background: var(--bg); transition: border-color 140ms var(--ease); }
textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 24px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .fieldset > legend { font-size: 13px; line-height: 16px; color: var(--ink-2); padding: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.hint { margin: 0; font-size: 13px; line-height: 20px; color: var(--ink-3); }
.hint code { font: 400 12px/16px var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }

.rating { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 8px; }
.rating label { position: relative; }
.rating input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.rating span { display: flex; align-items: center; justify-content: center; height: 36px; border: 1px solid var(--rule-strong); border-radius: 6px; font: 400 13px/16px var(--mono); color: var(--ink-2); transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.rating label:hover span { background: var(--surface-2); }
.rating input:checked + span { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.rating input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Dialogs ---- */
dialog { width: min(640px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--rule-strong); border-radius: var(--r-panel); background: var(--surface); color: var(--ink); overflow: hidden; }
dialog[open] { display: block; }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(20, 18, 15, 0.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 16px 24px; border-bottom: 1px solid var(--rule); }
.dlg-head h2 { margin: 0; font: 400 24px/32px var(--serif); }
.dlg-body { display: flex; flex-direction: column; gap: 16px; padding: 24px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--rule); }
.dlg-foot .spacer { margin-right: auto; }

.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--rule); border-radius: 10px; background: var(--bg); }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 32px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--ink-2); cursor: pointer; transition: background-color 140ms var(--ease), color 140ms var(--ease); }
.tab:hover { color: var(--ink); }
.tab[aria-selected=true] { background: var(--surface); border-color: var(--rule); color: var(--ink); }

.results { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-control); }
.results:empty { display: none; }
.results-head { position: sticky; top: 0; padding: 8px 12px; background: var(--surface-2); font: 400 12px/16px var(--mono); color: var(--ink-3); border-top: 1px solid var(--rule); }
.results li:first-child.results-head { border-top: 0; }
.result { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; padding: 8px 12px; border: 0; border-top: 1px solid var(--rule); background: none; text-align: left; cursor: pointer; transition: background-color 140ms var(--ease); }
li:first-child > .result { border-top: 0; }
.result:hover { background: var(--surface-2); }
.result .thumb { width: 40px; height: 40px; border-radius: 4px; background: var(--surface-2); object-fit: cover; box-shadow: inset 0 0 0 1px var(--rule); }
.result .t { display: block; font-weight: 500; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .s { display: block; font-size: 13px; line-height: 20px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick { display: flex; gap: 8px; }
.msg { min-height: 0; margin: 0; font-size: 13px; line-height: 20px; color: var(--ink-2); }
.msg.is-error { color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 8px 16px; border-radius: var(--r-control); background: var(--ink); color: var(--on-ink); font-size: 14px; line-height: 20px; opacity: 0; pointer-events: none; transition: opacity 160ms var(--ease); z-index: 20; }
.toast.is-on { opacity: 1; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); gap: 16px; }
  .side #cats { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side #cats .nav-item { width: auto; }
  .side .group.sources { display: none; }
  .side-foot { margin-top: 0; flex-direction: row; gap: 8px; }
  .side-foot .nav-item { width: auto; flex: 1; }
  main { padding: 24px 16px 48px; }
  .top { flex-direction: column; align-items: stretch; gap: 16px; padding-bottom: 24px; }
  .search { width: 100%; }
  .btn, .nav-item, .tab, .rating span, input[type=text], input[type=search], input[type=date], input[type=password], select { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .search .i { top: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .tabs { flex-wrap: wrap; }
  .tab { flex: 1 1 40%; }
}

/* ---- Views, friends, admin, sign-in ---- */
.views { gap: 2px; }
.who { margin: 0 8px 8px; font: 400 12px/16px var(--mono); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice { margin: 0 0 24px; padding: 12px 16px; border: 1px solid var(--rule-strong); border-radius: var(--r-card); color: var(--ink-2); font-size: 14px; }
.feed-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.feed-bar .field { width: 240px; }
.feed-bar .meta { margin: 0; }
.code.by { color: var(--ink); font-family: var(--sans); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-sec { margin: 0 0 48px; }
.a-sec h2 { margin: 0 0 16px; font: 400 28px/32px var(--serif); }
.a-list { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--rule); }
.a-row, .a-entry { display: grid; gap: 4px 16px; align-items: center; padding: 12px 8px; border-top: 1px solid var(--rule); }
.a-row { grid-template-columns: 160px minmax(0, 1fr); }
.a-row .a-acts { grid-column: 1 / -1; justify-content: flex-start; margin-left: -12px; }
.a-row .a-acts:empty { display: none; }
.a-entry { grid-template-columns: 112px minmax(0, 1fr) 150px 56px auto; }
.a-entry.is-hidden { opacity: 0.55; }
.a-name b, .a-title b { font-weight: 500; }
.a-name small, .a-title small { font: 400 12px/16px var(--mono); color: var(--ink-3); margin-left: 4px; }
.a-name small.bad, .a-title small.bad { color: var(--accent); }
.a-title { min-width: 0; overflow-wrap: anywhere; }
.a-title em { display: block; font: 400 15px/20px var(--serif); color: var(--ink-2); margin-top: 2px; }
.a-by { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-meta { font: 400 13px/20px var(--mono); color: var(--ink-3); }
.a-score { text-align: right; font: 500 15px/24px var(--mono); }
.a-score small { color: var(--ink-3); font-size: 11px; font-weight: 400; }
.a-acts { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.a-acts .btn { height: 32px; padding: 0 12px; }
.a-invite { display: flex; gap: 8px; margin-bottom: 16px; }
.a-invite input { flex: 1; }
.a-link { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 16px; padding: 16px; border: 1px solid var(--rule-strong); border-radius: var(--r-card); background: var(--surface); }
.a-link .hint { grid-column: 1 / -1; }
.a-filter { width: 240px; margin-bottom: 16px; }

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth { width: min(400px, 100%); display: flex; flex-direction: column; gap: 16px; }
.auth h1 { margin: 0; font: 400 36px/40px var(--serif); }
.auth form { display: flex; flex-direction: column; gap: 16px; }
.auth .brand { padding: 0; }

@media (max-width: 900px) {
  .a-row, .a-entry { grid-template-columns: minmax(0, 1fr) auto; }
  .a-row .a-meta, .a-entry .a-meta { grid-column: 1 / -1; }
  .a-acts { grid-column: 1 / -1; justify-content: flex-start; }
  .a-link, .a-invite { display: flex; flex-direction: column; }
  .feed-bar { flex-direction: column; align-items: stretch; }
  .feed-bar .field, .a-filter { width: 100%; }
  .side .group.views { flex-direction: row; }
  .side .group.views .nav-item { width: auto; flex: 1; }
}

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
