:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16191d;
  --muted: #666e79;
  --line: #dfe3e8;
  --accent: #1f5eff;
  --danger: #b3261e;
  --warn-bg: #fff5d6;
  --warn-line: #e3c96a;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* A long email in the header pushed the page wider than the screen, so narrow
   phones scrolled sideways and the Log out control sat off-screen. */
html, body { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 64px; }

h1 { font-size: 1.6rem; margin: 0 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }

a { color: var(--accent); }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px 12px; flex-wrap: wrap; padding: 12px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); flex: none; }
.nav-right { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; justify-content: flex-end; }
.who {
  color: var(--muted); font-size: .9rem;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link { flex: none; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 0 0 18px;
}

.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=file] {
  font: inherit; padding: 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
input[readonly] { background: #f2f4f7; color: var(--muted); }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; justify-self: start;
}
button.link {
  background: none; color: var(--accent); border: none; padding: 0;
  font-weight: 500; text-decoration: underline;
}
.danger-btn { background: var(--danger); }

.hint { color: var(--muted); font-size: .85rem; font-weight: 400; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }

.alert {
  padding: 10px 12px; border-radius: 8px; margin: 0 0 14px;
  border: 1px solid var(--danger); background: #fdecea; color: var(--danger);
}
.alert.warn { border-color: var(--warn-line); background: var(--warn-bg); color: #6b530a; }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.tile {
  display: grid; gap: 6px; padding: 10px; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.tile img {
  width: 100%; height: 140px; object-fit: cover;
  border-radius: 6px; background: #eef1f4;
}
.tile-title { font-weight: 600; overflow-wrap: anywhere; }
.tile-meta { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; }

.preview { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; }
.qr { width: 220px; max-width: 100%; height: auto; image-rendering: pixelated; background: #fff; }

.url-row { display: flex; gap: 8px; align-items: center; margin: 12px 0 8px; flex-wrap: wrap; }
.url-row input { flex: 1 1 200px; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.actions { display: flex; gap: 16px; margin: 0; flex-wrap: wrap; }

details.danger { border-color: #f0c4c0; }
details.danger summary { cursor: pointer; font-weight: 600; color: var(--danger); }
details.danger p { color: var(--muted); }

.public-title { font-size: 1.2rem; text-align: center; }
.public-image {
  max-width: 100%; height: auto; display: block; margin: 0 auto;
  border-radius: 8px; background: var(--card);
}

@media print {
  .nav, form, .actions, .banner, .url-row, details, .alert, .hint { display: none; }
  body { margin: 0; background: #fff; }
  .qr-print { display: block; margin: 0 auto; width: 60mm; height: 60mm; }
}
