/* the shell: sidebar, home screen, backup reminder, actions editor, action form, request result and data dialogs */

/* ---------- sidebar ---------- */

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.side-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 100%;
  height: 44px;
  padding: 0;
  border: 0;
  border-left: 3px solid transparent;
  color: var(--muted);
}

.side-btn:hover { color: var(--fg); }
.side-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
#data-btn { border-top: 1px solid var(--border); }

.side-home { height: 48px; border-bottom: 1px solid var(--border); }
.side-home.on { color: var(--accent); }

.links-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.links { flex: 1; min-height: 0; overflow: hidden auto; padding: 6px 0; scrollbar-width: none; }

/* when the icons don't fit: arrows above and below them (in the flow, never over an icon, so a quick double click
   can't land on one); the one at the edge is disabled, not hidden. click scrolls by a page */
.side-more {
  flex: none;
  display: grid;
  place-items: center;
  height: 22px;
  padding: 0;
  border: 0;
  color: var(--accent);
  background: var(--panel);
}

.side-more:hover { background: var(--hover); }
.side-more.up { border-bottom: 1px solid var(--border); }
.side-more.down { border-top: 1px solid var(--border); }
.side-more svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.links-wrap:not(.overflow) .side-more { display: none; }

.link {
  display: grid;
  place-items: center;
  width: 100%;
  height: 48px;
  padding: 0;
  border: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  color: var(--fg);
  text-decoration: none;
}

.link:hover { background: var(--hover); border-left-color: var(--accent); }
.link.on { background: var(--hover); border-left-color: var(--accent); }

.ico {
  --s: 20px;
  flex: none;
  display: grid;
  place-items: center;
  width: var(--s);
  height: var(--s);
  background: var(--accent);
  color: var(--accent-fg);
  font: 600 calc(var(--s) * 0.55)/1 var(--ui);
}

.ico.img { background: transparent; color: var(--accent); }
.ico img, .ico svg { display: block; width: 100%; height: 100%; }
.side .ico, .flyout .ico { --s: 32px; }

.flyout {
  position: fixed;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 16px);
  padding: 0 14px 0 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.fly-name { font-weight: 600; }
.fly-url { overflow: hidden; color: var(--muted); font: 12px var(--mono); text-overflow: ellipsis; }

/* ---------- home ---------- */

.home { overflow: auto; background: var(--bg); }

/* the GitHub corner (the repository) and the version beside it: fixed over the page, out of the layout (no size, no
   scroll); only the painted triangle takes clicks, the transparent half of its box lets them through */
.gh-corner { position: fixed; z-index: 1; top: 0; right: 0; width: 64px; height: 64px; pointer-events: none; }
.gh-corner path { pointer-events: auto; }
.gh-corner svg { display: block; width: 100%; height: 100%; }
.gh-bg { fill: var(--fg); }
.gh-cat { fill: var(--bg); }
.gh-corner:hover .gh-bg { fill: var(--accent); }
.app-ver { position: fixed; top: 8px; right: 72px; pointer-events: none; color: var(--muted); font: 11px var(--mono); white-space: nowrap; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 132px);
  justify-content: center;
  gap: 20px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 24px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: auto;
  aspect-ratio: 1;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  text-decoration: none;
}

.tile:hover { background: var(--surface); border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.tile .ico { --s: 56px; }
.tile-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-add { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); font-family: inherit; cursor: pointer; }
.tile-add .ico { background: none; color: var(--accent); font-size: 48px; font-weight: 300; }
.tile-add:hover { border-style: solid; color: var(--fg); }

/* ---------- backup reminder (home) and the data dialog ---------- */

.backup-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 48px);
  max-width: 1072px;
  margin: 24px auto -32px;
  padding: 8px 8px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}

.backup-bar span { flex: 1; }
.backup-bar button, .data-row button { height: 28px; padding: 0 14px; border-color: var(--border); }
.backup-bar .primary, .data-row .primary { border-color: var(--accent); }

.data-body { display: grid; gap: 10px; padding: 14px 12px; }
.data-body p { margin: 0 0 4px; }
.data-row { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: center; }
.data-row .muted { font-size: 12px; }
.data-row .danger { color: var(--danger); }
.data-row .danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* sync server (Data dialog) and its state on the sidebar button: a dot, none without a server (the one round thing:
   the user's wish, a bright green that doesn't pass for the blue accent) */
