:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --ink: #17191c;
  --muted: #6a7079;
  --line: #e4e6e2;
  --accent: #2547e0;
  --chip: #eef0f4;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px; height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brandmark { font-weight: 650; letter-spacing: -0.02em; font-size: 17px; }
.who { color: var(--muted); }
.pagehead-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.btn.bookmark { background: var(--surface); color: var(--ink); border: 1px solid var(--line); white-space: nowrap; }
.btn.bookmark:hover { border-color: #c9cdc7; }
.btn.bookmark.on { background: #fff7e0; border-color: #f0d98a; color: #8a6d1a; }
.brandmark span { color: var(--accent); }
.nav { display: flex; gap: 20px; }
.nav a { color: var(--muted); font-size: 14px; font-weight: 500; }
.nav a.active, .nav a:hover { color: var(--ink); text-decoration: none; }
.spacer { flex: 1; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}

.layout { display: grid; grid-template-columns: 220px 1fr; gap: 0; }
.sidebar {
  border-right: 1px solid var(--line); padding: 22px 18px; min-height: calc(100vh - 56px);
  background: var(--surface);
}
.sidebar h3 { margin: 0 0 12px; }
.sidebar ul { list-style: none; margin: 0 0 24px; padding: 0; }
.sidebar li a {
  display: flex; justify-content: space-between; padding: 5px 8px;
  border-radius: 6px; color: var(--ink); font-size: 14px;
}
.sidebar li a:hover { background: var(--bg); text-decoration: none; }
.sidebar li a.active { background: #eef1fd; color: var(--accent); }
.sidebar li a .n { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.main { padding: 26px 28px; }
.pagehead { display: flex; align-items: baseline; gap: 14px; margin-bottom: 20px; }
.pagehead h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }

.filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filters input[type=search] {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; min-width: 240px; background: var(--surface);
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s;
}
.card:hover { border-color: #c9cdc7; text-decoration: none; }
.card .thumb {
  aspect-ratio: 4/3; background: linear-gradient(180deg,#fbfbfa,#eef0ec);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
  font-family: var(--mono); font-size: 12px; border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.card .body { padding: 12px 14px; }
.card .from { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card .subj { color: var(--ink); font-weight: 550; margin: 4px 0 10px; font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; justify-content: space-between; align-items: center; }
.card .date { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.chip {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 20px; background: #eef0ec; color: #4a4f57; text-transform: uppercase;
}
.chip.promotional { background: #fdeede; color: #9a5a12; }
.chip.newsletter { background: #e6f0fb; color: #1f5aa8; }
.chip.transactional-adjacent { background: #eae9f6; color: #55499b; }

.detail { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
.detail iframe { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 10px; background:#fff; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; height: fit-content; }
.panel dl { margin: 0; }
.panel dt { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 14px; }
.panel dd { margin: 3px 0 0; font-size: 14px; word-break: break-word; }

.card-box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-top: 12px; }
.bars .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars .bar:hover { opacity: 1; }
.axis { display: flex; gap: 4px; margin-top: 6px; }
.axis span { flex: 1; text-align: center; font-family: var(--mono); font-size: 10px; color: var(--muted); }
.rows .row { display: grid; grid-template-columns: 130px 1fr 48px; align-items: center; gap: 12px; padding: 6px 0; }
.rows .track { background: var(--bg); border-radius: 6px; height: 10px; overflow: hidden; }
.rows .fill { background: var(--accent); height: 100%; }
.rows .row .n { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }

form.inline { display: flex; gap: 8px; align-items: center; }
input[type=text], input[type=email], input[type=password] {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--surface);
}
.btn {
  padding: 9px 16px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
table.inboxes { width: 100%; border-collapse: collapse; }
table.inboxes td, table.inboxes th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.inboxes th { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.login-wrap { max-width: 360px; margin: 12vh auto; padding: 0 20px; }
.login-wrap h1 { letter-spacing: -0.02em; }
.login-wrap form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.login-wrap input { width: 100%; }
.err { color: #b4231f; font-size: 14px; margin-top: 10px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.hint { color: var(--muted); font-size: 13px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; } .sidebar { min-height: 0; }
  .detail { grid-template-columns: 1fr; }
}

/* gallery pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 28px 0 8px; }
.pager-info { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.btn.ghost.disabled { opacity: .4; pointer-events: none; }

/* settings: storage + status */
.storage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.storage-grid .big { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.status { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.status.ok { background: #e4f5ea; color: #1c7a43; }
.status.syncing { background: #eef0f4; color: #55617a; }
.status.paused { background: #f0efe9; color: #7a7563; }
.status.err { background: #fbe6e4; color: #a8342a; cursor: help; }
.err-detail { color: #a8342a; }
@media (max-width: 640px) { .storage-grid { grid-template-columns: 1fr; gap: 12px; } }

/* brand selector bar (trends + calendar) */
.brandbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brandbar label { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); }
.brandbar select { font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--ink); min-width: 200px; cursor: pointer; }
.brandbar select:hover { border-color: #c9cdc7; }

/* calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-title { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); text-align: center; padding-bottom: 4px; }
.cal-cell { position: relative; aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); padding: 6px; overflow: hidden; }
.cal-cell.muted { opacity: .4; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-num { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.cal-link { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; color: var(--ink); }
.cal-link:hover { text-decoration: none; }
.cal-link .cal-num { position: absolute; top: 6px; left: 8px; }
.cal-count { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.cal-link.hot { color: #fff; }
.cal-link.hot .cal-num { color: rgba(255,255,255,.8); }
@media (max-width: 640px) {
  .cal-count { font-size: 15px; } .cal-cell { padding: 4px; }
}
