:root {
  --bg: #121214; --panel: #1c1c20; --panel2: #24242a; --ink: #ececf0; --muted: #9b9ba6; --line: #303038;
  --accent: #7aa2ff; --accent-ink: #0d1530; --ok: #52c78a; --warn: #f0a85a; --bad: #ff7d72;
  --r: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, Roboto, "Segoe UI", sans-serif; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 16px; }
[hidden] { display: none !important; }

header#top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(18,18,20,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--ink); }
header nav { margin-left: auto; display: flex; gap: 4px; }
header nav a { color: var(--muted); padding: 8px 12px; border-radius: 20px; }
header nav a.on { color: var(--ink); background: var(--panel2); }

main { max-width: 760px; margin: 0 auto; }

input, textarea, select, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=number], input[type=url], input[type=date], input[type=search], textarea, select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
  min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; }

.searchbar { padding: 12px 14px 6px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.searchbar textarea { min-height: 48px; height: 48px; }
.toolbar { display: flex; gap: 8px; padding: 4px 14px 10px; flex-wrap: wrap; align-items: center; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.activefilm { margin: 0 14px 10px; padding: 8px 12px; border-radius: 10px; background: #1d2740; display: flex; gap: 8px; align-items: center; }
.activefilm b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { margin: 0 14px 8px; font-size: 13px; color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 18px; padding: 6px 12px; min-height: 36px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chip.mini { min-height: 0; padding: 2px 9px; font-size: 12px; background: var(--panel2); }

.filters { margin: 0 14px 12px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.filters h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.filters h4:first-child { margin-top: 0; }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.switch input { width: 22px; height: 22px; }

.list { padding: 0 10px 40px; }
.item { display: block; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 12px 10px; margin: 0 4px 8px; position: relative; }
.item .t { font-weight: 600; padding-right: 48px; }
.item .a { color: var(--muted); font-size: 14px; }
.item .meta { margin-top: 6px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.item .sum { margin-top: 6px; font-size: 14px; color: #c9c9d2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .add { position: absolute; right: 8px; top: 8px; min-height: 40px; min-width: 40px; padding: 0; }
.item .add.in { color: var(--ok); }
.more { display: block; margin: 8px auto 20px; }

.detail { padding: 14px; }
.fname { font-size: 22px; font-weight: 700; word-break: break-word; line-height: 1.25; }
.copyrow { display: flex; gap: 8px; margin: 10px 0 4px; }
.copyrow button { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin: 12px 0; }
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.big { font-size: 26px; font-weight: 700; }
.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat div { background: var(--panel2); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.warnbox { background: #3a2a1a; color: #ffd2a6; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.stars button { font-size: 24px; min-width: 44px; background: transparent; border: none; color: var(--line); padding: 0; }
.stars button.on { color: #ffd166; }
.edited { color: var(--warn); font-size: 12px; }

.films .item .t { padding-right: 0; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.ftrack { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.ftrack .ops { display: flex; gap: 4px; }
.ftrack .ops button { min-width: 40px; padding: 0 8px; }
.used { color: var(--ok); }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2c2c34; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 50; }
#toast.show { opacity: 1; }
#toast.err { background: #4a2020; }

.login { padding: 40px 20px; max-width: 420px; margin: 0 auto; display: grid; gap: 12px; }
.login h1 { margin: 0 0 6px; }
