:root {
  --bg: #eef2f4;
  --glow: rgba(15, 118, 110, 0.14);
  --glow-2: rgba(184, 98, 42, 0.1);
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --text: #16202a;
  --muted: #4a5968;
  --line: #dbe2e8;
  --accent: #0f766e;
  --accent-contrast: #ffffff;
  --mark: #0f766e;
  --accent-soft: #e5f4f2;
  --warm: #8a4b16;
  --sponsored-bg: #f8f1ea;
  --shadow: 0 12px 32px rgba(22, 32, 42, 0.07);
  --danger: #8f2d2d;
  --focus: #0f766e;
  --radius: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #101418;
  --glow: rgba(94, 234, 212, 0.09);
  --glow-2: rgba(240, 178, 122, 0.08);
  --surface: #1b222b;
  --surface-2: #232c36;
  --text: #e8eef4;
  --muted: #a8b8c6;
  --line: #31404d;
  --accent: #117a72;
  --accent-contrast: #ffffff;
  --mark: #5eead4;
  --accent-soft: #143330;
  --warm: #f0b27a;
  --sponsored-bg: #2a2118;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  --danger: #ffb4b4;
  --focus: #7ee0d8;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 8% -10%, var(--glow), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, var(--glow-2), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 5;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

main {
  flex: 1;
  padding-bottom: 28px;
}

main[tabindex="-1"]:focus {
  outline: none;
}

.header-row,
.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 20px;
}

.header-row {
  padding: 22px 0 6px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 32px;
  height: 32px;
}

.brand-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.brand-name span {
  color: var(--mark);
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.clock {
  line-height: 1.15;
  text-align: right;
  margin-right: 4px;
}

.clock time {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.clock span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.text-btn,
.primary-btn,
.mini-btn {
  border-radius: 999px;
}

.text-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
  padding: 8px 12px;
}

.primary-btn {
  border: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  min-height: 44px;
  padding: 0 18px;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.search-section {
  margin: 28px 0 8px;
}

.search-form {
  display: flex;
  align-items: stretch;
  gap: 6px;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.search-form:focus-within {
  border-color: var(--focus);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
}

.engine-select {
  border: 0;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 0 12px 0 14px;
  font-weight: 700;
  min-height: 44px;
}

.search-field {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
}

.search-form input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0 12px;
  font-size: 1.05rem;
}

.search-form input::-webkit-search-cancel-button,
.search-form input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-form input:focus-visible {
  outline: none;
}

.search-clear {
  flex: none;
  width: 36px;
  height: 36px;
  margin-right: 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  padding: 0;
}

.search-clear:hover {
  background: var(--surface-2);
  color: var(--text);
}

.search-form input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.notice,
.edit-hint,
.empty-note,
.status {
  color: var(--muted);
  font-size: 0.92rem;
}

.notice {
  max-width: 760px;
  margin: 14px auto 0;
  padding: 10px 14px;
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 12px;
}

.shortcuts {
  margin-top: 28px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status:not(:empty) {
  margin: 8px 0 12px;
  color: var(--text);
}

.category-title {
  margin: 18px 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.25rem, 1fr));
  gap: 12px;
  align-items: stretch;
}

.grid > li {
  display: flex;
  min-width: 0;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 108px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(16, 20, 24, 0.03);
  color: inherit;
  text-align: left;
  text-decoration: none;
}

@media (hover: hover) {
  .tile:hover {
    transform: translateY(-2px);
    border-color: transparent;
    box-shadow: var(--shadow);
  }
}

.tile-add {
  align-items: center;
  justify-content: center;
  text-align: center;
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  min-height: 108px;
}

.tile-add span {
  color: var(--text);
  font-weight: 700;
}

.mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--mark-bg);
  color: var(--mark-ink);
  font-weight: 700;
}

.mark .icon {
  width: 22px;
  height: 22px;
}

.mark .site-icon {
  object-fit: contain;
  border-radius: 4px;
}

.tile-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
}

