/* ==========================================================================
   Nexus Mastering — Client portal
   Login / register, client dashboard and admin pages. Builds on the tokens
   and components in style.css.
   ========================================================================== */

:root {
  --status-sent: #7b97ff;
  --status-working: #f5b94a;
  --status-ready: #6fe3a3;
  --status-revision: #ff8f6b;
  --status-approved: #c9a7ff;
  --danger: #ff8383;
}

/* Cards in the portal are working surfaces: no hover lift */
.portal-page .card:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border-hairline);
}

.portal-muted {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.portal-break {
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Page hero & sections
   -------------------------------------------------------------------------- */
.portal-hero {
  padding-block: var(--space-xl) var(--space-md);
}

.portal-signed-in {
  margin-top: var(--space-xs);
  overflow-wrap: anywhere;
}

.portal-signed-in a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

.portal-section {
  padding-top: var(--space-md);
}

.portal-card {
  margin-bottom: var(--space-md);
}

.portal-card > .heading-sm {
  margin-bottom: 0.4rem;
}

.portal-card > .portal-muted {
  margin-bottom: var(--space-md);
}

.portal-grid {
  gap: var(--space-md);
}

.portal-grid .portal-card {
  margin-bottom: 0;
}

.portal-empty {
  color: var(--text-tertiary);
  padding: var(--space-md) 0 0;
}

/* --------------------------------------------------------------------------
   Login / register
   -------------------------------------------------------------------------- */
.portal-auth {
  min-height: calc(100vh - var(--nav-height) - 120px);
  display: flex;
  align-items: center;
}

.portal-auth-inner {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
}

.portal-auth-card {
  width: 100%;
  max-width: 440px;
}

.portal-auth-card .eyebrow {
  display: block;
}

.portal-auth-switch {
  text-align: center;
  margin-top: var(--space-md);
}

.portal-page .form-note a,
.portal-file a,
.portal-page .footer-copyright a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-hairline-strong);
  text-underline-offset: 3px;
}

.portal-page .form-note a:hover,
.portal-file a:hover {
  text-decoration-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */
.portal-alert {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline-strong);
  background: var(--surface-glass);
  margin-bottom: var(--space-md);
  font-size: 0.94rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.portal-alert-success {
  border-color: rgba(111, 227, 163, 0.35);
  background: rgba(111, 227, 163, 0.08);
  color: var(--status-ready);
}

.portal-alert-error {
  border-color: rgba(255, 131, 131, 0.35);
  background: rgba(255, 131, 131, 0.08);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(255, 131, 131, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 131, 131, 0.1);
}

/* --------------------------------------------------------------------------
   Status badges
   -------------------------------------------------------------------------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.status-sent { color: var(--status-sent); }
.status-working { color: var(--status-working); }
.status-ready { color: var(--status-ready); }
.status-revision { color: var(--status-revision); }
.status-approved { color: var(--status-approved); }

.status-working .status-dot {
  animation: status-pulse 1.6s ease-in-out infinite;
}

@keyframes status-pulse {
  50% { opacity: 0.35; }
}

/* Admin status menu, coloured like the badges */
.status-form {
  margin: 0;
}

.form-control-sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  width: auto;
}

.status-select {
  font-weight: 600;
  border-color: currentColor;
}

