:root { color-scheme: light dark; }
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; padding: 1.5rem; background: #fafafa; color: #222; }
main { max-width: 80%; margin: 0 auto; }
main.splash { max-width: 360px; text-align: center; padding-top: 6vh; }
main.splash h1 { margin-bottom: .25rem; }
main.splash .lede { color: #666; margin-top: 0; }
h1 { margin: 0 0 1rem; }
h2 { margin: 0 0 .75rem; font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: #555; }

header.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
header.topbar h1 { margin: 0; }
header.topbar #menu-btn {
  background: none; border: 1px solid #ccc; border-radius: 6px;
  padding: .25rem .6rem; font-size: 1.25rem; line-height: 1; cursor: pointer; color: #666;
  -webkit-tap-highlight-color: rgba(0, 102, 255, 0.15);
}
header.topbar #menu-btn:hover { color: #06f; border-color: #06f; }

/* Bottom-sheet menu (dropnotes pattern) */
#menu-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; z-index: 50;
}
#menu-backdrop.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top-left-radius: 14px; border-top-right-radius: 14px;
  padding: .75rem 1rem 1.5rem; max-height: 70vh; overflow-y: auto;
  display: none;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}
.sheet.open { display: block; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: #ddd; margin: .25rem auto .75rem; }
.sheet-title { text-align: center; font-size: .8rem; color: #888; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .5rem; }
.sheet-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem .5rem; border-radius: 8px; cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 102, 255, 0.15);
}
.sheet-item:active { background: #f0f7ff; }
.sheet-item .sheet-icon { font-size: 1.2rem; width: 1.5rem; text-align: center; }
.sheet-item .sheet-label { font-size: 1rem; }
.sheet-divider { height: 1px; background: #e0e0e0; margin: .35rem .5rem; }
.sheet-item.sheet-destructive { color: #c0392b; }
.sheet-item.sheet-destructive:active { background: #fde2e2; }
.sheet-item[hidden] { display: none; }

section { margin-bottom: 2rem; padding: 1rem; background: #fff; border: 1px solid #e0e0e0; border-radius: 6px; }
section.panel { padding: 1rem; }
section[hidden] { display: none; }
.drop {
  display: block; padding: 2rem; border: 2px dashed #999; border-radius: 8px;
  text-align: center; cursor: pointer; background: #fff; margin-bottom: 1rem;
}
.drop.hot { border-color: #06f; background: #eef4ff; }
fieldset { display: grid; gap: .5rem; border: 1px solid #ddd; border-radius: 6px; padding: .75rem; margin-bottom: 1rem; }
label { display: grid; gap: .25rem; }
input, select, button { font: inherit; padding: .5rem; border-radius: 4px; border: 1px solid #ccc; }
button { background: #06f; color: #fff; border: none; cursor: pointer; }
button:hover { background: #05d; }
#result { margin-top: 1rem; }
#url { width: 100%; font-family: ui-monospace, monospace; }
#err { color: #c00; }
.logout { margin-top: 2rem; text-align: center; display: flex; gap: 1rem; justify-content: center; align-items: center; }
.logout a, .logout button { color: #666; font-size: .875rem; }
.logout button { background: #06f; color: #fff; border: none; padding: .35rem .75rem; border-radius: 4px; }
.logout button:hover { background: #05d; }

.ios-hint {
  margin: 1rem auto 0; max-width: 480px; padding: .75rem 1rem;
  background: #f0f7ff; border: 1px solid #b6d4fe; border-radius: 6px;
  color: #1e40af; font-size: .9rem; text-align: center;
}
@media (prefers-color-scheme: dark) {
  .ios-hint { background: #1e3a8a; border-color: #3b82f6; color: #dbeafe; }
}

[data-idx]:focus { outline: 2px solid #06f; outline-offset: -2px; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.kpi { display: flex; flex-direction: column; padding: .75rem; background: #fafafa; border: 1px solid #e0e0e0; border-radius: 6px; }
.kpi label { font-size: .75rem; color: #666; text-transform: uppercase; letter-spacing: .04em; }
.kpi span { font-size: 1.5rem; font-weight: 600; margin-top: .25rem; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
table th, table td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #eee; }
table th { font-size: .75rem; color: #666; text-transform: uppercase; }
table td code { font-family: ui-monospace, monospace; }
table td.ua { overflow: hidden; text-overflow: ellipsis; }
.muted { color: #888; }

tr[data-idx] { cursor: pointer; }
tr[data-idx]:hover { background: rgba(0,0,0,0.03); }
@media (prefers-color-scheme: dark) {
  tr[data-idx]:hover { background: rgba(255,255,255,0.04); }
}
tr[data-idx].open td.chev::before { content: '▼'; }
tr[data-idx] td.chev::before { content: '▶'; font-size: .75rem; color: #888; }
tr.detail > td { background: #fafafa; padding: .5rem 1rem; }
@media (prefers-color-scheme: dark) {
  tr.detail > td { background: #1f1f1f; }
}
tr.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; margin: 0; font-size: .8125rem; }
tr.detail dt { color: #666; text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; align-self: center; }
tr.detail dd { margin: 0; word-break: break-all; }

td.actions { white-space: nowrap; display: flex; gap: .25rem; align-items: center; }
td.actions button { padding: .25rem .5rem; font-size: .75rem; }
button.danger { background: #c0392b; }
button.danger:hover { background: #a83224; }

.tag-dl, .tag-del, .tag-pwd {
  display: inline-block; font-size: .65rem; padding: .05rem .35rem; border-radius: 3px;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
}
.tag-dl { background: #dbeafe; color: #1e40af; }
.tag-del { background: #fee2e2; color: #991b1b; }
.tag-pwd { background: #fef3c7; color: #92400e; margin-left: .25rem; }
@media (prefers-color-scheme: dark) {
  .tag-dl { background: #1e3a8a; color: #dbeafe; }
  .tag-del { background: #7f1d1d; color: #fee2e2; }
  .tag-pwd { background: #78350f; color: #fef3c7; }
}

@media (prefers-color-scheme: dark) {
  body { background: #1a1a1a; color: #eee; }
  section { background: #232323; border-color: #333; }
  .drop, fieldset, input, select { background: #2a2a2a; color: #eee; border-color: #444; }
  .kpi { background: #1f1f1f; border-color: #333; }
  table th, table td { border-bottom-color: #333; }
  .sheet { background: #232323; }
  .sheet-item.sheet-destructive { color: #f87171; }
  .sheet-item.sheet-destructive:active { background: #7f1d1d; }
  .sheet-item:active { background: #1e3a8a; }
  .sheet-divider { background: #333; }
  header.topbar #menu-btn { color: #aaa; border-color: #444; }
}
