/* Dev portal — mobile-first dark UI. Big touch targets, single column. */

:root {
  --bg:      #0d1117;
  --panel:   #161b22;
  --panel-2: #1c2330;
  --border:  #2a3441;
  --text:    #e6edf3;
  --muted:   #8b98a5;
  --accent:  #3b82f6;
  --accent-d:#2563eb;
  --green:   #2ea043;
  --red:     #da3633;
  --amber:   #d29922;
  --radius:  14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(13,17,23,.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 600; font-size: 18px; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back, .topbar .logout {
  font-size: 24px; line-height: 1; color: var(--muted);
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 10px;
}
.topbar .back:active, .topbar .logout:active { background: var(--panel-2); }

/* ---- layout ---- */
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 14px 40px; }

/* ---- big tool buttons (home / project hub) ---- */
.tiles { display: grid; gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 16px; min-height: 64px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
}
.tile:active { background: var(--panel-2); }
.tile .ico { font-size: 26px; width: 34px; text-align: center; }
.tile .lab { font-weight: 600; font-size: 17px; }
.tile .sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.tile .col { display: flex; flex-direction: column; }

/* ---- lists (projects, discussions) ---- */
.list { display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px; min-height: 56px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text);
}
.row:active { background: var(--panel-2); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .path { color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--muted); font-size: 22px; }

/* ---- forms & buttons ---- */
input[type=text], input[type=password], textarea {
  width: 100%; padding: 13px 14px; font-size: 16px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
}
textarea { resize: vertical; min-height: 52px; }
label { display: block; color: var(--muted); font-size: 13px; margin: 12px 0 5px; }

