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

/* Colors: light-dark(light, dark) pairs, plus every color again in the dusk block below. */

:root {
  color-scheme: light dark;

  --page-bg: light-dark(#edf2f9, #0e131b);
  --panel-bg: light-dark(#f4f7fc, #131a24);
  --panel-border: light-dark(#e6ecf5, #1e2733);

  --card-bg: light-dark(#f9fbfe, #161e29);
  --card-border: light-dark(#edf1f7, #202a37);
  --card-live-bg: light-dark(#ffffff, #1b2431);
  --card-live-border: light-dark(#c6d5ee, #4f70a8);
  --card-live-border-hover: light-dark(#9fb9e6, #6f8fcc);

  --text-strong: light-dark(#0f172a, #e7ecf4);
  --text-body: light-dark(#334155, #b8c2d1);
  --text-muted: light-dark(#6b7280, #8b95a5);
  --text-faint: light-dark(#868d9b, #6b7585);

  --accent: light-dark(#1d4ed8, #8fb3ff);
  --accent-soft: light-dark(#dce8fd, #1c2d4d);
  --on-accent: light-dark(#ffffff, #0b1530);
  --danger: light-dark(#b42318, #ff8a7a);
  --tile-muted: light-dark(#e3e8f0, #1f2833);
  --icon-muted: light-dark(#5f6878, #8b95a5);
  --chevron-muted: light-dark(#a3aab6, #5b6676);

  --focus-ring: light-dark(rgb(29 78 216 / 0.7), rgb(143 179 255 / 0.6));
  --shadow-panel:
    0 1px 2px light-dark(rgb(15 23 42 / 0.03), rgb(0 0 0 / 0.3)),
    0 24px 48px -28px light-dark(rgb(30 58 110 / 0.14), rgb(0 0 0 / 0.6));
  --shadow-card:
    0 1px 2px light-dark(rgb(15 23 42 / 0.03), rgb(0 0 0 / 0.25)),
    0 6px 16px -10px light-dark(rgb(30 58 110 / 0.12), rgb(0 0 0 / 0.5));
  --shadow-card-live:
    0 1px 2px light-dark(rgb(29 78 216 / 0.05), rgb(0 0 0 / 0.3)),
    0 10px 24px -14px light-dark(rgb(29 78 216 / 0.22), rgb(0 0 0 / 0.6));
  --shadow-card-live-hover:
    0 1px 2px light-dark(rgb(29 78 216 / 0.06), rgb(0 0 0 / 0.35)),
    0 16px 32px -16px light-dark(rgb(29 78 216 / 0.3), rgb(0 0 0 / 0.7));

  --radius-panel: 16px;
  --radius-card: 12px;
  --radius-tile: 12px;

  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="dusk"] {
  color-scheme: light;

  --page-bg: #e8d9bd;
  --panel-bg: #ecdfc6;
  --panel-border: #dccab0;

  --card-bg: #efe4cf;
  --card-border: #e2d2b6;
  --card-live-bg: #f4ead8;
  --card-live-border: #a97b48;
  --card-live-border-hover: #8d5e2c;

  --text-strong: #3b2a18;
  --text-body: #55402a;
  --text-muted: #6b553c;
  --text-faint: #8d7656;

  --accent: #94480f;
  --accent-soft: #ecd3ad;
  --on-accent: #fff6e8;
  --danger: #9e2a1c;
  --tile-muted: #e3d3b6;
  --icon-muted: #6b553c;
  --chevron-muted: #9a8466;

  --focus-ring: rgb(148 72 15 / 0.8);
  --shadow-panel:
    0 1px 2px rgb(90 60 20 / 0.04),
    0 24px 48px -28px rgb(90 60 20 / 0.16);
  --shadow-card:
    0 1px 2px rgb(90 60 20 / 0.04),
    0 6px 16px -10px rgb(90 60 20 / 0.14);
  --shadow-card-live:
    0 1px 2px rgb(90 60 20 / 0.06),
    0 10px 24px -14px rgb(90 60 20 / 0.22);
  --shadow-card-live-hover:
    0 1px 2px rgb(90 60 20 / 0.08),
    0 16px 32px -16px rgb(90 60 20 / 0.3);
}

html {
  -webkit-text-size-adjust: 100%;
  accent-color: var(--accent);
  scrollbar-color: var(--chevron-muted) var(--page-bg);
}

::selection {
  background: var(--accent-soft);
  color: var(--text-strong);
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--page-bg);
  color: var(--text-strong);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.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;
}

/* Header */

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 16px clamp(16px, 5vw, 64px) 0;
}

.theme-switch {
  display: inline-flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  background: var(--tile-muted);
  border-radius: 10px;
}

.theme-switch__option {
  display: grid;
  place-items: center;
  width: 38px;
  height: 44px;
  padding: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--icon-muted);
  cursor: pointer;
}

.theme-switch__option svg {
  width: 18px;
  height: 18px;
}

.theme-switch__option:hover {
  color: var(--text-strong);
}

.theme-switch__option[aria-pressed="true"] {
  background: var(--card-live-bg);
  border-color: var(--card-live-border);
  box-shadow: var(--shadow-card);
  color: var(--text-strong);
}

.theme-switch__option:focus-visible {
  position: relative;
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.account-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  color: var(--text-body);
  font-size: 14px;
  text-decoration: none;
}

.account-control__avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.account-control__avatar-bg {
  fill: var(--tile-muted);
}

.account-control__avatar-figure {
  fill: var(--icon-muted);
}

.account-control__action {
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--card-live-border);
  border-radius: 8px;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.account-control__action:hover,
a.account-control:hover .account-control__action {
  border-color: var(--card-live-border-hover);
}

.account-control__action:focus-visible,
a.account-control:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

@media (max-width: 560px) {
  .account-control__name {
    display: none;
  }
}

/* Main area */

.site-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: clamp(16px, 5vw, 64px);
}

.messages {
  width: 100%;
  max-width: 1040px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.messages li {
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-card);
  color: var(--text-strong);
  font-size: 14px;
}

/* Panel */

.portal {
  width: 100%;
  max-width: 1040px;
  padding: clamp(20px, 5vw, 56px) clamp(16px, 4.5vw, 46px) clamp(24px, 6vw, 64px);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}

/* Grid */

.app-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.app-grid > li {
  display: flex;
}

@media (max-width: 860px) {
  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* Card */

.app-card {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "icon ."
    "body chevron";
  align-content: start;
  row-gap: 14px;
  column-gap: 16px;
  min-height: 176px;
  padding: 20px 28px 20px 26px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  color: inherit;
  text-decoration: none;
}

.app-card__icon {
  grid-area: icon;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-tile);
}

.app-card__icon svg {
  width: 30px;
  height: 30px;
}

.app-card__body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.app-card__title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.app-card__desc {
  font-size: 14px;
  line-height: 1.45;
}

.app-card__chevron {
  grid-area: chevron;
  align-self: center;
  width: 20px;
  height: 20px;
}

/* Live app */

.app-card--live {
  background: var(--card-live-bg);
  border-color: var(--card-live-border);
  box-shadow: var(--shadow-card-live);
}

.app-card--live .app-card__icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.app-card--live .app-card__title {
  color: var(--text-strong);
}

.app-card--live .app-card__desc {
  color: var(--text-body);
}

.app-card--live .app-card__chevron {
  color: var(--text-strong);
}

.app-card--live:hover {
  border-color: var(--card-live-border-hover);
  box-shadow: var(--shadow-card-live-hover);
}

.app-card--live:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  .app-card--live {
    transition:
      transform 180ms ease-out,
      box-shadow 180ms ease-out,
      border-color 180ms ease-out;
  }

  .app-card--live .app-card__chevron {
    transition: transform 180ms ease-out;
  }

  .app-card--live:hover {
    transform: translateY(-2px);
  }

  .app-card--live:hover .app-card__chevron {
    transform: translateX(3px);
  }
}

/* Coming soon */

.app-card--soon {
  cursor: default;
}

.app-card--soon .app-card__icon {
  background: var(--tile-muted);
  color: var(--icon-muted);
}

.app-card--soon .app-card__icon svg {
  width: 26px;
  height: 26px;
}

.app-card--soon .app-card__title {
  color: var(--text-muted);
}

.app-card--soon .app-card__desc {
  color: var(--text-faint);
}

.app-card--soon .app-card__chevron {
  color: var(--chevron-muted);
}

/* Login, sign-up, and account pages */

.auth-panel {
  width: 100%;
  max-width: 420px;
  padding: clamp(24px, 5vw, 40px);
  background: var(--card-live-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-panel);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
}

.auth-panel h1 {
  margin: 0 0 8px;
  color: var(--text-strong);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-panel a {
  color: var(--accent);
}

.auth-panel form p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0 0 14px;
}

.auth-panel label {
  color: var(--text-strong);
  font-weight: 500;
}

.auth-panel input:not([type="checkbox"]) {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--card-live-bg);
  border: 1px solid var(--card-live-border);
  border-radius: 8px;
  color: var(--text-strong);
  font: inherit;
}

.auth-panel input::placeholder {
  color: var(--text-muted);
}

.auth-panel input:-webkit-autofill {
  box-shadow: inset 0 0 0 1000px var(--card-live-bg);
  -webkit-text-fill-color: var(--text-strong);
  caret-color: var(--text-strong);
}

.auth-panel .helptext,
.auth-panel .helptext ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-panel .errorlist {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  color: var(--danger);
}

.auth-panel button[type="submit"] {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.auth-panel input:focus-visible,
.auth-panel button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
