/* The server's own pages: what daisyUI leaves to the page. daisyUI brings no reset, so the
   element defaults go in its `base` layer, under its components. The rules outside a layer
   are meant to win over daisyUI's. */

/* The theme: the website's, so the console and cliquet.dev look like one product. These
   values are the website's own, in `website/public/styles.css`, and a test keeps them equal.
   An app's own pages keep daisyUI's theme, as the screens they frame do, with the app's
   accent. */
body:not(.app-page) {
  color-scheme: light;
  --color-base-100: oklch(97.5% 0.008 85);
  --color-base-200: oklch(94.5% 0.012 85);
  --color-base-300: oklch(90% 0.015 85);
  --color-base-content: oklch(23% 0.02 285);
  --color-primary: oklch(50% 0.2 285);
  --color-primary-content: oklch(98% 0.01 285);
  --color-secondary: oklch(70% 0.16 55);
  --color-secondary-content: oklch(22% 0.04 55);
  --color-accent: oklch(72% 0.14 175);
  --color-accent-content: oklch(20% 0.04 175);
  --color-neutral: oklch(25% 0.02 285);
  --color-neutral-content: oklch(96% 0.01 285);
  --color-info: oklch(62% 0.15 240);
  --color-info-content: oklch(98% 0.01 240);
  --color-success: oklch(58% 0.14 155);
  --color-success-content: oklch(98% 0.02 155);
  --color-warning: oklch(76% 0.15 75);
  --color-warning-content: oklch(25% 0.05 75);
  --color-error: oklch(58% 0.2 25);
  --color-error-content: oklch(98% 0.01 25);
  --radius-selector: 0.5rem;
  --radius-field: 0.6rem;
  --radius-box: 1rem;
  --size-selector: 0.25rem;
  --size-field: 0.25rem;
  --border: 1px;
  --depth: 0;
  --noise: 0;
  --surface: oklch(99.5% 0.004 85);
  --line: oklch(88% 0.015 85);
  --muted: oklch(48% 0.02 285);
}

@media (prefers-color-scheme: dark) {
  body:not(.app-page) {
    color-scheme: dark;
    --color-base-100: oklch(17% 0.015 285);
    --color-base-200: oklch(21% 0.018 285);
    --color-base-300: oklch(27% 0.02 285);
    --color-base-content: oklch(93% 0.01 285);
    --color-primary: oklch(72% 0.15 285);
    --color-primary-content: oklch(18% 0.04 285);
    --color-secondary: oklch(78% 0.13 60);
    --color-secondary-content: oklch(20% 0.04 60);
    --color-neutral: oklch(30% 0.02 285);
    --color-neutral-content: oklch(94% 0.01 285);
    --color-success: oklch(72% 0.14 155);
    --color-success-content: oklch(18% 0.04 155);
    --color-warning: oklch(80% 0.14 75);
    --color-error: oklch(70% 0.17 25);
    --color-error-content: oklch(18% 0.04 25);
    --surface: oklch(20% 0.017 285);
    --line: oklch(30% 0.02 285);
    --muted: oklch(70% 0.02 285);
  }
}

@layer base {
  *, ::before, ::after { box-sizing: border-box; }
  body { margin: 0; min-height: 100vh; background-color: var(--color-base-100);
         color: var(--color-base-content); line-height: 1.5; overflow-wrap: break-word;
         font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
           Arial, sans-serif;
         -webkit-font-smoothing: antialiased; }
  h1, h2, h3, p, ol, ul, dl, dd, pre { margin: 0; }
  ol, ul { padding: 0; list-style: none; }
  h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.025em; }
  h2, h3 { font-size: 1rem; font-weight: 700; line-height: 1.375; }
  a { color: inherit; text-decoration: none; }
  a:focus-visible, summary:focus-visible { outline: 2px solid currentColor;
                                           outline-offset: 2px; }
  code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
              font-size: 0.875em; }
  button, input, select { font: inherit; color: inherit; }
  small { font-size: 0.875em; }
}

/* A hairline and secondary text, in the theme's own colour, on an app's own pages. */
.app-page { --line: color-mix(in oklab, var(--color-base-content) 10%, transparent);
            --muted: color-mix(in oklab, var(--color-base-content) 60%, transparent);
            --surface: var(--color-base-100); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
           overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }
/* The wordmark, as on the website: the ratchet wheel, then cliquet.dev. */
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700;
         font-size: 1.1rem; letter-spacing: -0.01em; }
.brand .tld { color: var(--muted); font-weight: 500; }
.logo { flex: none; width: 1.6rem; height: 1.6rem; fill: var(--color-primary);
        stroke: var(--color-primary); stroke-width: 2; stroke-linejoin: round; }
