/* Notie App - industrial field UI
   Direction: rugged / utilitarian. Dark slate base, hi-vis safety amber accent,
   oversized touch targets for gloved hands & bright sunlight, strong status cues.
   All self-hosted: no web fonts or CDNs (must work fully offline). */

:root {
  --bg: #0e1116;
  --bg-2: #161b22;
  --panel: #1c232d;
  --panel-2: #232c38;
  --line: #303a47;
  --line-2: #3d4a5a;
  --text: #eef2f6;
  --muted: #9aa7b4;
  --muted-2: #6b7888;
  --amber: #ff8a00;        /* hi-vis safety amber */
  --amber-ink: #1a1205;
  --green: #2ec27e;
  --red: #ff5d5d;
  --blue: #4aa3ff;
  --radius: 12px;
  --radius-lg: 16px;
  --tap: 52px;             /* minimum touch target */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
  padding-bottom: env(safe-area-inset-bottom);
}
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* ---- App bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(180deg, #11161d, #0e1116);
  border-bottom: 2px solid var(--amber);
}
.appbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .3px; }
.appbar .brand .logo {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: var(--amber); color: var(--amber-ink);
  display: grid; place-items: center; font-weight: 900; font-size: 18px;
  box-shadow: 0 0 0 3px rgba(255,138,0,.18);
}
.appbar .brand small { color: var(--muted); font-weight: 600; font-size: 11px; display: block; line-height: 1; }
.appbar .spacer { flex: 1; }

.net-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel);
}
.net-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.net-pill.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.net-pill.offline { color: var(--amber); border-color: rgba(255,138,0,.45); }
.net-pill.offline .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

.queue-btn {
  position: relative; min-width: var(--tap); height: 44px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel);
  color: var(--text); font-weight: 700; font-size: 13px; display: inline-flex;
  align-items: center; gap: 7px; cursor: pointer;
}
.queue-btn .badge {
  position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px;
  padding: 0 5px; border-radius: 999px; background: var(--amber); color: var(--amber-ink);
  font-size: 12px; font-weight: 900; display: grid; place-items: center;
  border: 2px solid var(--bg);
}
.queue-btn .badge.zero { display: none; }

/* ---- Layout ---- */
main { max-width: 720px; margin: 0 auto; padding: 16px 14px 120px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px;
}
.card > h2 {
  margin: 0 0 12px; font-size: 13px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 9px;
}
.card > h2 .ico { color: var(--amber); }
.req::after { content: " *"; color: var(--amber); }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=search], textarea, select {
  width: 100%; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 14px;
  font-size: 16px; font-family: inherit; min-height: var(--tap);
}
textarea { min-height: 92px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 40px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-weight: 800; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); width: 100%;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(255,93,93,.5); }
.btn.recording { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1.1s infinite; }
.btn.sm { min-height: 40px; font-size: 13px; padding: 0 12px; width: auto; }
.btn:disabled { opacity: .45; pointer-events: none; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,93,93,.5); } 50% { box-shadow: 0 0 0 10px rgba(255,93,93,0); } }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row.three { grid-template-columns: 1fr 1fr; }

/* ---- Segmented control ---- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--bg-2); padding: 6px; border-radius: 12px; margin-bottom: 14px; }
.seg button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 800; font-size: 13px; cursor: pointer; }
.seg button.active { background: var(--amber); color: var(--amber-ink); }

/* ---- FLOC results / lists ---- */
.results { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; -webkit-overflow-scrolling: touch; }
.node {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; min-height: var(--tap); cursor: pointer; color: var(--text);
}
.node:active { border-color: var(--amber); }
.node .meta { flex: 1; min-width: 0; }
.node .meta .desc { font-weight: 700; }
.node .meta .code { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .chev { color: var(--muted-2); font-size: 20px; flex: none; }
.node .pick { font-size: 11px; font-weight: 800; color: var(--amber); border: 1px solid rgba(255,138,0,.4); border-radius: 6px; padding: 5px 8px; flex: none; }

.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs button { background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 5px 9px; font-size: 12px; cursor: pointer; }
.crumbs .here { color: var(--amber); font-weight: 700; }

/* ---- Selected FLOC ---- */
.selected {
  border: 1px solid var(--amber); border-radius: 12px; padding: 14px;
  background: linear-gradient(180deg, rgba(255,138,0,.08), rgba(255,138,0,.02));
}
.selected .lbl { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--amber); }
.selected .name { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.selected .descr { font-size: 18px; font-weight: 800; margin-top: 4px; }
.selected .path { font-size: 12px; color: var(--muted); margin-top: 8px; }
.selected .unresolved { color: var(--amber); font-size: 12px; margin-top: 8px; }

/* ---- Chips / tags ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 700; color: var(--muted); }
.chip .x { cursor: pointer; color: var(--muted-2); }

/* ---- Media thumbs ---- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag { position: absolute; bottom: 4px; left: 4px; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 5px; background: rgba(0,0,0,.6); }
.thumb .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; cursor: pointer; display: grid; place-items: center; }
.audio-row { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.audio-row audio { flex: 1; height: 38px; }

.hint { font-size: 12px; color: var(--muted-2); margin-top: 8px; }
.kv { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 8px; }
.kv b { color: var(--text); font-weight: 700; }
.stamp { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* ---- Sticky submit ---- */
.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(14,17,22,0), var(--bg) 30%);
}
.submit-bar .inner { max-width: 720px; margin: 0 auto; }

/* ---- Modal / sheet ---- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.62); z-index: 60; display: none; align-items: flex-end; justify-content: center; }
.scrim.open { display: flex; }
.sheet {
  width: 100%; max-width: 560px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow: auto; animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.sheet.center { border-radius: 18px; align-self: center; margin: auto; }
.scrim.center { align-items: center; }
.sheet h3 { margin: 0 0 6px; font-size: 20px; }
.sheet p.sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* startup brand */
.startup-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.startup-brand .logo { width: 46px; height: 46px; border-radius: 11px; background: var(--amber); color: var(--amber-ink); display: grid; place-items: center; font-weight: 900; font-size: 26px; }

/* scanner */
.scan-stage { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 3/4; max-height: 60vh; margin-bottom: 14px; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18% 12%; border: 3px solid var(--amber); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }

/* queue list */
.q-item { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; margin-bottom: 10px; }
.q-item .top { display: flex; align-items: center; gap: 9px; }
.q-item .st { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; }
.st.pending { background: rgba(255,138,0,.16); color: var(--amber); }
.st.synced { background: rgba(46,194,126,.16); color: var(--green); }
.st.error { background: rgba(255,93,93,.16); color: var(--red); }
.st.syncing { background: rgba(74,163,255,.16); color: var(--blue); }
.q-item .ttl { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item .sub { font-size: 12px; color: var(--muted); margin-top: 5px; font-family: var(--mono); }

.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 80; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); padding: 12px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.5); max-width: 90%; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }

.footer-meta { text-align: center; color: var(--muted-2); font-size: 12px; margin-top: 20px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