.status-select option {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.portal-table-wrap {
  overflow-x: auto;
  margin-inline: calc(var(--space-sm) * -1);
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.portal-table th {
  text-align: left;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0.6rem var(--space-sm);
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}

.portal-table td {
  padding: 0.85rem var(--space-sm);
  border-bottom: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  vertical-align: middle;
  white-space: nowrap;
}

.portal-table tr:last-child td {
  border-bottom: none;
}

.portal-table td.portal-file {
  color: var(--text-primary);
  font-weight: 500;
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 180px;
}

/* Stays a real table cell (display:flex here would break the row's borders);
   the buttons and forms inside sit side by side as inline items. */
.portal-actions {
  text-align: right;
  white-space: nowrap;
}

.portal-actions > * {
  vertical-align: middle;
}

.portal-actions > * + * {
  margin-left: 0.5rem;
}

.portal-actions form {
  display: inline-flex;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Admin
   -------------------------------------------------------------------------- */
.portal-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.portal-stat {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: var(--space-md);
}

.portal-stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.portal-stat-label {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.portal-search {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.portal-search .form-control {
  max-width: 360px;
  padding-block: 0.6rem;
}

.portal-clear::after {
  content: none;
}

.portal-danger-zone {
  border-color: rgba(255, 131, 131, 0.2);
}

/* --------------------------------------------------------------------------
   Uploader
   -------------------------------------------------------------------------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: var(--space-lg) var(--space-md);
  border: 1.5px dashed var(--border-hairline-strong);
  border-radius: var(--radius-md);
  background: var(--surface-glass);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-smooth),
    background-color var(--duration-fast) var(--ease-smooth);
}

.dropzone:hover,
.dropzone:focus-within,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: rgba(91, 124, 250, 0.08);
}

.dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  width: 34px;
  height: 34px;
  stroke: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.dropzone-title {
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-hint {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.uploader.is-uploading .dropzone {
  opacity: 0.4;
  pointer-events: none;
}

.upload-progress {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress-head,
.upload-progress-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.upload-progress-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.upload-progress-pct {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.upload-bar {
  height: 8px;
  margin: 0.8rem 0;
  border-radius: var(--radius-full);
  background: var(--surface-glass-strong);
  overflow: hidden;
}

.upload-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent-gradient);
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width 0.25s linear;
}

.upload-progress-foot .portal-muted {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.upload-progress-buttons {
  display: flex;
  gap: 0.5rem;
}

.upload-progress-buttons [hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Instant Master
   -------------------------------------------------------------------------- */
.status-failed { color: var(--danger); }

.instant-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.instant-head .heading-sm {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.instant-head .portal-muted {
  max-width: 640px;
}

.instant-quota {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-hairline-strong);
  background: var(--surface-glass);
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.instant-usage {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.instant-usage form {
  margin: 0;
}

.instant-quota strong {
  color: var(--text-primary);
}

.preset-picker {
  border: none;
  margin-bottom: var(--space-md);
}

.preset-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.preset-option {
  position: relative;
  cursor: pointer;
}

.preset-option input {
  position: absolute;
  opacity: 0;
}

.preset-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  height: 100%;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border-hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  transition: border-color var(--duration-fast) var(--ease-smooth),
    background-color var(--duration-fast) var(--ease-smooth),
    box-shadow var(--duration-fast) var(--ease-smooth);
}

.preset-option:hover .preset-card {
  border-color: var(--text-tertiary);
}

.preset-option input:checked + .preset-card {
  border-color: var(--accent);
  background: rgba(91, 124, 250, 0.08);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.preset-option input:focus-visible + .preset-card {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preset-option input:disabled + .preset-card {
  opacity: 0.5;
  cursor: default;
}

.preset-name {
  font-weight: 600;
  color: var(--text-primary);
}

.preset-lufs {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-left: 0.3rem;
}

.preset-desc {
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.dropzone-disabled {
  cursor: default;
  opacity: 0.7;
}

.dropzone-disabled:hover {
  border-color: var(--border-hairline-strong);
  background: var(--surface-glass);
}

.instant-table {
  margin-top: var(--space-md);
}

.instant-error,
.instant-result {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  font-weight: 400;
}

.instant-error {
  color: var(--danger);
}

.instant-result {
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   Audio player
   -------------------------------------------------------------------------- */
.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-right: 0.65rem;
  vertical-align: middle;
  border-radius: 50%;
  border: 1px solid var(--border-hairline-strong);
  background: var(--surface-glass);
  color: var(--text-primary);
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-smooth),
    border-color var(--duration-fast) var(--ease-smooth),
    transform var(--duration-fast) var(--ease-smooth);
}

.play-btn:hover {
  border-color: var(--accent);
  background: rgba(91, 124, 250, 0.12);
}

.play-btn:active {
  transform: scale(0.92);
}

.play-btn:focus-visible,
.player-toggle:focus-visible,
.player-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.play-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-gradient);
  box-shadow: 0 0 14px var(--accent-glow);
}

.play-btn svg,
.player-toggle svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.play-btn .icon-pause,
.play-btn.is-playing .icon-play,
.player-toggle .icon-pause,
.audio-player.is-playing .player-toggle .icon-play {
  display: none;
}

.play-btn.is-playing .icon-pause,
.audio-player.is-playing .player-toggle .icon-pause {
  display: block;
}

.audio-player {
  position: fixed;
  left: 50%;
  bottom: var(--space-sm);
  transform: translateX(-50%);
  z-index: 900;
  width: min(760px, calc(100% - 2 * var(--space-sm)));
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline-strong);
  background: rgba(15, 15, 18, 0.82);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  box-shadow: var(--shadow-lg);
  animation: player-in 0.35s var(--ease-apple);
}

.audio-player[hidden] {
  display: none;
}

@keyframes player-in {
  from { opacity: 0; transform: translate(-50%, 16px); }
}

body.has-player {
  padding-bottom: 96px;
}

.player-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--text-inverse);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-smooth), box-shadow var(--duration-fast) var(--ease-smooth);
}

.player-toggle:hover {
  box-shadow: var(--shadow-glow);
}

.player-toggle:active {
  transform: scale(0.92);
}

.player-toggle svg {
  width: 18px;
  height: 18px;
}

.audio-player.is-loading .player-toggle {
  animation: status-pulse 1.2s ease-in-out infinite;
}

.player-main {
  flex: 1;
  min-width: 0;
}

.player-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.3rem;
}

.audio-player.has-error .player-title {
  color: var(--danger);
  white-space: normal;
}

.audio-player.has-error .player-timeline {
  display: none;
}

.player-timeline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.player-time {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  min-width: 2.6em;
}

.player-time:last-child {
  text-align: right;
}

.player-seek {
  --progress: 0%;
  flex: 1;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) var(--progress), var(--surface-glass-strong) var(--progress));
  cursor: pointer;
}

