.app { max-width: 1240px; margin: 0 auto; padding: 20px 24px 48px; }
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.spacer { flex: 1; }

.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 24px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
}
@media (max-width: 520px) {
  .app { padding: 16px 16px 40px; }
  .hide-sm { display: none; }
}

/* Connect card */
.qr-wrap { display: flex; justify-content: center; margin: 16px 0 12px; }
.qr { width: 220px; height: 220px; padding: 10px; background: #fff; border-radius: 16px; border: 1px solid var(--border); }
.qr svg { display: block; width: 100%; height: 100%; }
.steps { margin: 0 0 14px; padding-left: 20px; font-size: 14px; }
.steps li { margin: 3px 0; }
.tip-line { margin: -4px 0 14px; padding: 10px 12px; background: var(--accent-soft); border-radius: 10px; color: var(--text); }
.url-row { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 4px 4px 4px 12px; }
.url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.field select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }

/* Settings card */
.settings { display: flex; flex-direction: column; gap: 14px; }
.save-to { display: flex; gap: 12px; align-items: flex-start; }
.save-to .icon { color: var(--accent); margin-top: 2px; }
.path { font-size: 13px; word-break: break-all; }
.toggle { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.toggle input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.help summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.help ul { padding-left: 18px; margin: 10px 0 12px; font-size: 13.5px; color: var(--muted); }
.help li { margin: 5px 0; }
.small-btn { font-size: 13px; padding: 7px 10px; white-space: normal; text-align: left; }

/* Feed */
.feed-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.feed-head h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.day { margin: 22px 0 10px; font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.day:first-child { margin-top: 4px; }
.group { margin-bottom: 14px; padding: 16px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 14px; }
.group-head .icon { color: var(--accent); }
.group-head b { font-weight: 650; }
.group.fresh { animation: arrive .5s ease-out; }
@keyframes arrive { from { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--accent-soft); } to { transform: none; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: block; padding: 0; border: 0; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); aspect-ratio: 1; cursor: zoom-in; text-align: left;
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .file-icon { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); padding: 10px; }
.tile .file-icon .ext { font-size: 12px; font-weight: 700; letter-spacing: .05em; }
.tile .file-icon .fname { font-size: 12px; text-align: center; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all; }
.tile .badge { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 6px; }
.tile.missing { opacity: .45; cursor: default; }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile .reveal {
  position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s;
  background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 8px; padding: 5px; cursor: pointer; display: flex;
}
.tile:hover .reveal, .tile:focus-within .reveal { opacity: 1; }

/* Notes */
.note { margin-bottom: 14px; padding: 16px; }
.note-text {
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 15px; line-height: 1.55;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 280px; overflow: auto;
}
.note-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.note-actions .btn { font-size: 13px; padding: 6px 11px; }
.note-actions .spacer { flex: 1; }

/* Incoming */
.incoming { margin-bottom: 14px; padding: 16px; border-color: var(--accent); }
.incoming-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; margin-top: 10px; font-size: 14px; }
.incoming-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.incoming-row .progress { grid-column: 1 / -1; }

/* Empty */
.empty { text-align: center; padding: 48px 24px; }
.empty-art { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.empty p { max-width: 380px; margin: 6px auto 0; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 9, 12, .94); display: flex; align-items: center; justify-content: center; color: #fff; }
.lightbox[hidden] { display: none; }
.lb-top { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 8px; align-items: center; padding: 14px 16px; background: linear-gradient(rgba(0, 0, 0, .6), transparent); }
.lb-top .btn { background: rgba(255, 255, 255, .1); border-color: transparent; color: #fff; }
.lb-top .btn:hover { background: rgba(255, 255, 255, .2); }
.lb-title { flex: 1; min-width: 0; }
.lb-title > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lb-meta { opacity: .7; }
.lb-stage { max-width: calc(100vw - 140px); max-height: calc(100vh - 120px); display: flex; align-items: center; justify-content: center; }
.lb-stage img, .lb-stage video { max-width: calc(100vw - 140px); max-height: calc(100vh - 120px); object-fit: contain; border-radius: 6px; }
.lb-stage .file-big { text-align: center; opacity: .85; }
.lb-stage .file-big .icon { width: 64px; height: 64px; stroke-width: 1.5; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .08); border: 0; color: #fff; border-radius: 50%; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lb-nav:hover { background: rgba(255, 255, 255, .18); }
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 16px; }
.lb-nav[disabled] { opacity: .2; cursor: default; }
@media (max-width: 640px) {
  .lb-stage, .lb-stage img, .lb-stage video { max-width: 100vw; }
  .lb-nav { display: none; }
  .lb-top .btn span { display: none; }
}

/* ---- Web (GitHub Pages) version additions ---- */
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 16px;
  border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: 14px;
}
.banner .icon { color: var(--accent); margin-top: 1px; }
.private-note { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; }
.private-note .icon { margin-top: 2px; color: var(--ok); }
.save-body { min-width: 0; flex: 1; }
.save-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.save-actions .btn { font-size: 13px; padding: 6px 10px; }
.save-actions .hint { font-size: 12.5px; color: var(--muted); }
.warn-row { color: var(--warn); font-size: 13px; }
.footer { margin-top: 24px; text-align: center; }
.saved-badge { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 6px; }
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(8, 9, 12, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay-card { max-width: 420px; text-align: center; padding: 32px 24px; }
.overlay-card h2 { font-size: 19px; margin-bottom: 6px; }
.overlay-card .btn { margin-top: 14px; }
#save-where { word-break: normal; overflow-wrap: anywhere; }
.blocked { border-color: var(--danger); background: var(--danger-soft); }
.blocked h2 { color: var(--danger); }
.blocked p { margin: 6px 0 8px; }
.blocked ul { margin: 0; padding-left: 18px; }
.blocked li { margin: 4px 0; }
.shared-note { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.shared-note kbd { font: 12px ui-monospace, Consolas, monospace; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
