*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: var(--scheme); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

a { color: inherit; }

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 56px 32px 96px;
}

/* Header */
.top {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "date clock" "greeting clock" "search search";
  align-items: end;
  gap: 2px 24px;
  margin-bottom: 44px;
}
.date { grid-area: date; color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.greeting { grid-area: greeting; margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -.01em; }
.clock { grid-area: clock; font-size: 44px; font-weight: 300; font-variant-numeric: tabular-nums; color: var(--muted); line-height: 1; }

.search {
  grid-area: search;
  position: relative;
  margin-top: 24px;
}
.search i {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  font: inherit; font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* Groups */
.group { margin-bottom: 36px; }
.group-title {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 14px;
  font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted);
}
.group-title i { color: var(--accent); font-size: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

/* Link card: icon left, title upper right, description lower right */
.card {
  display: flex; align-items: center; gap: 14px;
  min-width: 0;
  padding: 12px 14px;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background-color .15s, border-color .15s, transform .15s;
}
.card:hover, .card:focus-visible {
  background: var(--surface-hover);
  border-color: var(--accent);
  outline: none;
}
.card:active { transform: scale(.98); }
.card.hit { border-color: var(--accent); }

.card-icon {
  flex: none;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  font-size: 22px;
  color: var(--accent);
}
.card-icon .letter {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  font-size: 17px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.card-text { display: flex; flex-direction: column; min-width: 0; }
.card-title, .card-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { font-weight: 600; font-size: 15px; }
.card-desc { color: var(--muted); font-size: 13px; }

.empty, .no-match { color: var(--muted); text-align: center; padding: 40px 0; }

/* Theme picker */
.theme-picker { position: fixed; right: 20px; bottom: 20px; z-index: 10; }
.theme-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 17px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.theme-btn:hover, .theme-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.theme-menu {
  position: absolute; right: 0; bottom: 52px;
  margin: 0; padding: 6px;
  list-style: none;
  min-width: 200px;
  max-height: 70vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.theme-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
}
.theme-menu a:hover { background: var(--surface-hover); }
.theme-menu a[aria-current="true"] { color: var(--accent); font-weight: 600; }
.swatch {
  flex: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bg) 0 50%, var(--accent) 50% 100%);
  border: 1px solid var(--border);
}

@media (max-width: 640px) {
  .wrap { padding: 32px 16px 88px; }
  .top { margin-bottom: 32px; }
  .greeting { font-size: 26px; }
  .clock { font-size: 32px; }
  .grid { grid-template-columns: 1fr; gap: 8px; }
}
