:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --danger: #dc2626;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.45;
}
a { color: var(--blue); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--blue); color: #fff;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { color: #fff; font-weight: 700; font-size: 19px; text-decoration: none; white-space: nowrap; }
.topnav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.topnav a { color: #dbeafe; text-decoration: none; font-size: 16px; }
.linklike { background: none; border: 0; color: #dbeafe; font-size: 16px; cursor: pointer; padding: 0; }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px 14px 48px; }
h1 { font-size: 24px; margin: 6px 0 10px; }
h1.page { margin-top: 4px; }
h2 { font-size: 19px; margin: 4px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 12px; border-radius: 12px; }
.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 10px 12px; border-radius: 12px; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 14px 0; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.card.narrow { max-width: 460px; margin: 32px auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.inner { margin-top: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 16px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
select, textarea {
  font: inherit; font-weight: 400; color: var(--ink);
  padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  min-height: 52px; width: 100%;
}
input[type="file"] { font: inherit; padding: 12px 0; }
textarea { min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 20px;
  border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-dark); }
.btn.big { min-height: 60px; font-size: 19px; width: 100%; }
.btn.small { min-height: 42px; padding: 8px 14px; font-size: 15px; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.addbtn { margin: 14px 0 18px; box-shadow: 0 6px 16px rgba(37, 99, 235, .28); }
.searchbar { display: flex; gap: 10px; }
.searchbar input { flex: 1; }
.searchbar .btn { min-width: 104px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.thing {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; text-decoration: none; color: var(--ink); overflow: hidden;
}
.thing img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; background: #e2e8f0; }
.thing-name { font-weight: 700; font-size: 16px; }
.thing-path { color: var(--muted); font-size: 13.5px; }
.thing.archived { opacity: .85; }
.thing form { margin-top: 6px; }
.bigphoto { width: 100%; max-height: 52vh; object-fit: contain; border-radius: 12px; background: #f8fafc; }
.preview { width: 100%; max-height: 300px; object-fit: cover; border-radius: 12px; }
.place { font-size: 19px; font-weight: 600; color: var(--blue-dark); }
.comment { white-space: pre-wrap; }
.badge { display: inline-block; background: #fef3c7; color: #92400e; padding: 4px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input { flex: 1; min-height: 42px; }
details.subtle { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }
details.subtle summary { cursor: pointer; color: var(--blue); font-weight: 600; padding: 4px 0; }
details.subtle .inner { padding-top: 8px; }
.loctree { list-style: none; margin: 0; padding: 0; }
.loctree li { padding: 10px 0 10px calc(var(--d) * 22px); border-bottom: 1px solid var(--line); }
.loctree li:last-child { border-bottom: 0; }
.locrow { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.locname { font-weight: 600; }
.locactions { display: flex; gap: 10px; align-items: flex-start; margin-top: 6px; }
.locactions details.subtle { flex: 1; }