.tile-name {
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tile-category {
  color: var(--muted);
  font-size: 0.78rem;
}

.cat-personal { --mark-bg: #f8e7f1; --mark-ink: #7a3160; }
.cat-email { --mark-bg: #e4f0ff; --mark-ink: #1d4e89; }
.cat-shopping { --mark-bg: #fdecd8; --mark-ink: #8a4b16; }
.cat-banking { --mark-bg: #e5f6ea; --mark-ink: #1d6b3a; }
.cat-news { --mark-bg: #fde8e8; --mark-ink: #8d2f2f; }
.cat-travel { --mark-bg: #e7f6f4; --mark-ink: #0f5c56; }
.cat-entertainment { --mark-bg: #f0e9fb; --mark-ink: #5b3d86; }
.cat-utilities { --mark-bg: #e8eef5; --mark-ink: #33475b; }

html[data-theme="dark"] .cat-personal { --mark-bg: #3d2434; --mark-ink: #f6c6e0; }
html[data-theme="dark"] .cat-email { --mark-bg: #1c3348; --mark-ink: #c5ddff; }
html[data-theme="dark"] .cat-shopping { --mark-bg: #3a2a1c; --mark-ink: #ffd7b0; }
html[data-theme="dark"] .cat-banking { --mark-bg: #173224; --mark-ink: #b7ebc8; }
html[data-theme="dark"] .cat-news { --mark-bg: #3a2020; --mark-ink: #ffc9c9; }
html[data-theme="dark"] .cat-travel { --mark-bg: #143330; --mark-ink: #b7f3ec; }
html[data-theme="dark"] .cat-entertainment { --mark-bg: #2d2340; --mark-ink: #e0d0fb; }
html[data-theme="dark"] .cat-utilities { --mark-bg: #243140; --mark-ink: #d5e2ef; }

.tile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
  margin-top: auto;
}

.mini-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  min-height: 36px;
  padding: 4px 6px;
  font-size: 0.78rem;
}

.danger-btn {
  color: var(--danger);
}

.editing .tile[data-shortcut-id] {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.editing .tile button {
  cursor: pointer;
}

.editing .tile.is-dragging {
  opacity: 0.55;
  pointer-events: none;
}

.editing .tile.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.icon {
  display: block;
}

.weather {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 760px;
  margin: 16px auto 0;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.weather p {
  margin: 0;
}

.weather-now {
  font-weight: 700;
}

.weather-source,
.weather-source a {
  color: var(--muted);
  font-size: 0.82rem;
}

.sponsored {
  margin-top: 36px;
  padding: 16px 18px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--sponsored-bg);
}

.sponsored .section-head {
  margin-bottom: 10px;
}

.sponsored-empty {
  margin: 0;
  color: var(--muted);
}

.sponsored-empty a,
.prose a,
.weather a {
  color: var(--mark);
  text-underline-offset: 2px;
}

.prose a {
  text-decoration-thickness: 1px;
}

.sponsored-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.sponsored-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(100%, 280px);
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.sponsored-image {
  width: 100%;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--mark-bg);
}

.kicker {
  color: var(--warm);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sponsored-name {
  font-weight: 700;
}

.sponsored-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 18px 0 28px;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-row {
  flex-wrap: wrap;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.footer-nav a {
  color: inherit;
  text-decoration: none;
}

.footer-nav a:hover,
.footer-nav a:focus-visible,
.footer-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer p {
  margin: 0;
}

.prose {
  max-width: 68ch;
  padding-top: 12px;
  overflow-wrap: anywhere;
}

.prose h1 {
  margin: 8px 0 8px;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.prose h2 {
  margin: 28px 0 8px;
  font-size: 1.15rem;
}

.prose p,
.prose li {
  color: var(--text);
}

.page-intro {
  color: var(--muted);
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(16, 20, 24, 0.55);
}

#shortcut-form {
  padding: 22px;
}

#shortcut-dialog-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.field-help {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.link-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-row input {
  flex: 1;
  min-width: 0;
}

.favicon-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.favicon-preview[hidden] {
  display: none;
}

.favicon-preview img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.favicon-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.form-error {
  min-height: 1.3em;
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 0.92rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 640px) {
  .shell {
    width: min(1080px, calc(100% - 24px));
  }

  .topbar-tools {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    border-radius: 18px;
  }

  .engine-select {
    grid-column: 1 / -1;
  }

  .header-row {
    padding-top: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .tile:hover {
    transform: none;
  }
}

@media print {
  .topbar-tools,
  .search-section,
  .sponsored,
  .tile-add,
  .tile-actions,
  .section-actions {
    display: none !important;
  }
}
