:root {
  --accent: #f26a21; --accent2: #ff8a3d;
  --panel: rgba(22, 26, 33, 0.86); --panel2: rgba(34, 39, 48, 0.92); --line: rgba(255,255,255,0.09);
  --text: #eef1f5; --muted: #9aa4b2; --ok: #3fbf7f; --bad: #e5484d;
  --cat-h: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1116; color: var(--text); font: 14px/1.35 Manrope, system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.hidden { display: none !important; }

/* top bar */
#top { position: absolute; left: 0; right: 0; top: 0; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: linear-gradient(180deg, rgba(14,17,22,.92), rgba(14,17,22,.75)); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); z-index: 5; overflow-x: auto; scrollbar-width: none; }
#top::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #c9401a); display: grid; place-items: center; font-size: 20px; color: #fff; box-shadow: 0 4px 14px rgba(242,106,33,.35); }
.brand b { display: block; font-size: 16px; letter-spacing: .2px; }
.brand small { color: var(--muted); font-size: 11px; }
#projName { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; width: 150px; font-weight: 600; }
#projName:hover, #projName:focus { border-color: var(--line); background: rgba(255,255,255,.04); outline: none; }
.grp { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 3px; white-space: nowrap; }
.grp button, .grp a { background: transparent; border: 0; border-radius: 7px; padding: 6px 9px; cursor: pointer; color: var(--text); text-decoration: none; }
.grp button:hover { background: rgba(255,255,255,.08); }
.grp button.on { background: rgba(242,106,33,.22); color: #ffd2b8; }
.grp button.primary { background: var(--accent); color: #fff; font-weight: 700; }
.grp button.primary:hover { background: var(--accent2); }
.grp button.user { font-weight: 600; }
.time input { width: 110px; accent-color: var(--accent); }
#timeLbl { width: 42px; color: var(--muted); font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

/* tools */
#tools { position: absolute; left: 12px; top: 68px; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(10px); z-index: 4; }
#tools button { width: 64px; height: 54px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
#tools button i { font-style: normal; font-size: 19px; line-height: 1; }
#tools button span { font-size: 10.5px; color: var(--muted); }
#tools button:hover { background: rgba(255,255,255,.07); }
#tools button.on { background: linear-gradient(135deg, var(--accent), #d2501b); }
#tools button.on span { color: #fff; }

#hint { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); padding: 7px 14px; border-radius: 999px; font-size: 13px; color: #dfe5ec; z-index: 3; pointer-events: none; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
#hint:empty { display: none; }

/* selection panel */
#sel { position: absolute; right: 12px; top: 68px; width: 260px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; z-index: 4; backdrop-filter: blur(10px); }
.selName { font-weight: 700; margin-bottom: 4px; }
.selMeta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.selBtns { display: flex; gap: 6px; flex-wrap: wrap; }
.selBtns button, .selBtns a { background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--text); text-decoration: none; font-size: 13px; }
.selBtns a { background: rgba(242,106,33,.18); border-color: rgba(242,106,33,.4); }
.selBtns button:hover { background: rgba(255,255,255,.14); }

/* catalog */
#catalog { position: absolute; left: 88px; right: 12px; bottom: 12px; height: var(--cat-h); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(12px); z-index: 4; display: flex; flex-direction: column; overflow: hidden; transition: height .2s; }
#catalog.min { height: 46px; }
#catTabs { display: flex; gap: 2px; padding: 6px 44px 0 8px; overflow-x: auto; scrollbar-width: thin; flex: none; }
#catTabs button { background: transparent; border: 0; padding: 7px 11px; border-radius: 9px 9px 0 0; cursor: pointer; white-space: nowrap; color: var(--muted); font-weight: 600; }
#catTabs button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.catBar { display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: var(--panel2); flex: none; }
#subTabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
#subTabs button { background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; cursor: pointer; white-space: nowrap; font-size: 12.5px; }
#subTabs button.on { background: rgba(242,106,33,.25); border-color: rgba(242,106,33,.6); }
#search { width: 220px; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; outline: none; }
#search:focus { border-color: var(--accent); }
#grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; padding: 8px; align-content: start; background: var(--panel2); }
.it { position: relative; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 11px; padding: 5px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.it:hover { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.09); }
.it.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.it .th { aspect-ratio: 1; border-radius: 8px; background: radial-gradient(circle at 50% 35%, #3a414d, #232830); overflow: hidden; display: grid; place-items: center; }
.it .th img { width: 100%; height: 100%; object-fit: cover; }
.it .nm { font-size: 11px; line-height: 1.2; color: #d5dbe3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 26px; }
.it .pr { font-size: 11px; color: var(--accent2); font-weight: 700; }
.it .badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 800; padding: 2px 5px; border-radius: 5px; letter-spacing: .3px; }
#catToggle { position: absolute; right: 8px; top: 6px; width: 30px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.06); cursor: pointer; }
#catalog.min #catToggle { transform: rotate(180deg); }
#catalog.min .catBar, #catalog.min #grid { display: none; }

#toast { position: absolute; left: 50%; bottom: calc(var(--cat-h) + 26px); transform: translateX(-50%) translateY(20px); background: #222832; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; z-index: 20; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { border-color: var(--bad); }

/* modal */
#modal { position: absolute; inset: 0; background: rgba(6,8,12,.6); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 30; padding: 16px; }
#modal .card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #181c23; border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
#modal h2 { margin: 0 0 6px; font-size: 22px; }
#modal p { color: var(--muted); margin: 6px 0 14px; }
#modal .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
#modal .btn { border: 1px solid var(--line); background: rgba(255,255,255,.06); padding: 10px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
#modal .btn:hover { background: rgba(255,255,255,.12); }
#modal .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
#modal .btn.primary:hover { background: var(--accent2); }
#modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
#modal input { width: 100%; background: rgba(0,0,0,.3); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; outline: none; }
#modal input:focus { border-color: var(--accent); }
#modal .note { font-size: 12px; color: #c9b38a; background: rgba(201,179,138,.08); border: 1px solid rgba(201,179,138,.25); padding: 8px 10px; border-radius: 8px; margin-top: 12px; }
.hero { text-align: center; }
.hero .logo { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 18px; background: linear-gradient(135deg, var(--accent), #c9401a); display: grid; place-items: center; font-size: 36px; color: #fff; }
.hero .row { justify-content: center; }
.plist { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.plist .p { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; }
.plist .p b { flex: 1; }
.plist .p small { color: var(--muted); }
table.bom { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.bom th, table.bom td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.bom td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.bom tr.h td { color: var(--accent2); font-weight: 700; padding-top: 12px; }
table.bom a { color: var(--accent2); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.keys kbd { background: rgba(255,255,255,.1); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-family: inherit; font-size: 12px; white-space: nowrap; }

#loading { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: #0e1116; z-index: 50; color: var(--muted); }
.spin { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255,255,255,.1); border-top-color: var(--accent); animation: sp 0.9s linear infinite; margin: 0 auto 10px; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  :root { --cat-h: 210px; }
  #top { height: 50px; gap: 6px; padding: 0 8px; }
  .brand div, #projName, .time input, #timeLbl, #bBom span { display: none; }
  #tools { flex-direction: row; left: 8px; right: 8px; top: 58px; overflow-x: auto; padding: 4px; }
  #tools button { width: 52px; height: 46px; flex: none; }
  #hint { top: 116px; font-size: 12px; }
  #catalog { left: 8px; right: 8px; bottom: 8px; }
  #search { width: 120px; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
  #sel { top: auto; bottom: calc(var(--cat-h) + 20px); right: 8px; left: 8px; width: auto; }
}
