:root {
  color-scheme: light;
  --ink: #17181c;
  --muted: #5d6470;
  --line: rgba(255, 255, 255, 0.44);
  --paper: #eaf1fb;
  --panel: rgba(255, 255, 255, 0.58);
  --green: #25a244;
  --blue: #2477f2;
  --red: #ff453a;
  --gold: #ffb020;
  --purple: #9b5cff;
  --cyan: #26bfd1;
  --shadow: 0 18px 48px rgba(45, 55, 72, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --glass-highlight: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.34));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% 0%, rgba(36, 119, 242, 0.22), transparent 28rem),
    radial-gradient(circle at 88% 8%, rgba(155, 92, 255, 0.18), transparent 24rem),
    linear-gradient(180deg, #f8fbff 0%, var(--paper) 58%, #edf3f8 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html.ios-device body {
  min-width: 0;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0 16px;
}

.safari-recent {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
}

.safari-recent:empty {
  display: none;
}

.safari-recent a {
  max-width: 190px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.46);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

.safari-recent a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.12;
  font-weight: 500;
}

h2 {
  font-size: 16px;
  font-weight: 500;
}

.daily-briefing {
  margin-bottom: 14px;
  padding: 14px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--glass-highlight), var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  border-left: 4px solid var(--blue);
  color: var(--ink);
  max-height: none;
  overflow: visible;
  break-inside: avoid;
  page-break-inside: avoid;
}

.daily-briefing h2 {
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 700;
}

.system-status {
  margin-bottom: 14px;
  padding: 12px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--glass-highlight), rgba(255, 255, 255, 0.48);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.system-status-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.system-status h2 {
  color: var(--ink);
  font-weight: 700;
}

.stale-warning {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.stale-warning.is-stale {
  color: #9a5a00;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.status-tile {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.status-tile.connected .status-dot {
  background: var(--green);
}

.status-tile.error .status-dot {
  background: var(--red);
}

.status-tile strong,
.status-tile span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-tile strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.1;
}

.status-tile span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.status-tile b {
  color: #174ea6;
  font-size: 14px;
}

#daily-briefing {
  color: #40474d;
  font-size: 14px;
  line-height: 1.25;
  margin: 0;
  padding: 0;
  white-space: normal;
}

#daily-briefing .briefing-section {
  margin: 8px 0 0;
  padding: 0;
}

#daily-briefing .briefing-section:first-child {
  margin-top: 0;
}

#daily-briefing .briefing-section h3 {
  margin: 0 0 2px;
  padding: 0;
  color: #174ea6;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
}

#daily-briefing .briefing-section p {
  color: #40474d;
  font-size: 14px;
  line-height: 1.25;
  margin: 0;
  padding: 0;
}

#daily-briefing .briefing-section ul {
  display: block;
  margin: 0;
  padding: 0 0 0 16px;
}

#daily-briefing .briefing-section li {
  color: #40474d;
  line-height: 1.24;
  font-size: 14px;
  margin: 0;
  padding: 0;
}

#daily-briefing .summary-sender {
  color: var(--ink);
  font-weight: 800;
}

#daily-briefing .briefing-state {
  color: #40474d;
  font-size: 14px;
  line-height: 1.25;
  margin: 0;
}

#daily-briefing .briefing-state.error {
  color: var(--red);
  font-weight: 700;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

#refresh {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass-highlight), var(--panel);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

#refresh.spinning svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#refresh svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--glass-highlight), var(--panel);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  overflow: hidden;
}

.panel:nth-child(1) {
  border-top: 3px solid var(--green);
}

.side-stack .panel:nth-child(1) {
  border-top: 3px solid var(--red);
}

.side-stack .panel:nth-child(2) {
  border-top: 3px solid var(--purple);
}

.compact-panel {
  align-self: start;
  height: fit-content;
  padding-bottom: 0;
}

.side-stack {
  display: grid;
  gap: 14px;
  align-self: start;
}

.compact-panel .panel-head {
  margin-bottom: 0;
}

.compact-panel .item:last-child {
  padding-bottom: 0;
}

.compact-panel .empty {
  min-height: 56px;
  padding: 14px;
}

.wide {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 0;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.36);
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.34);
  padding: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.segmented button,
.toggle {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.segmented button {
  padding: 0 12px;
  border-radius: 999px;
}

.segmented button.active,
.toggle[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.72);
  color: #1459c9;
  box-shadow: 0 6px 18px rgba(36, 119, 242, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.toggle {
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.44);
}

.feed {
  display: grid;
  gap: 0;
}

.item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
}

.item:first-child {
  border-top: 0;
}

.dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--blue);
}

.dot.whatsapp {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(24, 128, 56, 0.12);
}

