:root {
  --bg: rgba(24, 26, 29, 0.78); --bg2: rgba(40, 43, 47, 0.92); --line: rgba(255, 255, 255, 0.10);
  --fg: #eceae4; --mut: #a7a49c; --acc: #e1c48a; --acc2: #2f8cff; --r: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; color: var(--fg); font-size: 13px; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
button { font: inherit; color: var(--fg); background: rgba(255,255,255,0.07); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; cursor: pointer; white-space: nowrap; }
button:hover { background: rgba(255,255,255,0.14); }
button.on { background: rgba(225,196,138,0.22); border-color: rgba(225,196,138,0.55); color: #fff; }
button.primary { background: var(--acc); color: #1d1b17; border-color: var(--acc); font-weight: 600; }
button:disabled { opacity: 0.4; cursor: default; }
input[type=range] { width: 100%; accent-color: var(--acc); }
input[type=number], input[type=text], select { font: inherit; color: var(--fg); background: rgba(0,0,0,0.35); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; }
input[type=color] { width: 38px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: none; padding: 1px; }
select option { background: #26282b; }
.hidden { display: none !important; }
.ui { user-select: none; -webkit-user-select: none; }

#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, #2b2d31 0%, #141516 70%); z-index: 50; transition: opacity .5s; }
.lbox { width: min(440px, 86vw); text-align: center; }
.ltitle { font-size: 30px; letter-spacing: .5px; font-weight: 300; }
.lsub { color: var(--mut); margin: 6px 0 22px; }
.bar { height: 4px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; }
#lbar { height: 100%; width: 0; background: var(--acc); transition: width .2s; }
#ltext { margin-top: 12px; color: var(--mut); min-height: 1.4em; }

#top { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; z-index: 10; pointer-events: none; flex-wrap: wrap; }
#top > * { pointer-events: auto; }
#top .spacer { flex: 1; pointer-events: none; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; backdrop-filter: blur(8px); }
.seg button { border: none; background: none; border-radius: 7px; padding: 6px 10px; }
.seg button.on { background: rgba(225,196,138,0.25); }
.seg.col { flex-direction: column; width: 100%; }
#top > button, .dd > button { background: var(--bg); backdrop-filter: blur(8px); }
.dd { position: relative; }
.dd .menu { position: absolute; top: 36px; left: 0; min-width: 230px; max-height: 70vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 6px; display: none; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.dd.open .menu { display: block; }
.menu button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 7px 9px; }
.menu button:hover { background: rgba(255,255,255,0.1); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 0; }
.menu .mh { color: var(--mut); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 6px 9px 2px; }

.pop { position: fixed; top: 54px; right: 10px; width: 330px; max-height: calc(100vh - 120px); overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; z-index: 12; box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.pop h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.pop label { display: block; margin: 9px 0; color: var(--mut); }
.pop label span { float: right; color: var(--fg); }
.pop label.chk, label.chk { color: var(--fg); display: flex; gap: 8px; align-items: center; }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.moods button { flex: 1; }
.hint { color: var(--mut); font-size: 12px; line-height: 1.45; }

#panel { position: fixed; top: 54px; right: 10px; bottom: 54px; width: 370px; background: var(--bg); backdrop-filter: blur(12px); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; z-index: 9; transition: transform .25s, opacity .25s; }
#panel.collapsed { transform: translateX(calc(100% + 20px)); opacity: 0; pointer-events: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: none; padding: 6px 8px; border-radius: 6px; color: var(--mut); }
.tabs button.on { color: #fff; background: rgba(255,255,255,0.10); }
.pbody { flex: 1; overflow: auto; padding: 10px 12px 16px; }
.pbody h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--mut); font-weight: 600; }
.pbody h4:first-child { margin-top: 2px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 8px; margin: 4px 0 8px; }
.kv div:nth-child(odd) { color: var(--mut); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 4px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-align: left; white-space: normal; }
.tile:hover { border-color: rgba(225,196,138,0.6); }
.tile.sel { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc) inset; }
.tile img, .tile .sw { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; display: block; background: #444; }
.tile span { font-size: 11px; line-height: 1.25; color: var(--fg); }
.field { display: grid; grid-template-columns: 1fr 1.3fr; align-items: center; gap: 6px; margin: 6px 0; }
.field > span { color: var(--mut); }
.field input[type=number] { width: 100%; }
.field .inl { display: flex; gap: 6px; align-items: center; }
.scope { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.scope button { padding: 5px 8px; font-size: 12px; }
.box { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.list button { display: flex; width: 100%; text-align: left; justify-content: space-between; margin: 3px 0; }
.mut { color: var(--mut); }
.warn { color: #f0b37e; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 9px; background: rgba(255,255,255,0.1); font-size: 11px; margin-left: 4px; }

#bottom { position: fixed; left: 10px; bottom: 10px; right: 390px; display: flex; gap: 6px; align-items: center; z-index: 9; }
#bottom > button { background: var(--bg); backdrop-filter: blur(8px); font-size: 15px; padding: 5px 11px; }
#status { background: var(--bg); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
body.nopanel #bottom { right: 10px; }
#hintbar { position: fixed; left: 50%; bottom: 58px; transform: translateX(-50%); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; z-index: 9; color: var(--fg); }
#cross { position: fixed; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; pointer-events: none; z-index: 8; }
#cross::before, #cross::after { content: ''; position: absolute; background: rgba(255,255,255,0.85); box-shadow: 0 0 2px rgba(0,0,0,.8); }
#cross::before { left: 8px; top: 2px; width: 2px; height: 14px; }
#cross::after { top: 8px; left: 2px; height: 2px; width: 14px; }
#toast { position: fixed; left: 50%; top: 60px; transform: translateX(-50%); background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; z-index: 30; opacity: 0; transition: opacity .3s; pointer-events: none; }
#toast.show { opacity: 1; }

#help { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 40; display: flex; align-items: center; justify-content: center; }
.hbox { width: min(880px, 92vw); max-height: 88vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; }
.hbox h2 { margin: 0 0 8px; font-weight: 500; }
.hbox .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.hbox ul { padding-left: 18px; margin: 6px 0; line-height: 1.7; }
.hbox h4 { margin: 10px 0 2px; color: var(--acc); }

#touch { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
#joy { position: absolute; left: 26px; bottom: 80px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); pointer-events: auto; touch-action: none; }
#joy .knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.35); }
#lookpad { position: absolute; right: 0; top: 60px; bottom: 60px; width: 55%; pointer-events: auto; touch-action: none; }
.tbtns { position: absolute; right: 18px; bottom: 80px; display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
.tbtns button { width: 64px; height: 44px; background: var(--bg); }

@media (max-width: 760px) {
  #panel { left: 8px; right: 8px; width: auto; top: auto; height: 46vh; bottom: 52px; }
  #bottom { right: 10px; }
  #top { gap: 5px; }
  #top > button, .dd > button { padding: 5px 7px; }
  .pop { left: 8px; right: 8px; width: auto; }
}

body.photo #cross, body.photo #hintbar, body.photo #touch { display: none !important; }