.sync { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.sync label { font-weight: 600; }
.sync-line { display: flex; gap: 8px; }
.sync-line input { flex: 1; min-width: 0; height: 28px; font-family: var(--mono); font-size: 12px; }
.sync-line input.secret:not(:focus) { -webkit-text-security: disc; } /* the token shows only while editing */
.sync button { height: 28px; padding: 0 14px; border-color: var(--border); }
.sync .primary { border-color: var(--accent); }
.sync .muted { font-size: 12px; }
.sync .sync-online { color: var(--ok); }
.sync .sync-offline { color: var(--danger); }
.sync-choice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border-left: 3px solid var(--accent); background: var(--surface); }
.sync-choice > span:first-child { flex-basis: 100%; }
#data-btn { position: relative; }
#data-btn::after { content: ""; position: absolute; top: 7px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
#data-btn:not([data-sync])::after, #data-btn[data-sync="off"]::after { display: none; }
#data-btn[data-sync="online"]::after { background: #22c55e; }
#data-btn[data-sync="offline"]::after { background: #ef4444; }

/* add link dialog */

.add-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; align-items: center; padding: 14px 12px; }
.add-body > label, .add-body > span { color: var(--muted); }
.add-body input[type="text"], .add-body select { height: 28px; padding: 0 8px; }
.add-body textarea { min-width: 0; padding: 6px 8px; resize: vertical; background: var(--surface); border: 1px solid var(--border); }
.add-kind { justify-self: start; margin: 0; }
.add-kind button { padding: 0 10px; }
.add-body .url { font-family: var(--mono); font-size: 12px; }
.add-body > .check { color: var(--fg); }
.add-icon { display: flex; align-items: center; gap: 8px; }
.add-icon .ico { --s: 32px; }
.add-icon button { height: 28px; padding: 0 10px; border-color: var(--border); }
.add-icon .muted { font-size: 12px; }

/* shortcuts dialog */

.seg { display: flex; margin-right: 4px; border: 1px solid var(--border); }
.seg button { height: 24px; border: 0; }
.seg button.on { background: var(--accent); color: var(--accent-fg); }

.sc-row {
  display: grid;
  grid-template-columns: 16px 20px minmax(100px, 1fr) minmax(160px, 2.2fr) 84px 28px 28px 28px;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.sc-row input[type="text"] { min-width: 0; height: 26px; padding: 0 6px; }
.sc-row .url { font-family: var(--mono); font-size: 12px; }
.sc-what { grid-column: span 2; color: var(--muted); font-size: 12px; }
.sc-row button { height: 26px; padding: 0; border-color: var(--border); }
.sc-row .sc-more { font-size: 16px; }
.sc-row .sc-method { padding: 0 6px; font: 12px var(--mono); }
.sc-row .del:hover { background: var(--danger); color: #fff; }
.sc-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.sc-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }

.sc-adds { display: flex; gap: 8px; margin-top: 8px; }
.add { flex: 1; height: 28px; border: 1px dashed var(--border-strong); }

.sc-nonotes {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 6px 6px 6px 10px;
  border-left: 3px solid var(--danger);
  background: var(--surface);
}

.sc-nonotes span { flex: 1; }
.sc-nonotes button { height: 26px; border-color: var(--border); }

#sc-json-text {
  display: block;
  width: 100%;
  min-height: 50vh;
  padding: 8px;
  resize: vertical;
  background: var(--surface);
  border: 1px solid var(--border);
  outline: none;
  font: 12px/1.5 var(--mono);
}

#sc-json-err { margin: 6px 0 0; min-height: 1em; }

/* request result */

.req-dlg { height: min(640px, 90vh); }
.req-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1; padding: 10px 12px; }
.req-line { display: flex; align-items: baseline; gap: 12px; }
.req-status { font-weight: 600; }
.req-status.ok { color: var(--ok); }
.req-status.err { color: var(--danger); }
.req-meta { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.req-headers summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.req-headers pre, .req-text { margin: 0; padding: 8px; background: var(--surface); border: 1px solid var(--border); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.req-headers pre { max-height: 160px; overflow: auto; margin-top: 6px; }
.req-text { flex: 1; min-height: 0; overflow: auto; user-select: text; }
.req-tabs { align-self: flex-start; }
.req-tabs button { padding: 0 14px; }
.req-pane { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.req-render { overflow: auto; background: var(--surface); border: 1px solid var(--border); }
.req-frame { display: block; width: 100%; height: 40px; border: 0; }
.add-render { display: flex; flex-direction: column; gap: 4px; }
.add-render .hint { margin: 0; color: var(--muted); }

/* a new version of the web app is ready (shell/update.js) */
.update-bar {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(var(--status-h) + 12px); /* above the notepad's status bar */
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  padding: 6px 6px 6px 14px;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.update-bar button { height: 26px; border-color: currentColor; }
