:root {
  --bg: #0b0d12;
  --panel: #11151c;
  --panel-2: #161b24;
  --line: #222a36;
  --text: #d7dde8;
  --muted: #7d8796;
  --honey: #f9b34c;
  --coral: #f78c6b;
  --violet: #c77dff;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --ui: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--ui); }
body { overflow: hidden; user-select: none; }
input, select, textarea, button { font: inherit; color: inherit; }
::selection { background: rgba(199, 125, 255, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #262f3d; border-radius: 6px; border: 2px solid var(--bg); }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.red { color: var(--red); }
.green { color: var(--green); }
.honey { color: var(--honey); }
.hidden { display: none !important; }

/* layout */
#app { display: grid; grid-template-columns: 220px 1fr; height: 100%; }
nav.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 10px; gap: 2px; }
.logo { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; padding: 4px 8px 16px; }
.logo .word { font: 700 22px/1 var(--mono); letter-spacing: 3px; background: linear-gradient(90deg, #ffd166, var(--coral), var(--violet), #ffd166); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 9s linear infinite; }
.logo small { grid-column: 1 / -1; display: block; font: 11px var(--mono); color: var(--muted); margin-top: 8px; }
@keyframes shimmer { to { background-position: 300% 0; } }

/* animated bear */
.bear { overflow: visible; }
.bear .bear-body { transform-origin: 32px 56px; animation: breathe 4s ease-in-out infinite; }
.bear .eyes { transform-origin: 32px 30px; animation: blink 5.5s infinite; }
.bear .ear { transform-box: fill-box; transform-origin: center; }
.bear .ear.l { animation: earl 7s ease-in-out infinite; }
.bear .ear.r { animation: earr 7s ease-in-out infinite 0.4s; }
body.busy .bear .bear-body { animation: bob .6s ease-in-out infinite alternate; }
@keyframes breathe { 50% { transform: scale(1.03); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes earl { 0%, 85%, 100% { transform: rotate(0); } 90% { transform: rotate(-14deg); } 95% { transform: rotate(6deg); } }
@keyframes earr { 0%, 85%, 100% { transform: rotate(0); } 90% { transform: rotate(14deg); } 95% { transform: rotate(-6deg); } }
@keyframes bob { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-3px) rotate(3deg); } }
nav.side button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav.side button:hover { background: var(--panel-2); color: var(--text); }
nav.side button.active { background: rgba(249, 179, 76, .1); color: var(--honey); }
nav.side button .k { margin-left: auto; font: 11px var(--mono); color: #4b5563; }
nav.side .badge { margin-left: auto; background: var(--violet); color: #12061f; font: 700 11px var(--mono); padding: 1px 7px; border-radius: 10px; }
nav.side .spacer { flex: 1; }

main { display: flex; flex-direction: column; min-width: 0; }
header.top { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: rgba(17, 21, 28, .6); }
header.top h1 { font: 600 16px var(--mono); margin: 0; flex: 1; }
.pill { font: 12px var(--mono); padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }
section.view { flex: 1; overflow: auto; padding: 20px 22px 40px; user-select: text; }

/* controls */
.btn { cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 7px 14px; font-weight: 600; }
.btn:hover { border-color: #334155; }
.btn.primary { background: var(--honey); color: #1a1205; border-color: var(--honey); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(239, 68, 68, .5); color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 2px rgba(199, 125, 255, .2); }
textarea { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }

/* cards */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h3 { margin: 0 0 12px; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: 1.5px; color: var(--honey); display: flex; justify-content: space-between; }
.card h3 .count { color: var(--muted); }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font: 13px var(--mono); }
.kv span:nth-child(odd) { color: var(--muted); }
.gauge { height: 6px; border-radius: 3px; background: #1e2530; overflow: hidden; margin-top: 4px; }
.gauge > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--honey)); }
.gauge.warn > div { background: var(--yellow); }
.gauge.crit > div { background: var(--red); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.list li .right { margin-left: auto; color: var(--muted); font: 12px var(--mono); white-space: nowrap; }
.empty { color: var(--muted); font-style: italic; font-size: 13px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid #191f29; vertical-align: middle; }
tr:hover td { background: rgba(255, 255, 255, .015); }
tr.overdue td { color: var(--red); }
tr.denied td { color: var(--red); }
td.actions { text-align: right; white-space: nowrap; }
.tag { display: inline-block; font: 11px var(--mono); padding: 1px 7px; border-radius: 10px; background: rgba(199, 125, 255, .12); color: var(--violet); margin-right: 4px; }
.prio { font: 600 11px var(--mono); padding: 1px 7px; border-radius: 10px; }
.prio.low { color: var(--muted); background: #1a202a; }
.prio.medium { color: var(--blue); background: rgba(59, 130, 246, .12); }
.prio.high { color: var(--honey); background: rgba(249, 179, 76, .12); }
.prio.urgent { color: #fff; background: var(--red); }
.status { font: 11px var(--mono); }
.pdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.bar { height: 8px; border-radius: 4px; background: #1e2530; overflow: hidden; min-width: 120px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--honey), var(--violet)); }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 240px; }
.col h4 { margin: 2px 4px 10px; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); display: flex; justify-content: space-between; }
.col.drag-over { border-color: var(--violet); background: rgba(199, 125, 255, .05); }
.kcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: grab; }
.kcard:hover { border-color: #334155; }
.kcard.overdue { border-left: 3px solid var(--red); }
.kcard .t { font-weight: 600; margin-bottom: 6px; }
.kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.kcard.dragging { opacity: .4; }

/* drop zone */
.drop { border: 2px dashed #2b3442; border-radius: 14px; padding: 28px; text-align: center; color: var(--muted); transition: all .15s; --wails-drop-target: drop; }
.drop.wails-drop-target-active, .drop.hover { border-color: var(--honey); color: var(--honey); background: rgba(249, 179, 76, .06); }
.drop b { display: block; font: 600 15px var(--mono); color: var(--text); margin-bottom: 6px; }

/* progress + notices */
#progress { position: fixed; right: 18px; bottom: 18px; width: 360px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.notice { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 8px; padding: 10px 12px; font-size: 13px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: in .2s ease-out; }
.notice.ok { border-left-color: var(--green); }
.notice.error { border-left-color: var(--red); }
.notice.warn { border-left-color: var(--yellow); }
.notice .bar { margin-top: 8px; }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }

.banner { padding: 9px 22px; font-size: 13px; background: rgba(234, 179, 8, .1); color: var(--yellow); border-bottom: 1px solid rgba(234, 179, 8, .3); }
.banner summary { cursor: pointer; }
.banner-detail { margin: 8px 0 2px; font: 12px/1.5 var(--mono, monospace); white-space: pre-wrap; color: var(--text); }
.banner.red { background: rgba(239, 68, 68, .1); color: var(--red); border-color: rgba(239, 68, 68, .3); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(5, 7, 10, .75); display: flex; align-items: center; justify-content: center; z-index: 30; backdrop-filter: blur(3px); }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(560px, 92vw); max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.modal h2 { margin: 0 0 16px; font: 600 16px var(--mono); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .full { grid-column: 1 / -1; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* lock / pairing screens */
.screen { position: fixed; inset: 0; background: radial-gradient(circle at 50% 30%, #161b26, var(--bg) 70%); display: flex; align-items: center; justify-content: center; z-index: 40; }
.screen .box { width: min(400px, 90vw); text-align: center; }
.screen img { width: 96px; height: 96px; margin-bottom: 12px; }
.screen h2 { font: 700 26px var(--mono); letter-spacing: 4px; margin: 0 0 4px; background: linear-gradient(90deg, #ffd166, var(--coral), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.screen p { color: var(--muted); margin: 0 0 20px; }
.screen input { width: 100%; margin-bottom: 10px; text-align: center; font-family: var(--mono); }
.screen .btn { width: 100%; padding: 10px; }
.screen .err { color: var(--red); min-height: 20px; margin-top: 10px; font-size: 13px; }
.screen pre { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: 12px var(--mono); white-space: pre-wrap; user-select: text; }

/* drop-zone mode */
body.dz { --wails-draggable: drag; background: transparent; }
body.dz #app { display: block; }
.dzwin { height: 100vh; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.dzwin .head { display: flex; align-items: center; gap: 8px; font: 700 13px var(--mono); }
.dzwin .head img { width: 22px; height: 22px; }
.dzwin .head .x { margin-left: auto; cursor: pointer; color: var(--muted); --wails-draggable: no-drag; padding: 0 4px; }
.dzwin select, .dzwin .drop, .dzwin .btn { --wails-draggable: no-drag; }
.dzwin .drop { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 14px; }
.dzwin .status { font: 12px var(--mono); color: var(--muted); min-height: 32px; }

/* live dashboard */
.counters { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.counter { all: unset; cursor: pointer; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; transition: border-color .2s, transform .2s; }
.counter:hover { border-color: #334155; transform: translateY(-1px); }
.counter .cv { font: 700 30px/1.1 var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.counter .cl { font-size: 12px; color: var(--muted); }
.counter.hot .cv { color: var(--violet); }
.counter.alert .cv { color: var(--red); }
.counter.bump { animation: bump .6s ease-out; }
@keyframes bump { 30% { transform: scale(1.05); border-color: var(--honey); box-shadow: 0 0 18px rgba(249, 179, 76, .25); } }
.card.wide { grid-column: span 2; }
@media (max-width: 760px) { .card.wide { grid-column: auto; } }
.charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.chart { background: var(--bg); border: 1px solid #1a212c; border-radius: 8px; padding: 8px 10px 6px; min-width: 0; }
.chart-head { display: flex; justify-content: space-between; font: 12px var(--mono); color: var(--muted); margin-bottom: 4px; }
.chart-head b { color: var(--text); font-weight: 600; white-space: nowrap; }
.chart-canvas { display: block; width: 100%; height: 74px; }
.netline { margin-top: 10px; font-size: 12px; color: var(--muted); }
.viz { display: block; width: 100%; height: 210px; }
.legend { display: flex; gap: 6px 12px; align-items: center; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.legend .lg { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: -6px; }
.legend .lg.up { background: var(--honey); }
.legend .lg.down { background: var(--blue); }
.legend .lg.off { background: #4b5563; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 250px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.feed li { display: grid; grid-template-columns: 62px 1fr auto; gap: 8px; align-items: baseline; font-size: 12px; padding: 4px 8px; border-left: 3px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, .015); }
.feed li.ok { border-left-color: var(--green); }
.feed li.warn { border-left-color: var(--yellow); }
.feed li.err { border-left-color: var(--red); color: #fca5a5; }
.feed li.info { border-left-color: var(--blue); }
.feed li.empty { display: block; border: 0; background: none; }
.feed .ft, .feed .fd { color: var(--muted); font-size: 11px; }
.feed .fx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li.fresh { animation: slidein .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes slidein { from { transform: translateX(-14px); opacity: 0; background: rgba(249, 179, 76, .18); } }
.notice .spd { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 11px; color: var(--muted); }
.notice .spark { width: 120px; height: 24px; display: block; }

/* reduced motion: setting or OS preference */
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* folders view */
.fgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.fcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; transition: border-color .2s, transform .2s; outline: none; }
.fcard:hover, .fcard:focus { border-color: var(--honey); transform: translateY(-2px); }
.fcard.secret:hover .padlock:not(.open) { animation: jiggle .5s ease-in-out; }
.fcard .fname { font-weight: 600; word-break: break-word; }
.fcard .fmeta { font: 11px var(--mono); color: var(--muted); }
@keyframes jiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font: 13px var(--mono); }
.crumbs a { cursor: pointer; color: var(--text); padding: 3px 6px; border-radius: 6px; display: inline-flex; align-items: center; gap: 5px; }
.crumbs a:hover, .crumbs a.over { background: var(--panel-2); color: var(--honey); }
.crumbs .sep { color: var(--muted); }
#f-q { width: 220px; }
.secretbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 12px; border-radius: 8px; font-size: 12px; background: rgba(249, 179, 76, .08); border: 1px solid rgba(249, 179, 76, .3); color: var(--honey); }
.secretbar .btn { margin-left: auto; }
.entries.drop { border-style: solid; border-width: 1px; border-color: var(--line); padding: 6px; text-align: left; color: var(--text); min-height: 180px; background: var(--panel); }
.entries.list { display: flex; flex-direction: column; gap: 2px; }
.entries.list .ent { display: grid; grid-template-columns: 24px 1fr 110px 110px; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 6px; cursor: default; outline: none; }
.entries.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.entries.grid .ent { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; border-radius: 8px; text-align: center; outline: none; }
.entries.grid .ent .sz, .entries.grid .ent .tm { font-size: 10px; color: var(--muted); }
.ent .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; flex-direction: column; }
.entries.grid .ent .nm { white-space: normal; word-break: break-word; font-size: 12px; }
.ent .sz, .ent .tm { font-size: 12px; color: var(--muted); text-align: right; }
.ent:hover { background: var(--panel-2); }
.ent.sel { background: rgba(249, 179, 76, .12); box-shadow: inset 0 0 0 1px rgba(249, 179, 76, .45); }
.ent.over { background: rgba(199, 125, 255, .15); box-shadow: inset 0 0 0 1px var(--violet); }
.ent.dir .nm { font-weight: 600; }
.ctxmenu { position: fixed; z-index: 50; min-width: 180px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); animation: in .12s ease-out; }
.ctxmenu button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ctxmenu button:hover { background: var(--panel-2); color: var(--honey); }
.ctxmenu button.red { color: var(--red); }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.warnbox { padding: 10px 12px; border-radius: 8px; background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .35); color: #fca5a5; font-size: 13px; }
.modal .err { min-height: 18px; margin-top: 8px; font-size: 13px; }
.modal.wide { width: min(980px, 94vw); }
.pv-img { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 6px; }
.pv-pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pv-text { max-height: 70vh; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; font: 12px var(--mono); white-space: pre-wrap; user-select: text; }
.unlock { text-align: center; }
.unlock .padlock { display: block; margin: 4px auto 8px; }
.unlock.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* padlock: the shackle lifts when open */
.padlock .shackle { transform-box: view-box; transform-origin: 44px 30px; transition: transform .45s cubic-bezier(.3, 1.6, .5, 1); }
.padlock.open .shackle { transform: translateY(-6px) rotate(28deg); }
.padlock .lbody { transition: fill .3s; }
.padlock.open .lbody { fill: #22c55e; }
.lockfx { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; pointer-events: none; background: radial-gradient(circle, rgba(11, 13, 18, .55), transparent 60%); animation: in .2s ease-out; transition: opacity .35s; }
.lockfx .padlock { filter: drop-shadow(0 8px 30px rgba(249, 179, 76, .35)); animation: pop .5s ease-out; }
.lockfx.out { opacity: 0; }
@keyframes pop { from { transform: scale(.6); } 60% { transform: scale(1.1); } }

/* TEDDY apps */
.appcard svg { width: 40px; height: 40px; }
.appcard.off { opacity: .6; }
.apphost { position: fixed; inset: 0; z-index: 45; background: rgba(5, 7, 10, .8); display: flex; align-items: center; justify-content: center; }
.appwin { width: min(1100px, 94vw); height: min(820px, 90vh); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); animation: in .2s ease-out; }
.appbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.apptitle { font: 600 13px var(--mono); color: var(--honey); }
.appwin iframe { flex: 1; width: 100%; border: 0; background: #0b0d12; }
