/* The account pages (sign-in, playlists, profiles, devices, settings, support desk), on top of
   marketing.css: the website's colours, type, buttons and glass, applied to plain forms, cards and
   tables. Colours are classes, never inline styles: the CSP allows none. */

body.app { min-height: 100vh; display: flex; flex-direction: column; }
body.app::before {
  /* The website's glow, behind everything. */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(800px 420px at 85% -5%, rgba(140, 90, 255, 0.22), transparent 70%),
    radial-gradient(600px 360px at 0% 0%, rgba(255, 107, 157, 0.10), transparent 70%);
}
.app-main { flex: 1; padding: 36px 0 40px; }
.app-footer { margin-top: 40px; padding: 28px 0; }
.app-footer .fine { margin-top: 0 !important; text-align: center; }
.app-footer a { color: var(--text); }

.app a:not(.btn):not([role="button"]) { color: #cbb6ff; text-decoration-color: rgba(203, 182, 255, 0.4); text-underline-offset: 3px; }
.app .mk-links a, .app .mk-brand, .app .account-tabs a, .app .filters a { text-decoration: none; }
.app .mk-links a { color: var(--muted) !important; }
.app .mk-links a:hover { color: var(--text) !important; }

.app h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 800; }
.app h2 { font-size: 1.35rem; font-weight: 750; letter-spacing: -0.015em; margin-bottom: 14px; }
.app p + p, .app p + form, .app form + p { margin-top: 14px; }
.app small { font-size: 0.86rem; }
.app strong { font-weight: 700; }
.muted { color: var(--muted); }
.centered { text-align: center; }
.nowrap { white-space: nowrap; }

