/* PocketLinux — phone shell with an XFCE/Greybird temperament:
   hard corners, 1px borders, flat grays, one restrained blue. */

:root {
  --panel:       #2b3036;
  --panel-edge:  #16181b;
  --panel-text:  #e8eaec;
  --win-bg:      #f2f3f4;
  --win-text:    #24282c;
  --edge:        #9ca0a4;
  --edge-dark:   #55595e;
  --accent:      #3d8fd6;
  --accent-down: #2f6ea6;
  --term-bg:     #15181b;
  --ok:          #6bb35e;
  --warn:        #d6a53d;
  --bad:         #cf5b56;
  --sa-top:    env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; border-radius: 0 !important; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font: 15px/1.45 -apple-system, "Segoe UI", system-ui, "DejaVu Sans", sans-serif;
  background: #000; color: var(--win-text);
  -webkit-text-size-adjust: none; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}

#phone { position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 0%, #3c4a57 0%, transparent 60%),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255,255,255,.022) 22px 23px),
    linear-gradient(160deg, #2a333c 0%, #1d242b 55%, #161b21 100%);
}

/* ── status bar ─────────────────────────────────────────── */
#statusbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 60;
  height: calc(26px + var(--sa-top)); padding: var(--sa-top) 10px 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--panel-edge);
  color: var(--panel-text); font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
}
#sb-title { opacity: .55; font-weight: 700; letter-spacing: .4px; }
#sb-right { display: flex; gap: 10px; align-items: center; }
#sb-net { color: var(--bad); font-weight: 700; }
#sb-net.on { color: var(--ok); }
#sb-save { color: #6d747b; font-size: 9px; }
#sb-save.fresh { color: var(--ok); }
#sb-save.saving { color: var(--warn); }

/* ── home screen ────────────────────────────────────────── */
#homescreen {
  position: absolute; inset: calc(26px + var(--sa-top)) 0 calc(86px + var(--sa-bottom)) 0;
  overflow-y: auto; padding: 26px 18px 8px;
}
#appgrid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 22px 10px; max-width: 460px; margin: 0 auto;
}
@media (min-width: 700px) { #appgrid { grid-template-columns: repeat(6, 1fr); max-width: 700px; } }

.tile { display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer; }
.tile-icon {
  width: 58px; height: 58px; border: 1px solid rgba(0,0,0,.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 1px 2px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.tile-icon svg { width: 34px; height: 34px; }
.tile:active .tile-icon { filter: brightness(.82); }
.tile-label {
  color: #eceef0; font-size: 11.5px; font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,.8); text-align: center;
}

/* ── dock ───────────────────────────────────────────────── */
#dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 60;
  height: calc(78px + var(--sa-bottom)); padding: 9px 14px calc(9px + var(--sa-bottom));
  background: rgba(38, 43, 48, .94); border-top: 1px solid var(--panel-edge);
  display: flex; justify-content: center; gap: 22px;
}
#dock .tile-label { display: none; }
#dock .tile-icon { width: 56px; height: 56px; }

/* ── app windows ────────────────────────────────────────── */
.app {
  position: absolute; inset: calc(26px + var(--sa-top)) 0 var(--kb, 0px) 0; z-index: 70;
  display: none; flex-direction: column;
  background: var(--win-bg); border-top: 1px solid var(--panel-edge);
}
.app.open { display: flex; }

.titlebar {
  height: 40px; flex: 0 0 auto; display: flex; align-items: center;
  background: linear-gradient(#3a4046, #30353b); border-bottom: 1px solid var(--panel-edge);
  color: var(--panel-text); padding-left: 12px; gap: 8px;
}
.titlebar .t-name { font-weight: 700; font-size: 14px; flex: 1; }
.titlebar .t-icon svg { width: 17px; height: 17px; display: block; }
.tb-btn {
  width: 52px; height: 100%; border: none; border-left: 1px solid var(--panel-edge);
  background: transparent; color: var(--panel-text); font-size: 17px; cursor: pointer;
}
.tb-btn:active { background: rgba(0,0,0,.35); }

.app-body { flex: 1; overflow-y: auto; user-select: text; -webkit-user-select: text; }
.app-body.pad { padding: 14px; padding-bottom: calc(14px + var(--sa-bottom)); }

/* ── terminal app ───────────────────────────────────────── */
#app-terminal .app-body { background: var(--term-bg); overflow: hidden; padding: 4px 0 0 6px; }
#term-host { width: 100%; height: 100%; }
#term-keys {
  flex: 0 0 auto; display: flex; overflow-x: auto; gap: 1px;
  background: var(--panel-edge); border-top: 1px solid var(--panel-edge);
  padding-bottom: var(--sa-bottom);
}
#term-keys button {
  flex: 1 0 44px; min-width: 44px; height: 40px; border: none;
  background: var(--panel); color: var(--panel-text);
  font: 600 13px ui-monospace, Menlo, monospace; cursor: pointer;
}
#term-keys button:active { background: #444b52; }
#term-keys button.latched { background: var(--accent); }

/* ── display (VGA) app ──────────────────────────────────── */
#app-display .app-body { background: #000; overflow: auto; display: flex;
  align-items: flex-start; justify-content: flex-start; }