.player-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

.player-seek::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 0 8px var(--accent-glow);
}

.player-seek:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.player-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--text-tertiary);
  cursor: pointer;
}

.player-close:hover {
  color: var(--text-primary);
  background: var(--surface-glass-strong);
}

.player-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
}

/* --------------------------------------------------------------------------
   Admin tabs & unread counts
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.admin-tabs {
  display: inline-flex;
  gap: 0.3rem;
  padding: 0.3rem;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-hairline);
  background: var(--surface-glass);
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background-color var(--duration-fast) var(--ease-smooth), color var(--duration-fast) var(--ease-smooth);
}

.admin-tab:hover {
  color: var(--text-primary);
  background: var(--surface-glass-strong);
}

.admin-tab.is-active {
  color: var(--text-inverse);
  background: var(--text-primary);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.4rem;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 10px var(--accent-glow);
  vertical-align: middle;
}

.count-badge[hidden] {
  display: none;
}

.nav-link .count-badge,
.nav-mobile-link .count-badge {
  margin-left: 0.35rem;
}

/* --------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */
.messages-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

.messages-head form {
  margin: 0;
}

.message-list {
  border-top: 1px solid var(--border-hairline);
}

.message-item {
  border-bottom: 1px solid var(--border-hairline);
}

.message-summary {
  display: grid;
  grid-template-columns: 10px minmax(140px, 240px) 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  padding: 1rem 0.5rem;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-sm);
  transition: background-color var(--duration-fast) var(--ease-smooth);
}

.message-summary::-webkit-details-marker {
  display: none;
}

.message-summary:hover {
  background: var(--surface-glass);
}

.message-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.message-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.message-item.is-unread .message-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.message-from {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  min-width: 0;
}