.label-text { font-size: 0.875rem; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.connect, .clients { display: flex; flex-direction: column; }
.connect > .copy-field { margin-bottom: 0.5rem; }
.stack-lg, .tab-body { display: flex; flex-direction: column; gap: 1.5rem; }

/* An app's mark: its icon, or the first letter of its name, in the app's accent with white
   text, which the SDK checks reads on it, or in Cliquet's primary colour when it has none. */
.mark { display: inline-flex; flex: none; align-items: center; justify-content: center;
        width: 2rem; height: 2rem; border-radius: var(--radius-field);
        background: var(--color-primary); color: var(--color-primary-content);
        font-size: 0.875rem; font-weight: 600; }
.mark[style] { background: var(--mark); color: #fff; }
.mark > svg { width: 62.5%; height: 62.5%; }
.mark-sm > svg { width: 75%; height: 75%; }
.mark-sm { width: 1.25rem; height: 1.25rem; border-radius: 0.375rem; font-size: 0.6875rem; }
.mark-lg { width: 3rem; height: 3rem; border-radius: var(--radius-box); font-size: 1.25rem; }

/* The active item of a menu is a soft grey, not daisyUI's near black. */
.menu { --menu-active-bg: var(--line); --menu-active-fg: var(--color-base-content); }

/* A card's edge shows on the page, in light and dark: daisyUI's is almost the page's colour. */
.card-border, .card-dash { border-color: var(--line); }
.card { background-color: var(--surface); }

/* A plain button is a surface with a hairline, as on the website: daisyUI's grey is the
   sidebar's colour. Coloured and ghost buttons keep daisyUI's look. */
.btn:not(.btn-primary, .btn-secondary, .btn-accent, .btn-neutral, .btn-info, .btn-success,
         .btn-warning, .btn-error, .btn-ghost, .btn-link, .btn-soft, .btn-outline, .btn-dash) {
  --btn-bg: var(--surface); --btn-border: var(--line);
  &:hover { --btn-bg: var(--color-base-200); }
}

/* Lists in a card line up with its title, as on a screen. */
.card-body > .list > .list-row { padding-inline: 0; }
.card-body > .list > .list-row::after { inset-inline: 0; }
.list-row { padding-block: 0.75rem; align-items: center; }
.row-text { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
@media (width < 640px) {
  .tool-rows > .list-row { grid-template-columns: minmax(0, 1fr); }
  .tool-rows .row-end { grid-row-start: 2; justify-content: flex-start; }
}
.row-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
           gap: 0.375rem; }
.card-body > .text-base-content\/70 { margin-bottom: 0.25rem; }
.alert h2 { font-size: inherit; }
.table-scroll { overflow-x: auto; }
.card-body .table :is(th, td):first-child { padding-inline-start: 0; }
.card-body .table :is(th, td):last-child { padding-inline-end: 0; }
.error-line { min-width: 14rem; overflow-wrap: anywhere; }
.error-text { font-size: 0.8125rem; white-space: pre-wrap; overflow-wrap: anywhere; }
form .input, form .select, form .file-input { width: 100%; }

/* Pages without the console: signing in, and problems. */
.plain-main { display: flex; flex-direction: column; gap: 1.5rem; max-width: 30rem;
              margin: 0 auto; padding: 3rem 1rem; }
.plain-main .card-title { font-size: 1.375rem; line-height: 1.25; }
.plain-main .brand { padding-inline: 0.25rem; }

/* The console: a sidebar that is a drawer on a phone, then the page. */
.drawer-content { min-width: 0; }
.sidebar { display: flex; flex-direction: column; gap: 0.5rem; width: 16rem; min-height: 100%;
           padding: 0.75rem; background: var(--color-base-200);
           border-inline-end: var(--border) solid var(--line); }
.sidebar > .brand { padding: 0.5rem 0.75rem; }
.sidebar .menu { width: 100%; padding: 0; }
.sidebar .menu a { min-height: 2.25rem; }
.nav-empty { padding: 0.25rem 0.75rem; color: var(--muted); font-size: 0.8125rem; }
.nav-icon { display: inline-flex; width: 1.25rem; justify-content: center; }
.nav-icon > svg { width: 1rem; height: 1rem; }
.person { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
          margin-top: auto; padding: 0.75rem 0.5rem 0.25rem;
          border-top: var(--border) solid var(--line); }
.sign-out { flex: none; }
.person-text { display: flex; flex-direction: column; min-width: 0; font-size: 0.8125rem; }
.person-name { font-weight: 600; }
.person-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
                color: var(--muted); }
.privacy-link { align-self: flex-start; font-size: 0.8125rem; color: var(--muted); }
.console-top { gap: 0.5rem; min-height: 3.5rem; padding: 0.25rem 0.75rem;
               border-bottom: var(--border) solid var(--line); }
.console-main { display: flex; flex-direction: column; gap: 1.5rem; max-width: 64rem;
                margin: 0 auto; padding: 2.5rem 2rem 4rem; }
@media (width >= 768px) { .console-top { display: none; } }
@media (width < 768px) { .console-main { padding: 1.25rem 1rem 3rem; } }

.page-head, .app-head-text { display: flex; flex-direction: column; gap: 0.25rem; }
.group { display: flex; flex-direction: column; gap: 0.75rem; }
.app-grid { display: grid; gap: 0.75rem;
            grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
.app-card > .card-body { flex-direction: row; align-items: flex-start; gap: 1rem;
                         padding: 1.25rem; }
.app-card:hover { border-color: color-mix(in oklab, var(--color-base-content) 25%, #0000); }
.app-card-text { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.app-card-text > p:not(:last-child) { display: -webkit-box; -webkit-box-orient: vertical;
                                      -webkit-line-clamp: 2; overflow: hidden; }
.card-title { flex-wrap: wrap; }
.card-title > .badge { font-weight: 400; }

/* An app in the console: its header, its tabs, and its overview. */
.app-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem; }
.app-head-text { flex: 1; min-width: 14rem; }
.nav-tabs, .app-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-tabs { border-bottom: var(--border) solid var(--line); }
/* Tabs that scroll fade at the edge where more of them wait. */
.nav-tabs.more-after { mask-image: linear-gradient(to right, #000 calc(100% - 3rem), #0000); }
.nav-tabs.more-before { mask-image: linear-gradient(to left, #000 calc(100% - 3rem), #0000); }
.nav-tabs.more-before.more-after {
  mask-image: linear-gradient(to right, #0000, #000 3rem, #000 calc(100% - 3rem), #0000); }
.nav-tabs > .tab, .app-tabs > .tab { flex: none; padding-inline: 0; margin-inline-end: 1.5rem;
                                     --tab-p: 0rem; font-weight: 500; }
.role-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem;
             font-size: 0.875rem; }

/* A change's diff: its lines as the file has them, in a box that scrolls sideways, so the
   page never does. Each line's colour runs the box's whole width, or the longest line's. */
.patch, .data-table { border: var(--border) solid var(--line);
                      border-radius: var(--radius-field); }
.patch { overflow-x: auto; }
.patch-lines { display: inline-block; min-width: 100%; padding-block: 0.375rem;
               font-size: 0.8125rem; line-height: 1.5; }
.patch-line { display: block; padding-inline: 0.75rem; white-space: pre; tab-size: 4; }
.patch-added { background: color-mix(in oklab, var(--color-success) 16%, transparent); }
.patch-removed { background: color-mix(in oklab, var(--color-error) 16%, transparent); }
.patch-note, .patch-cut, .patch-gap { color: var(--muted); }
/* Where the change leaves lines or rows alone: a quiet band, not git's @@ line. */
.patch-gap { display: block; padding-inline: 0.75rem; background: var(--color-base-200);
             line-height: 1.25; }
/* A CSV file's change: its rows under its header, a sign before each changed one. */
.patch-table tr.patch-gap > td { padding-block: 0.125rem; background: var(--color-base-200);
                                 color: var(--muted); }
.patch-sign { width: 1.5rem; color: var(--muted); font-weight: 700; text-align: center; }

/* A data file's preview: in a panel on the right of the overview, the whole width on a phone.
   Its table scrolls inside its own box, so the panel never does sideways. */
.file-panel { margin: 0 0 0 auto; width: min(48rem, 100vw); max-width: 100vw; height: 100dvh;
              max-height: 100dvh; padding: 0; border: 0;
              border-inline-start: var(--border) solid var(--line);
              background: var(--color-base-100); color: var(--color-base-content); }
.file-panel::backdrop { background: color-mix(in oklab, black 40%, transparent); }
.file-panel-box { position: relative; min-height: 100%; padding: 1.25rem 1.5rem 2rem; }
@media (width < 768px) { .file-panel-box { padding: 1rem 1rem 2rem; } }
.file-panel-close { position: absolute; inset-block-start: 0.5rem; inset-inline-end: 0.5rem; }
.data-file { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.data-file > .card-title { padding-inline-end: 2.5rem; overflow-wrap: anywhere; }
.data-table { overflow: auto; max-height: 70dvh; }
.data-table td, .data-table th { white-space: pre; tab-size: 4; }
.data-table, .data-table thead tr, .data-file > .patch { background: var(--surface); }

/* An address to copy: the address, then its button. */
.copy-field, .snippet { display: flex; width: 100%; }
.address, .snippet > pre { flex: 1; min-width: 0; display: flex; align-items: center;
                           padding: 0.5rem 0.75rem; background: var(--color-base-200);
                           border-color: color-mix(in oklab, var(--color-base-content) 20%, #0000);
                           font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
                           font-size: 0.8125rem; line-height: 1.4; overflow-wrap: anywhere; }
.address { min-height: 2.5rem; user-select: all; }
.copy-field > .btn, .snippet > .btn { height: auto; min-height: var(--size); }
.snippet > pre { font-size: 0.75rem; white-space: pre-wrap; }

/* Tools and rules, and the views' controls. */
.tools-head, .preview-controls { display: flex; flex-wrap: wrap; align-items: flex-end;
                                 justify-content: space-between; gap: 1rem 1.5rem; }
.preview-controls { justify-content: flex-start; }
.jump-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: 0.875rem; }
.jump-links a { display: inline-flex; align-items: center; gap: 0.375rem; min-height: 2rem; }
.tab-body > section[id] { scroll-margin-top: 1rem; }
.control { display: flex; flex-direction: column; gap: 0.375rem; }

/* Forms in a row on a wide page, in a column on a phone. */
.share-form { display: grid; gap: 0.25rem 0.75rem; align-items: end;
              grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; }
.share-form > .btn { margin-bottom: 0.25rem; }
@media (width < 640px) {
  .share-form { grid-template-columns: minmax(0, 1fr); }
  .share-form > .btn { justify-self: start; }
}
/* A token's name, then one row per app with its role, then everywhere. */
.token-form { display: flex; flex-direction: column; align-items: start; gap: 0.25rem; }
.token-form > .fieldset { width: 100%; min-width: 0; max-width: 36rem; }
.token-form .label { white-space: normal; }
.token-apps { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
              gap: 0.5rem 0.75rem; align-items: center; }
.token-apps > label { overflow-wrap: anywhere; }
.token-apps > .select { width: 100%; }
.token-form > .btn { margin-top: 0.5rem; }
@media (width < 640px) {
  .token-apps { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .token-apps > .select { margin-bottom: 0.5rem; }
}
/* What each role may use, under the form that shares one. */
.role-uses { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 0.5rem;
             font-size: 0.8125rem; color: var(--muted); }
.role-uses strong { margin-right: 0.25rem; color: var(--color-base-content); font-weight: 600; }
/* A new token shows once: its card stands out, and its focus ring stays on the card. */
.new-token { border-color: color-mix(in oklab, var(--color-success) 55%, var(--line));
             background: color-mix(in oklab, var(--color-success) 7%, var(--surface)); }
.new-token:focus { outline: none; }
.new-token:focus-visible { outline: 2px solid var(--color-success); outline-offset: 2px; }
/* A button at the end of a row: a hairline that reads as a button, and room for a finger. */
.row-button { --size: 2.25rem; }
.upload-form { display: flex; flex-direction: column; gap: 0.5rem; }

/* The live app's screens: a slim warning joined to the top of their stage. */
.live-strip { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem;
              border-radius: var(--radius-box) var(--radius-box) 0 0; font-size: 0.875rem;
              background: color-mix(in oklab, var(--color-warning) 30%, var(--color-base-300));
              color: var(--color-base-content); }
.live-strip > svg { flex: none; }
.live-stage > .preview-stage { border-radius: 0 0 var(--radius-box) var(--radius-box); }
/* The views' preview: the screen at the chosen width, on a grey stage. */
.preview-stage { display: flex; justify-content: center; overflow-x: auto; padding: 1.5rem;
                 border-radius: var(--radius-box); background: var(--color-base-300); }
.preview-frame { flex: none; max-width: 100%; border-radius: var(--radius-field);
                 background: var(--color-base-100); }
.preview-frame[data-width="full"] { flex: 1; }
@media (width < 768px) { .preview-stage { justify-content: flex-start; padding: 0.75rem; } }

/* A screen in its frame: no border, as tall as it says it is. The screen's page declares no
   colour scheme, so the frame doesn't either: otherwise Chrome paints a white backdrop behind it
   in dark mode. */
.screen { display: block; width: 100%; height: 60vh; border: 0; color-scheme: normal; }

/* An app's own pages: a slim bar, then the screen at the width it was designed for. */
.app-bar { position: sticky; top: 0; z-index: 10; background: var(--color-base-100);
           border-bottom: var(--border) solid var(--line); }
.app-bar-row { justify-content: space-between; gap: 0.75rem; max-width: 48rem; min-height: 0;
               margin: 0 auto; padding: 0.375rem 1rem; }
.app-name { display: inline-flex; align-items: center; gap: 0.625rem; min-width: 0;
            min-height: 2.5rem; font-weight: 600; }
.app-name > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar-actions { display: flex; flex: none; align-items: center; gap: 0.25rem; }
.app-bar-actions .btn { --btn-p: 0.75rem; }
@media (width < 480px) { .app-bar-actions .btn { --btn-p: 0.5rem; } }
.app-tabs { max-width: 48rem; margin: 0 auto; padding: 0 1rem; }
.app-main { max-width: 48rem; margin: 0 auto; padding-bottom: 3rem; }
/* Added to a phone's home screen, a role's page is the app itself: the bar's name, roles,
   Manage and assistant button are the browser's page's, and only the tabs stay, if any. The
   screen's frame takes its height from its content, so it needs nothing more. */
@media (display-mode: standalone) {
  .app-bar-row, .app-bar:not(:has(.app-tabs)) { display: none; }
}
.preview-banner { margin: 1rem 1rem 0; }
.app-empty { display: flex; flex-direction: column; gap: 0.75rem; padding: 2rem 1rem 0; }
.app-empty h1 { font-size: 1.25rem; }
@media (width < 480px) {
  .connect-label { display: none; }
  .connect-button { width: 2.5rem; }
}
.role-menu > summary { list-style: none; }
.role-menu > summary::-webkit-details-marker { display: none; }
.role-menu > .dropdown-content { z-index: 20; min-width: 10rem; margin-top: 0.25rem;
                                 border: var(--border) solid var(--line);
                                 border-radius: var(--radius-box);
                                 background: var(--color-base-100);
                                 box-shadow: 0 4px 16px rgb(0 0 0 / 0.08); }
.role-menu .menu a { min-height: 2.5rem; }

/* Using an app from an assistant: the address, then how to add it, client by client. A closed
   dialog takes no room, so nothing in it counts as on the page. */
.modal:not([open]) { display: none; }
.connect-dialog > .modal-box { display: flex; flex-direction: column; gap: 1rem;
                               max-width: 36rem; }
.connect-dialog h2 { padding-inline-end: 2.5rem; font-size: 1.125rem; }
.modal-close { position: absolute; top: 1rem; right: 1rem; }
.clients > .fold + .fold, .connect > .fold { border-top: var(--border) solid var(--line);
                                             border-radius: 0; }
.fold > .collapse-title { min-height: 2.75rem; padding: 0.625rem 2.5rem 0.625rem 0;
                          font-size: 0.875rem; font-weight: 600; }
.fold > .collapse-content { padding-inline: 0; font-size: 0.875rem; }
.fold.collapse-arrow > .collapse-title::after { inset-inline-end: 0.75rem; }
.fold .link { overflow-wrap: anywhere; }
.steps-list { display: flex; flex-direction: column; gap: 0.375rem; padding-left: 1.25rem;
              list-style: decimal; }
.agent { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.75rem; }
.tool-list { display: flex; flex-direction: column; gap: 0.5rem; color: var(--muted); }
.tool-list code { margin-right: 0.375rem; color: var(--color-base-content); }

/* An app's page: its buttons beside its name; a draft's card: its links under its text. */
.app-head-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.draft-card .card-actions { margin-top: 0.5rem; }
/* The overview's line of counts, each a link to where they are listed. */
.summary-line { display: flex; flex-wrap: wrap; gap: 0.375rem 1.5rem; }
.summary-line strong { font-weight: 700; }
.row-meta { font-size: 0.875rem; text-align: end; }
#overview-errors > .btn { justify-self: end; }

/* Secondary text reads at 4.5:1 at least on every surface of the console, in both themes:
   daisyUI's faded tabs and menu titles, and text at 60%, fall short of it. A test checks the
   ratios of `--muted`. */
body:not(.app-page) :is(.tabs > .tab:not([aria-current]), .menu-title, .text-base-content\/60) {
  color: var(--muted);
}
/* An icon drawn by name in an alert or a strip takes the size of its line. */
.alert > svg { flex: none; width: 1.25rem; height: 1.25rem; }
.live-strip > svg { width: 1rem; height: 1rem; }