#screen_container { position: relative; transform-origin: 0 0; }
#screen_container > div {
  white-space: pre; font: 14px ui-monospace, Menlo, "DejaVu Sans Mono", monospace;
  line-height: 14px; color: #ddd; background: #000;
}
#screen_container > canvas { display: none; }
#display-bar {
  flex: 0 0 auto; display: flex; gap: 6px; padding: 6px 6px calc(6px + var(--sa-bottom));
  background: var(--panel); border-top: 1px solid var(--panel-edge);
}
#display-bar input {
  flex: 1; height: 34px; border: 1px solid var(--panel-edge); background: #1d2126;
  color: #e8eaec; padding: 0 8px; font: 13px ui-monospace, Menlo, monospace;
}
#display-bar button {
  height: 34px; padding: 0 12px; border: 1px solid var(--panel-edge);
  background: #3a4046; color: var(--panel-text); font-weight: 600; cursor: pointer;
}

/* ── generic widgets (settings, store, about) ───────────── */
h2.sect { font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: #5c626a; margin: 20px 2px 6px; }
h2.sect:first-child { margin-top: 2px; }
.card { background: #fff; border: 1px solid var(--edge); }
.card + .card { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border-bottom: 1px solid #e2e4e6; min-height: 46px; }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; font-size: 14.5px; }
.row .r-sub { font-size: 12.5px; color: #6a7078; }
.row input[type=text] {
  width: 100%; border: 1px solid var(--edge); padding: 7px 8px;
  font: 13px ui-monospace, Menlo, monospace; background: #fbfbfc; color: var(--win-text);
}

.btn {
  display: inline-block; border: 1px solid var(--edge-dark);
  background: linear-gradient(#fdfdfd, #e8eaec); color: var(--win-text);
  font: 600 13.5px inherit; padding: 8px 14px; cursor: pointer;
}
.btn:active { background: #d7dadd; }
.btn.primary { background: linear-gradient(#4d9be0, var(--accent)); border-color: var(--accent-down); color: #fff; }
.btn.primary:active { background: var(--accent-down); }
.btn.danger { background: linear-gradient(#d96660, var(--bad)); border-color: #a03f3b; color: #fff; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* toggle: square, xfce-ish */
.toggle { position: relative; width: 46px; height: 26px; flex: 0 0 auto;
  border: 1px solid var(--edge-dark); background: #c6c9cc; cursor: pointer; }
.toggle::after { content: ""; position: absolute; top: 1px; left: 1px;
  width: 22px; height: 22px; background: linear-gradient(#fff,#dfe2e4);
  border: 1px solid var(--edge-dark); transition: left .12s; }
.toggle.on { background: var(--accent); border-color: var(--accent-down); }
.toggle.on::after { left: 21px; }

select.sel {
  border: 1px solid var(--edge); background: #fbfbfc; color: var(--win-text);
  font: 600 13.5px inherit; padding: 7px 8px;
}

/* radio rows */
.radio { width: 18px; height: 18px; border: 1px solid var(--edge-dark);
  background: #fff; flex: 0 0 auto; position: relative; }
.radio.on::after { content: ""; position: absolute; inset: 4px; background: var(--accent); }

/* ── app store ──────────────────────────────────────────── */
.store-note { font-size: 12.5px; color: #6a7078; padding: 2px 2px 10px; }
.pkg-icon { width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font: 700 17px ui-monospace, Menlo, monospace; color: #fff; }
.netwarn { background: #fdf3dd; border: 1px solid #e0c27a; padding: 10px 12px;
  font-size: 13px; margin-bottom: 10px; }
.netwarn a { color: var(--accent-down); font-weight: 700; text-decoration: none; }

/* ── about ──────────────────────────────────────────────── */
#app-about .app-body { font-size: 14px; }
#app-about h3 { font-size: 15px; margin: 16px 0 4px; }
#app-about p, #app-about li { color: #3a3f45; margin: 6px 0; }
#app-about ul { padding-left: 20px; }
#app-about code { font: 12.5px ui-monospace, Menlo, monospace; background: #e8eaec;
  padding: 1px 4px; border: 1px solid #d5d8da; }

/* ── boot overlay ───────────────────────────────────────── */
#bootscreen {
  position: absolute; inset: 0; z-index: 100; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(165deg, #262c33, #14181d); color: #e8eaec;
  padding: 30px; text-align: center;
}
#boot-logo { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
#boot-logo span { color: var(--accent); }
#boot-sub { font-size: 13px; color: #8b939b; margin-top: -8px; }
#boot-bar { width: min(280px, 70vw); height: 10px; border: 1px solid #000;
  background: #0d0f12; box-shadow: inset 0 1px 3px rgba(0,0,0,.7); }
#boot-bar-fill { width: 0%; height: 100%; background: var(--accent); transition: width .15s; }
#boot-status { font: 12px ui-monospace, Menlo, monospace; color: #9aa2aa; min-height: 16px; }
#boot-err { font-size: 13px; color: #e08984; max-width: 340px; white-space: pre-wrap; }
#bootscreen.done { display: none; }

.hidden { display: none !important; }