.message-name {
  font-weight: 500;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.message-item.is-unread .message-name {
  font-weight: 700;
  color: var(--text-primary);
}

.message-preview {
  color: var(--text-tertiary);
  font-size: 0.92rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.message-item.is-unread .message-preview {
  color: var(--text-secondary);
}

.message-date {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.message-item[open] .message-preview {
  visibility: hidden;
}

.message-body {
  padding: 0.25rem 0.5rem 1.5rem calc(10px + var(--space-sm) + 0.5rem);
}

.message-meta {
  display: grid;
  gap: 0.35rem;
  margin-bottom: var(--space-sm);
  font-size: 0.9rem;
}

.message-meta div {
  display: flex;
  gap: 0.75rem;
}

.message-meta dt {
  width: 4.5rem;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.message-meta dd {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.message-meta a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-hairline-strong);
  text-underline-offset: 3px;
}

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: var(--space-sm) 1.1rem;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
  color: var(--text-primary);
  line-height: 1.6;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.message-actions form {
  margin: 0;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* --------------------------------------------------------------------------
   Notes, change requests and approvals under each client upload
   -------------------------------------------------------------------------- */
.portal-table-notes tbody tr:not(.notes-row) td {
  border-bottom: none;
}

.notes-row td {
  padding-top: 0;
  white-space: normal;
}

.review-box {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(111, 227, 163, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(111, 227, 163, 0.06);
}

.review-text {
  font-size: 0.92rem;
  color: var(--text-secondary);
  padding-top: 0.35rem;
}

.review-text strong {
  color: var(--text-primary);
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.review-actions .note-toggle[open] {
  flex-basis: 100%;
}

.note-form-inline {
  margin: 0;
}

.note-toggle > summary {
  list-style: none;
  cursor: pointer;
}

.note-toggle > summary::-webkit-details-marker {
  display: none;
}

.note-form {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
  margin-top: 0.6rem;
  max-width: 640px;
}

.note-form textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  font-size: 0.92rem;
}

.note-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

.note-links .note-toggle[open] {
  flex-basis: 100%;
}

.note-link {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--text-tertiary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note-link:hover,
.note-toggle[open] > .note-link {
  color: var(--text-primary);
}

.note-thread {
  list-style: none;
  margin: 0 0 0.7rem;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-width: 760px;
}

.note {
  padding: 0.65rem 0.9rem;
  border-left: 2px solid var(--border-hairline-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-glass);
}

.note-admin {
  border-left-color: var(--status-sent);
}

.note-revision {
  border-left-color: var(--status-revision);
  background: rgba(255, 143, 107, 0.06);
}

.note-approval {
  border-left-color: var(--status-approved);
  background: rgba(201, 167, 255, 0.06);
}

.note-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

.note-who {
  font-weight: 600;
  color: var(--text-primary);
}

.note-kind {
  font-weight: 600;
}

.note-revision .note-kind { color: var(--status-revision); }
.note-approval .note-kind { color: var(--status-approved); }

.note-date {
  color: var(--text-tertiary);
}

.note-body {
  margin-top: 0.3rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Admin: needs attention, private notes, storage
   -------------------------------------------------------------------------- */
.attention-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-bottom: var(--space-sm);
}

.attention-head .heading-sm {
  margin-bottom: 0;
}

.attention-messages {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.attention-messages:hover {
  text-decoration: underline;
}

/* The file you jumped to from "Needs attention" or a Discord link */
.notes-row {
  scroll-margin-top: calc(var(--nav-height, 72px) + 6rem);
}

.portal-table tr:has(+ .notes-row:target) td,
.notes-row:target td {
  background: rgba(123, 151, 255, 0.07);
}

.admin-notes {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  margin-bottom: 0.75rem;
}

.admin-notes-save {
  justify-self: start;
}

.client-note-preview {
  display: block;
  max-width: 300px;
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-tertiary);
}

.portal-stat-link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.portal-stat-link:hover {
  border-color: var(--border-hairline-strong);
}

.portal-stat-link.is-warning,
.portal-stat-link.is-warning .portal-stat-value {
  border-color: rgba(255, 131, 131, 0.5);
  color: var(--danger);
}

.count-badge-warning {
  background: var(--danger);
}

.disk-meter {
  height: 12px;
  margin: var(--space-sm) 0 0.6rem;
  border-radius: var(--radius-full);
  background: var(--surface-glass-strong);
  overflow: hidden;
}

.disk-meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--status-ready), var(--status-sent));
}

.disk-meter.is-warning .disk-meter-fill {
  background: linear-gradient(90deg, var(--status-working), var(--danger));
}

.disk-summary {
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
}

.disk-summary strong {
  color: var(--text-primary);
}

.storage-breakdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-top: var(--space-md);
}

.storage-breakdown div {
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.storage-breakdown dt {
  font-size: 0.76rem;
  color: var(--text-tertiary);
}

.storage-breakdown dd {
  margin: 0.2rem 0 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cleanup-age {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: var(--space-sm) 0 var(--space-md);
}

.cleanup-age .form-label {
  margin: 0;
}

.cleanup-list {
  display: grid;
  gap: 0.6rem;
}

.cleanup-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.cleanup-row form {
  margin: 0;
}

.cleanup-info {
  display: grid;
  gap: 0.15rem;
}

.cleanup-name {
  font-weight: 600;
}

.cleanup-desc {
  font-size: 0.84rem;
}

.cleanup-count {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-secondary);
}

.btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

@media (max-width: 720px) {
  .storage-breakdown {
    grid-template-columns: repeat(2, 1fr);
  }

  .cleanup-row {
    grid-template-columns: 1fr auto;
  }

  .cleanup-info {
    grid-column: 1 / -1;
  }
}

/* --------------------------------------------------------------------------
   Account settings
   -------------------------------------------------------------------------- */
.account-grid {
  display: grid;
  gap: var(--space-md);
  max-width: 640px;
}

.account-form {
  display: grid;
  gap: 0.2rem;
}

.account-form .btn {
  justify-self: start;
}

.danger-card {
  border-color: rgba(255, 107, 107, 0.35);
}

/* --------------------------------------------------------------------------
   Locked features (client dashboard)
   The preview underneath is a non-functional lookalike; see locked_feature().
   -------------------------------------------------------------------------- */
.feature-locked {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 210px;
}

.feature-locked-preview {
  filter: blur(6px) saturate(0.6);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

.feature-locked-preview .preset-options {
  margin-bottom: var(--space-md);
}

.feature-locked-preview .dropzone {
  min-height: 150px;
}

.feature-locked-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: var(--space-md);
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(5, 5, 6, 0.55) 0%, rgba(5, 5, 6, 0.25) 70%);
}

.feature-locked-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 0.3rem;
  border-radius: 50%;
  border: 1px solid var(--border-hairline-strong);
  background: var(--surface-glass-strong);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
}

.feature-locked-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-primary);
}