.btn {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 16px; min-height: 48px; font-size: 16px; font-weight: 600;
  background: var(--accent); color: #fff; border: none; border-radius: 12px;
}
.btn:active { background: var(--accent-d); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.green  { background: var(--green); }
.btn.red    { background: var(--red); }
.btn.small  { padding: 8px 12px; min-height: 36px; font-size: 14px; }
.btn:disabled { opacity: .5; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.err  { color: #ffb4b4; background: rgba(218,54,51,.12);
  border: 1px solid rgba(218,54,51,.4); padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.ok   { color: #9be9a8; background: rgba(46,160,67,.12);
  border: 1px solid rgba(46,160,67,.4); padding: 10px 12px; border-radius: 10px; margin: 10px 0; }

/* checkbox + label on one line, with a finger-sized box */
label.check { display: flex; align-items: center; gap: 10px; margin: 0;
  color: var(--text); font-size: 16px; cursor: pointer; }
label.check input[type=checkbox] { width: 22px; height: 22px; flex-shrink: 0;
  accent-color: var(--accent); margin: 0; }

/* password field with a show/hide eye tucked inside it */
.pw { position: relative; }
.pw input { padding-right: 52px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: none; padding: 0; cursor: pointer;
  font-size: 18px; line-height: 1; opacity: .75;
}
.pw-eye:active { opacity: 1; }
.muted { color: var(--muted); }
.section-title { color: var(--muted); font-size: 13px; text-transform: uppercase;
  letter-spacing: .05em; margin: 20px 0 8px; }
.floatadd { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; font-size: 30px; z-index: 20; }

/* ---- git tool ---- */
.branch-bar { display:flex; align-items:center; gap:8px; margin-bottom:14px;
  color: var(--muted); font-size: 14px; }
.branch-bar .b { color: var(--text); font-weight:600; font-family: ui-monospace, monospace; }
.g-section { margin-bottom: 8px; }
.g-head { display:flex; align-items:center; gap:8px; padding:10px 4px; cursor:pointer;
  user-select:none; font-weight:600; }
.g-head .caret { transition: transform .15s; color: var(--muted); }
.g-section.collapsed .caret { transform: rotate(-90deg); }
.g-section.collapsed .g-body { display:none; }
.g-count { color: var(--muted); font-weight:400; font-size:13px; }
.g-file { border:1px solid var(--border); border-radius:10px; margin-bottom:8px;
  background: var(--panel); overflow:hidden; }
.g-file-head { display:flex; align-items:center; gap:10px; padding:11px 12px; }
.g-file-head .st { width:20px; text-align:center; font-family:ui-monospace,monospace;
  font-weight:700; font-size:13px; }
.g-file-head .fn { flex:1; min-width:0; font-family:ui-monospace,monospace; font-size:13px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.st.mod { color: var(--amber); } .st.add { color: var(--green); }
.st.del { color: var(--red); }   .st.new { color: var(--accent); }
.g-diff { display:none; border-top:1px solid var(--border); background:#0b0f14;
  overflow-x:auto; }
.g-file.open .g-diff { display:block; }
.g-diff pre { margin:0; padding:10px 12px; font: 12px/1.45 ui-monospace, monospace; }
.dl-add { color:#7ee787; } .dl-del { color:#ff9c9c; } .dl-hd { color:#6ea8ff; }
.dl-at { color: var(--muted); }
.g-commit { border:1px solid var(--border); border-radius:10px; margin-bottom:8px;
  background: var(--panel); padding:10px 12px; }
.g-commit-head { display:flex; align-items:baseline; gap:10px; }
.g-commit-head .ch { color: var(--accent); font-family:ui-monospace,monospace;
  font-size:12px; font-weight:700; flex-shrink:0; }
.g-commit-head .cs { flex:1; min-width:0; font-size:13px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.g-commit-meta { color: var(--muted); font-size:12px; margin-top:4px; }
.commit-box { margin-top: 18px; }

/* ---- claude chat ---- */
/* padding-bottom is set from JS to the live dock height so the last message
   always clears the fixed composer; this is just a sane fallback before JS runs. */
.chat { display:flex; flex-direction:column; gap:12px; padding-bottom: 120px; }
.msg { max-width: 88%; padding:11px 14px; border-radius:14px; white-space:pre-wrap;
  word-wrap:break-word; }
.msg.user { align-self:flex-end; background: var(--accent-d); color:#fff;
  border-bottom-right-radius:4px; }
.msg.asst { align-self:flex-start; background: var(--panel); border:1px solid var(--border);
  border-bottom-left-radius:4px; }
/* queued = sent, but waiting its turn; cancelled = pulled back before Claude saw it */
.msg.user.queued { opacity:.6; padding-right:40px; position:relative; }
.msg.user.queued .qx { position:absolute; top:2px; right:2px; cursor:pointer;
  font-size:13px; line-height:1; opacity:.85;
  padding:10px 12px;                 /* finger-sized tap target, not a 12px glyph */
  -webkit-tap-highlight-color: transparent; }
.msg.user.cancelled { opacity:.45; }
.msg.user.cancelled .utext { text-decoration: line-through; }
.msg.user .qtag { display:block; margin-top:4px; font-size:11px; opacity:.9;
  font-style:italic; }
.note { align-self:center; color: var(--muted); font-size:13px; padding:4px 10px;
  border:1px solid var(--border); border-radius:999px; background: var(--panel); }
.tool { align-self:flex-start; max-width:92%; width:92%;
  background: var(--panel-2); border:1px solid var(--border); border-radius:12px;
  font-size:13px; overflow:hidden; }
.tool summary { list-style:none; cursor:pointer; padding:10px 12px;
  display:flex; align-items:center; gap:8px; font-family:ui-monospace,monospace; }
.tool summary::-webkit-details-marker { display:none; }
.tool .tname { color: var(--accent); font-weight:600; }
.tool .tsum { color: var(--muted); overflow:hidden; text-overflow:ellipsis;
  white-space:nowrap; flex:1; min-width:0; }
.tool pre { margin:0; padding:0 12px 12px; overflow-x:auto; color: var(--muted);
  font: 12px/1.4 ui-monospace, monospace; }
.tool .tres { border-top:1px solid var(--border); padding:10px 12px; color: var(--muted);
  max-height:220px; overflow:auto; }
.perm { align-self:center; width:100%; background: rgba(210,153,34,.1);
  border:1px solid var(--amber); border-radius:12px; padding:14px; }
.perm .pt { font-weight:600; margin-bottom:6px; }
.perm pre { background:#0b0f14; border-radius:8px; padding:10px; overflow-x:auto;
  font:12px/1.4 ui-monospace,monospace; margin:8px 0; }
.perm .pbtns { display:flex; gap:8px; flex-wrap:wrap; }
.thinking { align-self:flex-start; color: var(--muted); font-style:italic; font-size:13px;
  padding: 2px 6px; }
.status { text-align:center; color: var(--muted); font-size:13px; padding:8px 6px 2px; }

/* the dock = status line + composer, pinned to the bottom as one fixed unit so
   its height can be measured and reserved as chat padding (see chat.js). */
.dock { position: fixed; left:0; right:0; bottom:0; z-index:15;
  background: rgba(13,17,23,.95); backdrop-filter: blur(8px);
  border-top:1px solid var(--border); }
.composer { display:flex; gap:8px; align-items:flex-end;
  padding:10px 12px max(10px, env(safe-area-inset-bottom)); }
.composer textarea { flex:1; max-height:140px; }
.composer .btn { min-width:56px; }

/* ---- permission tool ---- */
/* Opened over the chat from a permission card. The overlay is an iframe so the
   popup keeps its own scroll and polling without entangling the chat behind it. */
.permtool-overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); }
.permtool-overlay iframe { width: 100%; height: 100%; border: 0; display: block; }
body.permtool-open { overflow: hidden; }

/* rules written into a settings file, shown on the resolved card */
.perm-added { margin-top: 6px; font-size: 12px; color: var(--muted); }
.perm-added code, .pt-added code { font-family: ui-monospace, monospace;
  color: #7ee787; background: rgba(46,160,67,.12); padding: 1px 6px; border-radius: 6px; }

/* --- the popup itself (permtool.php) --- */
.pt-body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.pt-head { display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.pt-title { font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-x { background: none; border: none; color: var(--muted); font-size: 20px;
  width: 44px; height: 44px; cursor: pointer; }

.pt-tabs { display: flex; flex-shrink: 0; border-bottom: 1px solid var(--border);
  background: var(--panel); }
.pt-tab { flex: 1; background: none; border: none; color: var(--muted);
  font-size: 15px; font-weight: 600; padding: 13px 8px; cursor: pointer;
  border-bottom: 2px solid transparent; }
.pt-tab.on { color: var(--text); border-bottom-color: var(--accent); }

/* Only the active pane participates in layout, so the inactive one can't add
   its own scroll height underneath. */
.pt-pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.pt-pane.on { display: flex; }
.pt-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px; display: flex; flex-direction: column; gap: 12px; }
/* The transcript reuses the chat's message styles, which lean on align-self to
   sit user and assistant on opposite sides — so it has to be a flex column too. */
#pt-chat { display: flex; flex-direction: column; gap: 12px; }

/* the request that is waiting */
.pt-req { background: rgba(210,153,34,.1); border: 1px solid var(--amber);
  border-radius: 12px; padding: 13px; }
.pt-req-h { font-weight: 600; font-size: 13px; color: var(--amber);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.pt-cmd { background: #0b0f14; border-radius: 8px; padding: 10px; margin: 0 0 8px;
  overflow-x: auto; font: 12px/1.45 ui-monospace, monospace; white-space: pre-wrap;
  word-break: break-all; }
.pt-req-d { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.pt-sug { color: var(--muted); font-size: 12px; margin: 8px 0; }
.pt-sug code { display: inline-block; margin: 3px 4px 0 0; padding: 2px 6px;
  background: var(--panel-2); border-radius: 6px; font-family: ui-monospace, monospace;
  word-break: break-all; }
.pt-req-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pt-resolved-line { font-weight: 600; }

/* a rule the advisor is recommending */
.pt-prop { align-self: stretch; background: var(--panel);
  border: 1px solid var(--accent); border-radius: 12px; padding: 13px; }
.pt-prop-h { font-size: 12px; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.pt-prop-rule { font-family: ui-monospace, monospace; font-size: 13px;
  background: #0b0f14; border-radius: 8px; padding: 9px 10px; margin-bottom: 6px;
  word-break: break-all; }
.pt-prop-dest { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.pt-prop-why { font-size: 13px; margin-bottom: 10px; }
.pt-prop-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.pt-code { background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; overflow-x: auto; font: 12px/1.45 ui-monospace, monospace; margin: 0; }

.pt-dock { flex-shrink: 0; background: var(--panel);
  border-top: 1px solid var(--border); }
.pt-status { text-align: center; color: var(--muted); font-size: 13px; padding: 7px 6px 0; }

/* settings files tab */
.pt-filter { display: flex; gap: 8px; align-items: center; }
.pt-filter input { flex: 1; }
.pt-file { background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px; }
.pt-file-h { display: flex; align-items: baseline; gap: 10px; }
.pt-file-n { font-weight: 600; flex: 1; }
.pt-file-c { color: var(--muted); font-size: 12px; }
.pt-file-p { color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace;
  word-break: break-all; margin-top: 2px; }
.pt-file-note { color: var(--muted); font-size: 12px; margin-top: 6px; font-style: italic; }
.pt-file-other { color: var(--muted); font-size: 11px; margin-top: 8px; }
.pt-bucket { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; margin: 12px 0 5px; }
.pt-rules { display: flex; flex-direction: column; gap: 5px; }
.pt-rule { display: flex; align-items: center; gap: 8px; background: var(--panel-2);
  border-radius: 8px; padding: 7px 4px 7px 10px; }
.pt-rule.going { opacity: .5; }
.pt-rule-t { flex: 1; min-width: 0; font: 12px/1.4 ui-monospace, monospace;
  word-break: break-all; }
.pt-rule-x { flex-shrink: 0; color: var(--muted); cursor: pointer; font-size: 13px;
  padding: 6px 11px; -webkit-tap-highlight-color: transparent; }
.pt-rule-x:active { color: var(--red); }
.pt-more { margin-top: 6px; align-self: flex-start; }