.dot.imessage {
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.dot.email {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 153, 0, 0.14);
}

.dot.teams {
  background: #6264a7;
  box-shadow: 0 0 0 3px rgba(98, 100, 167, 0.14);
}

.dot.event {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.12);
}

.title {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.title:hover {
  text-decoration: underline;
}

.item-summary {
  margin-top: 4px;
  color: #2f3540;
  font-size: 14px;
  line-height: 1.42;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  color: #46505c;
  font-size: 12px;
  font-weight: 750;
}

.item[data-source="whatsapp"] .pill {
  background: rgba(37, 162, 68, 0.14);
  color: #137333;
}

.item[data-source="imessage"] .pill {
  background: rgba(36, 119, 242, 0.14);
  color: #174ea6;
}

.item[data-source="email"] .pill {
  background: rgba(255, 176, 32, 0.17);
  color: #9a5a00;
}

.item[data-source="teams"] .pill {
  background: rgba(98, 100, 167, 0.15);
  color: #464775;
}

#todos .pill {
  background: rgba(155, 92, 255, 0.15);
  color: #6a1b9a;
}

.time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.empty {
  min-height: 132px;
  display: grid;
  place-items: center;
  border-top: 0;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.compact .item {
  grid-template-columns: auto minmax(0, 1fr);
}

.compact .time {
  grid-column: 2;
}

.todo-item {
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
}

.todo-item .dot {
  margin-top: 0;
}

.todo-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.todo-line .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-item .time {
  font-size: 12px;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .wide {
    grid-row: auto;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1440px);
    padding-top: 16px;
  }

  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 28px;
  }

  .item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .system-status-head {
    align-items: start;
    flex-direction: column;
  }

  .stale-warning {
    text-align: left;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .time {
    grid-column: 2;
  }
}

@media (max-width: 820px) {
  html.ios-device .shell {
    width: 100%;
    padding: calc(12px + env(safe-area-inset-top)) 10px calc(28px + env(safe-area-inset-bottom));
  }

  html.ios-device .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    padding: 4px 2px 12px;
  }

  html.ios-device .topbar > div:first-child {
    min-width: 0;
  }

  html.ios-device h1 {
    font-size: 26px;
    font-weight: 650;
  }

  html.ios-device .status {
    justify-self: end;
    gap: 8px;
    font-size: 12px;
  }

  html.ios-device #generated {
    max-width: 92px;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html.ios-device #refresh {
    width: 38px;
    height: 38px;
  }

  html.ios-device .safari-recent {
    grid-column: 1 / -1;
    order: 3;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding: 1px 0 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  html.ios-device .safari-recent::-webkit-scrollbar {
    display: none;
  }

  html.ios-device .safari-recent a {
    flex: 0 0 auto;
    max-width: 72vw;
    padding: 8px 11px;
    font-size: 12px;
  }

  html.ios-device .daily-briefing {
    margin-bottom: 10px;
    padding: 12px 13px 13px;
    border-radius: 20px;
  }

  html.ios-device #daily-briefing,
  html.ios-device #daily-briefing .briefing-section li {
    font-size: 13px;
    line-height: 1.26;
  }

  html.ios-device #daily-briefing .briefing-section {
    margin-top: 7px;
  }

  html.ios-device .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  html.ios-device .side-stack {
    gap: 10px;
  }

  html.ios-device .panel {
    border-radius: 20px;
  }

  html.ios-device .panel-head {
    align-items: stretch;
    gap: 10px;
    padding: 11px 12px;
  }

  html.ios-device .panel-head h2 {
    font-size: 15px;
    font-weight: 700;
  }

  html.ios-device .segmented {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  html.ios-device .segmented::-webkit-scrollbar {
    display: none;
  }

  html.ios-device .segmented button {
    flex: 1 0 auto;
    min-height: 38px;
    padding: 0 11px;
  }

  html.ios-device .item {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
    padding: 11px 12px;
  }

  html.ios-device .item .time {
    grid-column: 2;
    justify-self: start;
    margin-top: 2px;
    font-size: 12px;
  }

  html.ios-device .title {
    font-size: 14px;
    line-height: 1.25;
  }

  html.ios-device .item-summary {
    font-size: 13px;
    line-height: 1.34;
  }

  html.ios-device .meta {
    gap: 5px;
    font-size: 12px;
  }

  html.ios-device .pill {
    min-height: 19px;
    font-size: 11px;
  }

  html.ios-device .todo-item {
    padding: 8px 12px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .daily-briefing,
  .panel {
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #ffffff;
    border-color: #cccccc;
  }

  .daily-briefing {
    max-height: none;
    overflow: visible;
  }
}