.feature-locked-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.feature-locked-text {
  max-width: 380px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.feature-locked-text a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Admin: access switches
   -------------------------------------------------------------------------- */
.access-list {
  display: grid;
  gap: 0.6rem;
}

.access-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.8rem 1rem;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.access-row form {
  margin: 0;
}

.access-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.access-name {
  font-weight: 600;
}

.access-state {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  border: 1px solid currentColor;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.access-state.is-unlocked {
  color: var(--status-ready);
  background: rgba(111, 227, 163, 0.08);
}

.access-state.is-locked {
  color: var(--text-tertiary);
  background: var(--surface-glass);
}

.access-state.is-locked::before {
  content: "";
  width: 9px;
  height: 9px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4h1a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zm2 0h6V7a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4h1a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zm2 0h6V7a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.access-pills {
  white-space: nowrap;
}

.access-pills .access-state + .access-state {
  margin-left: 0.3rem;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 880px) {
  .portal-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  .message-summary {
    grid-template-columns: 10px 1fr auto;
  }

  .message-preview {
    grid-column: 2 / -1;
  }

  .message-body {
    padding-left: 0.5rem;
  }

  .preset-options {
    grid-template-columns: 1fr;
  }

  .instant-head {
    flex-direction: column;
  }

  .portal-page .card {
    padding: var(--space-md);
  }

  .portal-stat-value {
    font-size: 1.6rem;
  }

  .upload-progress-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --------------------------------------------------------------------------
   Two-factor login (Account settings, login-2fa.php)
   -------------------------------------------------------------------------- */
.two-factor h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.access-state.tfa-off {
  color: var(--text-tertiary);
  background: var(--surface-glass);
}

.two-factor-steps {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
  color: var(--text-secondary);
}

.totp-qr {
  width: 200px;
  max-width: 100%;
  margin: 0.25rem 0 0.75rem;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.totp-qr:empty {
  display: none;   /* no JavaScript: the setup key below still works */
}

.totp-qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.totp-secret {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 1rem;
  letter-spacing: 0.08em;
  user-select: all;
  word-break: break-all;
}

.totp-input {
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  max-width: 14rem;
}

.totp-cancel {
  margin-top: 0.6rem;
}

.two-factor-action {
  border-top: 1px solid var(--border-hairline);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

.two-factor-action summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
}

.two-factor-action[open] summary {
  margin-bottom: 0.75rem;
}

.two-factor-buttons {
  margin-top: 0.25rem;
}

.backup-codes {
  border: 1px solid rgba(201, 167, 255, 0.35);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  background: rgba(201, 167, 255, 0.06);
}

.backup-code-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, max-content));
  gap: 0.35rem 2rem;
  margin: 0.75rem 0 1rem;
  padding-left: 1.6rem;
}

.backup-code-list code {
  font-size: 1rem;
  letter-spacing: 0.06em;
}

/* Account → Emails */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0.25rem 0 0.25rem;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin-top: 0.15rem;
  flex: none;
  accent-color: #f5f5f7;
}

/* Sign-ups that haven't entered their emailed code (admin) */
.access-state.unconfirmed-pill {
  color: #ffb86b;
  background: rgba(255, 184, 107, 0.08);
}

.access-hint {
  flex-basis: 100%;
  font-size: 0.85rem;
}

/* verify-email.php */
.verify-resend {
  margin-top: 0.6rem;
}

.verify-change {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-hairline);
}

.verify-change summary {
  cursor: pointer;
  color: var(--text-secondary);
}

.verify-change[open] summary {
  margin-bottom: 0.75rem;
}

/* Dashboard: suggest two-factor login to clients who don't have it on */
.tfa-nudge {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-tertiary);
}

.tfa-nudge a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
