:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --fg-secondary: #5d6573;
  --border: #d0d4dc;
  --accent: #2d5fff;
  --bg-elev: #f6f7fb;
  --bg-tree: #f1f3f9;
  --status-ok: #00897b;
  --status-warn: #c69026;
  --status-error: #d63031;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d2330;
    --fg: #e5e7ec;
    --fg-secondary: #9aa0ac;
    --border: #2d3343;
    --accent: #5d7fff;
    --bg-elev: #252b3a;
    --bg-tree: #1f2531;
  }
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
#hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-top)) 14px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
#title {
  flex: 1 1 auto;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#status {
  font-size: 11px;
  color: var(--fg-secondary);
  white-space: nowrap;
}
#status.ok::before { content: "● "; color: var(--status-ok); }
#status.warn::before { content: "● "; color: var(--status-warn); }
#status.error::before { content: "● "; color: var(--status-error); }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: none;
}
.icon-btn:hover { background: var(--bg-tree); }
#app.view-edit #back-btn { display: inline-block; }
#main {
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
}
.screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen[hidden] { display: none; }

/* Pairing screen */
.pair-msg {
  padding: 24px 20px;
  text-align: center;
}
.pair-msg h2 { margin: 16px 0 8px; }
.pair-msg p { margin: 8px 0; color: var(--fg-secondary); }
.pair-detail { font-size: 12px; }
code {
  background: var(--bg-tree);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}

/* List screen */
#search {
  margin: 10px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--fg);
  font-size: 15px;
  outline: none;
  flex: 0 0 auto;
}
#search:focus { border-color: var(--accent); }
#project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}
#project-list li {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
#project-list li:active {
  background: var(--bg-tree);
}
#project-list .li-name {
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#project-list .li-preview {
  font-size: 13px;
  color: var(--fg-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--fg-secondary);
  text-align: center;
}

/* Edit screen */
#edit-path {
  padding: 10px 14px;
  font-size: 11px;
  color: var(--fg-secondary);
  font-family: ui-monospace, Consolas, monospace;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;
}
#edit-area {
  flex: 1 1 auto;
  resize: none;
  border: none;
  outline: none;
  padding: 14px;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
  width: 100%;
}
#edit-status {
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom)) 14px;
  font-size: 11px;
  color: var(--fg-secondary);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}