/* ── Tabs under the nav ── */
.account-tabs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin-top: 22px; padding: 6px; width: fit-content; max-width: min(var(--wrap), 100% - 40px);
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
}
.account-tabs::-webkit-scrollbar { display: none; }
.account-tabs a {
  flex: none; padding: 9px 18px; border-radius: 999px; font-weight: 600; color: var(--muted) !important;
  transition: background 0.25s, color 0.25s;
}
.account-tabs a:hover { color: var(--text) !important; }
.account-tabs a[aria-current="page"] { background: #fff; color: #111 !important; }

/* ── Page heading ── */
.page-heading { margin-bottom: 30px; }
.page-heading p { color: var(--muted); font-size: 1.1rem; margin-top: 8px; }
hgroup p { color: var(--muted); margin-top: 6px; }

/* ── Cards ── */
.app article {
  position: relative;
  margin: 0 0 18px; padding: 26px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
}
.app article > header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.app article > header h2 { margin: 0; }
.app article > footer { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.narrow { max-width: 30rem; margin-inline: auto; }
.app article.narrow { padding: 34px; }
.app article.narrow hgroup { margin-bottom: 24px; }
.app article.empty { text-align: center; color: var(--muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 18px; margin-bottom: 18px; }
.card-grid > article { margin: 0; }

.split { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.app article > header.split { justify-content: space-between; }

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding-block: 12px; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: none; }

/* ── Forms ── */
.app form { margin: 0; }
.app label { display: block; margin-bottom: 18px; font-weight: 600; font-size: 0.95rem; }
.app label > small { display: block; margin-top: 7px; font-weight: 400; color: var(--muted); }
.app input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]),
.app select,
.app textarea {
  display: block; width: 100%; margin-top: 8px;
  padding: 13px 16px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font: inherit; font-weight: 400;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.app textarea { resize: vertical; min-height: 7rem; }
.app input::placeholder, .app textarea::placeholder { color: #6f6c84; }
.app input:focus, .app select:focus, .app textarea:focus {
  outline: none; border-color: var(--accent); background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 4px rgba(164, 124, 243, 0.22);
}
.app select {
  appearance: none; padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a3a0b8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.app select option { background: #15151f; color: var(--text); }
.app fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.app legend { padding: 0; }

/* An input with its button alongside. */
.app fieldset[role="group"] { display: flex; gap: 10px; align-items: stretch; }
.app fieldset[role="group"] > input, .app fieldset[role="group"] > select { flex: 1; margin-top: 0; }

/* Two fields side by side (one column on phones). */
.app .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .app .grid { grid-template-columns: 1fr; } }

/* ── Buttons: plain <button>s and role="button" links look like the website's. ── */
.app button:not(.btn), .app [role="button"]:not(.btn) {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 24px; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 650; text-decoration: none; line-height: 1.2;
  color: #fff; border: 1px solid transparent;
  background: linear-gradient(135deg, #b18cff, #8a5cf0);
  box-shadow: 0 10px 30px -10px rgba(150, 100, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.app button:not(.btn):hover, .app [role="button"]:not(.btn):hover { transform: translateY(-1px); }
.app button:focus-visible, .app [role="button"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.app button.secondary, .app [role="button"].secondary {
  background: var(--surface-2); border-color: var(--line); color: var(--text); box-shadow: none;
}
.app button.secondary:hover, .app [role="button"].secondary:hover { background: rgba(255, 255, 255, 0.11); }
.app button.outline, .app [role="button"].outline { background: transparent; border-color: rgba(255, 255, 255, 0.2); color: var(--text); box-shadow: none; }
.app button.outline:hover, .app [role="button"].outline:hover { background: var(--surface); }
.app button.small, .app [role="button"].small { padding: 8px 16px; font-size: 0.9rem; }
.app button.danger { background: #e5484d; box-shadow: 0 10px 30px -12px rgba(229, 72, 77, 0.8); }
.app button.danger:hover { background: #cc3a40; }
.app article.narrow form button, .app article.narrow .sso [role="button"] { width: 100%; }
.app article.narrow form button + button { margin-top: 12px; }
form.inline { display: inline; margin: 0; }

/* htmx: while a request is out, its form dims and can't be submitted twice. */
.htmx-request, .htmx-request button { opacity: 0.6; pointer-events: none; cursor: progress; }

/* ── Tables ── */
.app table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.app th {
  text-align: left; padding: 10px 12px; color: var(--muted);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.app td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.app tbody tr:last-child td { border-bottom: none; }
.app tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.app article:has(> table) { overflow-x: auto; }

/* ── Badges and notices ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { background: rgba(164, 124, 243, 0.2); border-color: rgba(164, 124, 243, 0.45); color: #e2d6ff; }

.notice { padding: 14px 18px; border-radius: 14px; border: 1px solid; margin: 0 0 18px; }
.notice.success { border-color: rgba(164, 124, 243, 0.45); background: rgba(164, 124, 243, 0.12); }
.notice.error { border-color: rgba(229, 72, 77, 0.5); background: rgba(229, 72, 77, 0.12); }

/* ── Sign-in ── */
.divider { display: flex; align-items: center; gap: 1rem; margin-block: 22px; color: var(--muted); font-size: 0.9rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.sso { display: grid; gap: 12px; }
.sso-mark { width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin-right: 0.2rem; }
/* Sign in with Apple / Google, as their guidelines draw them on a dark page. */
.app .sso a.sso-apple { background: #fff; color: #000; box-shadow: none; }
.app .sso a.sso-apple:hover { background: #e8e8ed; }
.app .sso a.sso-google { background: #131314; border: 1px solid #8e918f; color: #e3e3e3; box-shadow: none; }
.app .sso a.sso-google:hover { background: #1f1f20; }

.code-input, .code-display { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.2em; text-transform: uppercase; }
.code-display {
  font-size: 2rem; font-weight: 700; text-align: center; margin-block: 22px !important;
  padding: 18px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); border: 1px dashed rgba(164, 124, 243, 0.45);
}

/* ── Playlists ── */
.playlist > header { justify-content: space-between; }
/* Rename opens to the card's full width; Delete stays at the right of the Rename line. */
.playlist > footer { position: relative; display: block; }
.playlist > footer > button { position: absolute; right: 0; top: 16px; }
.playlist > footer summary {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px;
  cursor: pointer; color: var(--muted); font-weight: 600; list-style: none;
}
.playlist > footer summary::-webkit-details-marker { display: none; }
.playlist > footer summary::before { content: "✎"; font-size: 0.95rem; }
.playlist > footer details[open] summary::before { content: "×"; font-size: 1.2rem; }
.playlist > footer details[open] summary { color: var(--text); }
.playlist > footer summary:hover { color: var(--text); }
.playlist > footer form { margin-top: 12px; }
.app article.playlist fieldset[role="group"] { flex-direction: column; margin: 0; }
.app article.playlist fieldset[role="group"] > input { margin-top: 0; }
.app article.playlist fieldset[role="group"] > button { margin-top: 0; align-self: flex-start; padding: 9px 20px; }

/* ── Profiles: avatars as the app draws them (a colour, with an icon or the initial), and the pickers. ── */
.av-purple { --av: #7c4dff; }
.av-blue { --av: #2979ff; }
.av-teal { --av: #00bfa5; }
.av-green { --av: #43a047; }
.av-amber { --av: #ffb300; }
.av-orange { --av: #ff6d00; }
.av-red { --av: #e53935; }
.av-pink { --av: #ec407a; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 3.5rem; height: 3.5rem; border-radius: 0.9rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--av) 82%, white), color-mix(in srgb, var(--av) 75%, black));
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--av) 70%, transparent);
  color: #fff; font-size: 1.9rem; font-weight: 800; line-height: 1;
}
.profile > header { gap: 14px; }
.profile > header strong { display: block; font-size: 1.1rem; }

.app .avatar-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-choices legend { width: 100%; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
/* The radios are hidden but stay focusable; their labels are the tiles. */
.app .avatar-choices label { position: relative; flex: none; margin: 0; cursor: pointer; }
.avatar-choices input[type="radio"] { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.avatar-choices .swatch { display: block; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--av); border: 3px solid transparent; }
.avatar-choices .icon-choice {
  display: inline-grid; place-items: center; width: 2.7rem; height: 2.7rem; border-radius: 0.7rem;
  border: 2px solid transparent; background: var(--surface-2); font-size: 1.45rem; line-height: 1;
}
.icon-choice .initial { font-size: 1.1rem; font-weight: 800; }
.swatch:has(input:checked) { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15); }
.icon-choice:has(input:checked) { background: var(--av); color: #fff; border-color: #fff; }
.avatar-choices label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── Settings → Delete account ── */
.app article.danger-zone { border-color: rgba(229, 72, 77, 0.4); background: linear-gradient(180deg, rgba(229, 72, 77, 0.08), var(--surface)); }
.danger-zone h2 { color: #ff7b80; }

/* ── Support desk ── */
.filters { display: flex; gap: 6px; margin-bottom: 18px; padding: 5px; width: fit-content; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.filters a { padding: 7px 16px; border-radius: 999px; color: var(--muted) !important; font-weight: 600; }
.filters a[aria-current="page"] { background: var(--surface-2); color: var(--text) !important; }
.message-body { white-space: pre-wrap; }
.app article.message.agent { border-color: rgba(164, 124, 243, 0.45); background: linear-gradient(180deg, rgba(164, 124, 243, 0.12), var(--surface)); }
.attachment { display: block; max-width: 100%; max-height: 420px; margin: 12px 0 6px; border-radius: 10px; border: 1px solid var(--line); }

/* ── Overview: a tile per part of the account. ── */
.overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 18px; }
.app .overview .tile { display: flex; flex-direction: column; margin: 0; transition: transform 0.3s ease, border-color 0.3s ease; }
.app .overview .tile:hover { transform: translateY(-3px); border-color: rgba(164, 124, 243, 0.4); }
.overview .tile > header h2 { flex: 1; font-size: 1.15rem; }
.app .overview .tile > footer { margin-top: auto; padding-top: 18px; border-top: 0; }
.overview .tile > p { margin-bottom: 4px; }
.tile-wide { grid-column: 1 / -1; }
.tile-icon {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(177, 140, 255, 0.28), rgba(255, 134, 180, 0.18));
  border: 1px solid rgba(177, 140, 255, 0.35);
  color: #e6dcff; font-size: 1.15rem;
}
.tile-count { font-size: 1.8rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
ul.compact li { padding-block: 8px; }
.avatar-row { display: flex; flex-wrap: wrap; gap: 14px; }
.avatar-with-name { display: grid; justify-items: center; gap: 6px; }
.avatar-with-name .avatar { width: 2.9rem; height: 2.9rem; font-size: 1.5rem; }
.avatar-with-name small { color: var(--muted); max-width: 5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 640px) {
  .app article { padding: 20px; }
  .app article.narrow { padding: 24px; }
  .app-main { padding-top: 24px; }
}

/* Spacing fixes after the cards' own margins. */
.app article.narrow { margin: 0 auto 18px; }
.app textarea { margin-bottom: 14px; }
#ticket-panel > p:has(> a) { margin-bottom: 16px; }
.app .tile-actions [role="button"] { padding-inline: 14px; }
/* An input with its button: the input takes the room, even inside a narrow card. */
.app article fieldset[role="group"] > button { width: auto; flex: none; margin-top: 8px; }
.app fieldset[role="group"] > input { min-width: 0; }

/* ── Admin ── */
.account-tabs a.tab-back { color: var(--muted) !important; border-right: 1px solid var(--line); border-radius: 999px 0 0 999px; margin-right: 4px; }
.account-tabs a.tab-admin { color: #e2d6ff !important; background: rgba(164, 124, 243, 0.18); }
.account-tabs a.tab-admin:hover { background: rgba(164, 124, 243, 0.3); }
.app p.back { margin-bottom: 16px; }
.app p.list-count { margin-bottom: 12px; }
.app form.search-row { margin-bottom: 18px; max-width: 34rem; }
.app form.search-row fieldset[role="group"] > button { margin-top: 8px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 800px) { .admin-grid { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; }
.app article > footer > form + p, .app article > footer > p + form { margin-top: 12px; }

/* ── Premium ── */
.premium-badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; }
.premium-badge.on { background: linear-gradient(135deg, #ffd36b, #ffa94d); color: #2a1a00; box-shadow: 0 6px 18px -8px rgba(255, 169, 77, 0.8); }
.premium-badge.off { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.app article.premium-tile.is-premium { border-color: rgba(255, 196, 92, 0.45); background: linear-gradient(135deg, rgba(255, 196, 92, 0.12), var(--surface) 60%); }
.app .premium-card form { margin-top: 16px; }
.premium-actions { display: flex; flex-wrap: wrap; gap: 8px; }
