:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1e21;
  --muted: #5f6368;
  --border: #d7dae0;
  --accent: #e11d2e;
  --accent-text: #ffffff;
  --active: #e8eaee;
  --desk: #d9dce1;
  --desk-check: #cfd3d9;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181b;
    --surface: #222327;
    --text: #e8e9ec;
    --muted: #9aa0a6;
    --border: #3a3c42;
    --active: #33353b;
    --desk: #0e0f11;
    --desk-check: #141518;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }

header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; color: var(--accent); text-decoration: none; }
main { padding: 16px; max-width: 1600px; margin: 0 auto; }

button, .button, input[type=password], input[type=text] {
  font: inherit; font-size: 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 7px 12px;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
button:hover, .button:hover { background: var(--active); }
button.active { background: var(--active); border-color: var(--text); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: .6; cursor: wait; }
button.link { border: none; background: none; color: var(--muted); }

.card {
  max-width: 560px; margin: 48px auto; padding: 24px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
.card h1 { margin: 0 0 8px; font-size: 22px; }
.card p { color: var(--muted); }
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; }
.linkrow input { flex: 1 1 220px; min-width: 0; }
.error { color: var(--accent) !important; }

.drop {
  margin: 48px auto; max-width: 720px; padding: 64px 24px; text-align: center;
  border: 3px dashed var(--border); border-radius: 12px; color: var(--muted);
}
.drop.over { border-color: var(--accent); }
.drop .big { font-size: 24px; font-weight: 600; color: var(--text); margin-top: 0; }
.filepick { color: var(--accent); text-decoration: underline; cursor: pointer; }
kbd { border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 13px; background: var(--surface); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px;
  position: sticky; top: 0; z-index: 2; padding: 8px 0; background: var(--bg);
}
.toolbar .group { display: flex; gap: 4px; align-items: center; }
.toolbar #save { margin-left: auto; }
.swatch {
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  background: var(--c) !important; border: 2px solid var(--border);
}
.swatch.active { outline: 2px solid var(--text); outline-offset: 2px; }
#color { width: 30px; height: 30px; padding: 0; border: none; background: none; cursor: pointer; }
#color.active { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 4px; }

/* Grey "desk" around the screenshot, so it is clear where the image ends. */
#frame {
  display: flex; justify-content: center; align-items: flex-start;
  padding: 28px; border-radius: 10px; border: 1px solid var(--border);
  background-color: var(--desk);
  background-image:
    linear-gradient(45deg, var(--desk-check) 25%, transparent 25%, transparent 75%, var(--desk-check) 75%),
    linear-gradient(45deg, var(--desk-check) 25%, transparent 25%, transparent 75%, var(--desk-check) 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px;
}
#stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
#canvas {
  /* Fit the whole screenshot on screen: header, toolbar and frame take ~220px. */
  max-width: 100%; max-height: calc(100vh - 220px); width: auto; height: auto;
  display: block; cursor: crosshair; touch-action: none;
  outline: 1px solid rgba(0,0,0,.35); box-shadow: 0 4px 18px rgba(0,0,0,.35);
}
#text-input {
  position: absolute; line-height: normal; padding: 2px 4px; min-width: 160px;
  background: rgba(255,255,255,.9); color: #000; font-weight: 600;
}

#sticky-input {
  position: absolute; line-height: 1.25; border: none; border-radius: 6px; resize: none; overflow: hidden;
  background: #fff7a8; color: #222222; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 500; box-shadow: 0 2px 8px rgba(0,0,0,.3); outline: 1px solid rgba(120, 100, 0, .35);
}

.status { text-align: center; color: var(--muted); }

/* Share page */
.view main { text-align: center; }
.view main img { max-width: 100%; max-height: calc(100vh - 140px); width: auto; height: auto; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
.view .actions { display: flex; gap: 8px; }
.meta { color: var(--muted); font-size: 13px; }

@media (max-width: 600px) {
  .toolbar #save { margin-left: 0; width: 100%; justify-content: center; }
}

/* Note for the administrator about new accounts */
.adminbar { display: block; padding: 8px 16px; background: #fff1c2; color: #6b4e00; font-size: 14px; font-weight: 600; text-decoration: none; }
.adminbar:hover { text-decoration: underline; }

/* Header navigation */
header nav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; justify-content: flex-end; }
header nav a { color: var(--muted); text-decoration: none; font-size: 14px; padding: 4px 0; border-bottom: 2px solid transparent; }
header nav a:hover { color: var(--text); }
header nav a.current { color: var(--text); border-bottom-color: var(--accent); }
header nav .who { color: var(--muted); font-size: 13px; }

/* Login and sign-up */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; font-weight: 600; color: var(--muted); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); background: none; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.stack label input { font-weight: 400; }
.stack button { align-self: flex-start; }
.notice { margin: 0; padding: 10px 12px; border-radius: 6px; background: var(--active); color: var(--text) !important; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
.info { color: var(--text) !important; }
input[type=email], input[type=date] {
  font: inherit; font-size: 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 7px 12px;
}

/* My screenshots */
.pagehead { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.pagehead h1 { margin: 0; font-size: 24px; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filter label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.shot { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.shot .thumb { display: block; aspect-ratio: 16 / 10; background: var(--active); }
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; }
.shot figcaption { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; font-size: 13px; }
.shot time { color: var(--muted); font-variant-numeric: tabular-nums; }
.shot-actions { display: flex; gap: 6px; }
.shot-actions button, .shot-actions .button { padding: 4px 8px; font-size: 13px; }
.empty { color: var(--muted); }

/* Admin */
.tablewrap { overflow-x: auto; margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; }
td.actions button { padding: 4px 10px; font-size: 13px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--active); color: var(--text); }
.chip.pending { background: #fff1c2; color: #6b4e00; }
.chip.active { background: #d8f5df; color: #13612b; }
.chip.disabled, .chip.rejected { background: #fde2e1; color: #8c1a12; }
.chip.admin { background: var(--accent); color: var(--accent-text); }

/* Share page viewer */
/* Fit the whole screenshot on screen: header, frame and date take ~185px. */
#view { max-width: 100%; max-height: calc(100vh - 185px); width: auto; height: auto; display: block; touch-action: pan-y pinch-zoom; outline: 1px solid rgba(0,0,0,.35); box-shadow: 0 4px 18px rgba(0,0,0,.35); }
/* When notes stick out, the canvas is bigger than the screenshot; the
   screenshot then draws its own shadow. */
#canvas.expanded, #view.expanded { outline: none; box-shadow: none; }
