:root {
  color-scheme: light dark;
  --bg: #f3ecdf;
  --bg-raised: #fffaf3;
  --bg-sunken: #eae1d1;
  --ink: #1c1612;
  --muted: #52473d;
  --line: #d4c8b6;
  --line-strong: #b7a68f;
  --accent-fill: #9a3412;
  --accent-hover: #7f2a0e;
  --accent-ink: #fff7ed;
  --accent-tint: #f7e6da;
  --focus: #9a3412;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110e;
    --bg-raised: #1c1814;
    --bg-sunken: #0e0c0a;
    --ink: #f5eee3;
    --muted: #c5b8a6;
    --line: #342c25;
    --line-strong: #53473c;
    --accent-fill: #e8894f;
    --accent-hover: #f39d66;
    --accent-ink: #19100a;
    --accent-tint: #261b14;
    --focus: #ffb07a;
  }
}

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

html {
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-block-size: 100dvh;
  border-block-start: 2px solid var(--accent-fill);
  font: 1rem/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

main {
  max-inline-size: 42rem;
  margin: 0 auto;
  padding: 2.75rem 1.5rem 4rem;
}

main:has(#account-directory) {
  max-inline-size: 68rem;
}

h1,
h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.85rem, 3.5vw, 2.5rem);
}

h2 {
  margin: 2.25rem 0 0.85rem;
  font-size: 1.35rem;
}

p {
  margin: 0 0 0.85rem;
  max-inline-size: 64ch;
  color: var(--muted);
}

#embedder-email,
#embedder-name,
#embedder-subject {
  color: var(--ink);
  font-size: 0.95rem;
}

#embedder-subject {
  font-family: var(--font-mono);
}

a {
  color: var(--accent-fill);
  text-underline-offset: 0.18em;
}

a.sign-in {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.65rem;
  margin: 0.5rem 0 1.25rem;
  padding: 0.45rem 1.2rem;
  border: 1px solid var(--accent-fill);
  border-radius: 999px;
  background: var(--accent-fill);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

a.sign-in:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

#unlimited-grant {
  max-inline-size: 34rem;
  margin: 1.75rem 0 0;
  padding: 1.35rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--bg-raised);
}

#unlimited-grant h2 {
  margin-block-start: 0;
}

label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--muted);
}

input {
  display: block;
  inline-size: 100%;
  min-block-size: 2.45rem;
  margin: 0 0 0.9rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--ink);
  font: 0.9rem/1.4 var(--font-mono);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.2rem;
  margin: 0 0.45rem 0.45rem 0;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--ink);
  font: 600 0.85rem/1.2 var(--font-sans);
  cursor: pointer;
}

button:hover {
  border-color: var(--ink);
  background: var(--accent-tint);
}

#unlimited-grant button[value="1"] {
  border-color: var(--accent-fill);
  background: var(--accent-fill);
  color: var(--accent-ink);
}

#unlimited-grant button[value="1"]:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
.table-wrap:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 2px;
}

.table-wrap {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(34rem, 70dvh);
  margin: 0 0 1.75rem;
  container-type: inline-size;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--bg-raised);
}

.table-wrap table {
  border-collapse: separate;
  border-spacing: 0;
  inline-size: 100%;
}

.table-wrap caption {
  caption-side: top;
  padding: 0.75rem 0.95rem;
  border-block-end: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: start;
}

.table-wrap thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
}

.table-wrap thead th {
  padding: 0.6rem 0.85rem;
  border-block-end: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: start;
  white-space: nowrap;
}

.table-wrap tbody th,
.table-wrap tbody td {
  text-align: start;
  padding: 0.75rem 0.85rem;
  border-block-end: 1px solid var(--line);
  vertical-align: top;
  background: var(--bg-raised);
  font-size: 0.9rem;
  white-space: nowrap;
}

.table-wrap tbody tr:last-child th,
.table-wrap tbody tr:last-child td {
  border-block-end: 0;
}

.table-wrap tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  font-weight: 650;
}

.table-wrap td input {
  inline-size: 8.5rem;
  min-block-size: 2.15rem;
  margin: 0 0 0.45rem;
  font-variant-numeric: tabular-nums;
}

.table-wrap td label {
  margin: 0 0 0.25rem;
}

.row-status,
#grant-status {
  margin: 0.35rem 0 0;
  color: var(--accent-fill);
  font-size: 0.85rem;
  white-space: normal;
}

.row-status:empty,
#grant-status:empty {
  display: none;
}

#admin-list ul {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-inline-size: 34rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

#admin-list li {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--bg-raised);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

#account-directory table {
  --label-2: "Email";
  --label-3: "Subject";
  --label-4: "Admin";
  --label-5: "Unlimited";
  --label-6: "Balance";
  --label-7: "Access";
}

#user-directory table {
  --label-2: "Embedder";
  --label-3: "Consumed";
}

@container (width < 42rem) {
  .table-wrap {
    max-block-size: none;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .table-wrap table,
  .table-wrap caption,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap tbody th,
  .table-wrap tbody td {
    display: block;
    inline-size: 100%;
    white-space: normal;
  }

  .table-wrap caption {
    padding: 0 0 0.65rem;
    border: 0;
    background: transparent;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    margin-block-end: 1rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
  }

  .table-wrap tbody th {
    position: static;
    background: var(--bg-sunken);
  }

  #account-directory td:nth-child(2)::before {
    content: var(--label-2) ": ";
    font-weight: 650;
  }

  #account-directory td:nth-child(3)::before {
    content: var(--label-3) ": ";
    font-weight: 650;
  }

  #account-directory td:nth-child(4)::before {
    content: var(--label-4) ": ";
    font-weight: 650;
  }

  #account-directory td:nth-child(5)::before {
    content: var(--label-5) ": ";
    font-weight: 650;
  }

  #account-directory td:nth-child(6)::before {
    content: var(--label-6) ": ";
    font-weight: 650;
  }

  #account-directory td:nth-child(7)::before {
    content: var(--label-7) ": ";
    font-weight: 650;
  }

  #user-directory td:nth-child(2)::before {
    content: var(--label-2) ": ";
    font-weight: 650;
  }

  #user-directory td:nth-child(3)::before {
    content: var(--label-3) ": ";
    font-weight: 650;
  }
}

@media (forced-colors: active) {
  a.sign-in,
  button,
  input,
  .table-wrap,
  #unlimited-grant {
    border: 1px solid CanvasText;
  }
}
