:root {
  --ink: #151515; --muted: #6a6a6a; --line: #e7e4dd; --bg: #f7f6f2; --card: #fff;
  --dot: #d0342c; --warn: #7a5200; --warnbg: #fff6e0;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
       gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
       background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; text-decoration: none; }
.pill { background: var(--dot); color: #fff; border-radius: 999px; font-size: 12px; padding: 1px 8px; font-weight: 700; }
.top nav { display: flex; align-items: center; gap: 16px; font-size: 15px; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }

.wrap { max-width: 860px; margin: 0 auto; padding: 14px 14px 30px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 30px; }
.small { font-size: 13px; color: var(--muted); }
.nowrap { white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
       border-radius: 8px; border: 1px solid #111; background: #111; color: #fff; font: inherit; font-weight: 600;
       text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.secondary { background: #fff; color: #111; border-color: #cfccc4; }

.search { display: flex; gap: 8px; margin: 2px 0 10px; }
.search input[type=search] { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 9px 12px;
       border: 1px solid #cfccc4; border-radius: 8px; background: #fff; }
.tabs { display: flex; gap: 6px; margin: 0 0 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.tabs a { flex: none; text-decoration: none; padding: 6px 12px; border-radius: 999px; background: #fff;
          border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.tabs a.on { background: #111; color: #fff; border-color: #111; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; gap: 12px; padding: 12px; text-decoration: none; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row:active { background: #f2f0ea; }
.thumb { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: #ece9e2;
         display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 11px; text-align: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.main { flex: 1; min-width: 0; }
.line1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread .name { font-weight: 800; }
.unread .name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
                        background: var(--dot); margin-right: 7px; vertical-align: 2px; }
.when { flex: none; color: var(--muted); font-size: 13px; }
.unread .when { color: var(--ink); font-weight: 600; }
.line2, .line3 { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line2 { color: var(--muted); }
.line3 { color: #3a3a3a; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; margin-top: 12px; }

.back { display: inline-block; margin: 2px 0 10px; color: var(--muted); text-decoration: none; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.actions form { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 0 0 12px; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; }
.spamnote { background: var(--warnbg); border-color: #f0dfb0; }
.spamnote p { margin: 0 0 10px; }
.msg { margin: 0; white-space: pre-wrap; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 14px; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.path { overflow-wrap: anywhere; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 640px) { .photos { grid-template-columns: repeat(5, 1fr); } }
.photos button { position: relative; padding: 0; border: 0; background: #ece9e2; aspect-ratio: 1 / 1;
                 border-radius: 8px; overflow: hidden; cursor: zoom-in; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.65); color: #fff;
               font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.nopreview { display: flex; align-items: center; justify-content: center; height: 100%; padding: 6px;
             font-size: 12px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.warn { background: var(--warnbg); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin: 10px 0 0; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 9px 10px;
                 border: 1px solid #cfccc4; border-radius: 8px; background: #faf9f6; }

.lb { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
      background: #000; }
.lb[hidden] { display: none; }
.lb img { max-width: 100vw; max-height: 100vh; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lb-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px;
            border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; font-size: 26px; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0;
          border-radius: 8px; background: rgba(255,255,255,.12); color: #fff; font-size: 30px; cursor: pointer; }
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }
.lb-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between;
          padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom)); color: #ddd; font-size: 15px;
          background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.lb-bar a { color: #fff; font-weight: 600; }
@media (hover: none) { .lb-nav { display: none; } }

.login { max-width: 360px; margin: 12vh auto 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.login h1 { font-size: 22px; margin-bottom: 12px; }
.login label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.login input { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid #cfccc4; border-radius: 8px; }
.login .btn { width: 100%; margin-top: 18px; }
.error { color: #b3261e; font-weight: 600; margin: 12px 0 0; }

table.rep { width: 100%; border-collapse: collapse; font-size: 15px; }
table.rep td { padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
table.rep tr:first-child td { border-top: 0; }
table.rep td.n { width: 1%; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.barcell { width: 28%; }
.bar { height: 8px; min-width: 3px; border-radius: 4px; background: #111; opacity: .75; }
