/* ==========================================================================
   Components
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 15px;
  line-height: 20px;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--quick) var(--ease), border-color var(--quick) var(--ease),
    color var(--quick) var(--ease), filter var(--quick) var(--ease);
}

.button:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.button--secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}

.button--secondary:hover {
  background: var(--surface-raised);
  filter: none;
}

.button--ghost {
  background: transparent;
  color: var(--text);
  padding-left: 12px;
  padding-right: 12px;
}

.button--ghost:hover {
  background: var(--surface-raised);
  filter: none;
}

.button--danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.button--danger:hover {
  background: var(--sunset-orange);
  border-color: var(--sunset-orange);
  color: var(--dusk-ink);
  filter: none;
}

.button--small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 10px;
}

.button--block {
  width: 100%;
}

.button[disabled],
.button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.inline-form {
  display: inline;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form {
  display: grid;
  gap: var(--space-4);
}

.form--narrow {
  max-width: 460px;
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

.field > label,
.field legend {
  font-weight: 600;
  font-size: 15px;
  line-height: 22px;
  padding: 0;
}

.field .required::after {
  content: " *";
  color: var(--text-muted);
}

.help {
  font-size: 13px;
  line-height: 20px;
  color: var(--text-muted);
}

.help ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.errorlist {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.form-errors {
  padding: 12px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--text);
}

.form-errors .errorlist {
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
input[type="datetime-local"],
input[type="tel"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: 16px;
  line-height: 22px;
  transition: border-color var(--quick) var(--ease), background var(--quick) var(--ease);
}

[data-theme="skylight"] input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
[data-theme="skylight"] select,
[data-theme="skylight"] textarea {
  background: var(--surface-raised);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 24px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--text-muted);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  font-size: 14px;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  flex: none;
  accent-color: var(--accent);
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 600;
  line-height: 24px;
  cursor: pointer;
}

.check .help {
  font-weight: 400;
}

.field--check {
  gap: 2px;
}

.field--check .help,
.field--check .errorlist {
  padding-left: 28px;
}

.radio-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.radio-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  cursor: pointer;
}

.hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.form-actions .spacer {
  margin-left: auto;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin: 0;
  padding: var(--space-3) var(--space-4) var(--space-4);
}

fieldset > legend {
  padding: 0 8px;
  margin-left: -8px;
  font-weight: 800;
}

/* Choice cards (payment methods, variants) */
.choices {
  display: grid;
  gap: 8px;
}

.choices--pills {
  display: flex;
  flex-wrap: wrap;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  cursor: pointer;
  transition: border-color var(--quick) var(--ease), background var(--quick) var(--ease);
}

[data-theme="skylight"] .choice {
  background: var(--surface-raised);
}

.choice:hover {
  border-color: var(--text-muted);
}

.choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.choice input {
  margin: 0;
}

.choices--pills .choice {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
}

.choice__body {
  display: grid;
  line-height: 20px;
}

.choice__body small {
  color: var(--text-muted);
  font-size: 13px;
}

.choice .icon {
  color: var(--text-muted);
  flex: none;
}

.choice--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Quantity stepper */
.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.stepper button {
  width: 44px;
  border: 0;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
}

.stepper button:hover {
  background: var(--surface-hover);
}

.stepper input {
  width: 64px;
  border: 0;
  border-radius: 0;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Markdown editor
   -------------------------------------------------------------------------- */

.editor {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  overflow: hidden;
}

[data-theme="skylight"] .editor {
  background: var(--surface-raised);
}

.editor:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.editor__bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-raised);
  flex-wrap: wrap;
}

.editor__bar button {
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.editor__bar button:hover,
.editor__bar button[aria-pressed="true"] {
  background: var(--surface-hover);
  color: var(--text);
}

.editor__bar .editor__tabs {
  margin-left: auto;
  display: flex;
  gap: 2px;
}

.editor textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  min-height: 160px;
}

.editor textarea:focus-visible {
  outline: none;
}

.editor__preview {
  min-height: 160px;
  padding: 12px 14px;
}

.editor__hint {
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Cards, panels, badges
   -------------------------------------------------------------------------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--quick) var(--ease), transform 600ms var(--ease);
}

.card--link:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.card__media {
  aspect-ratio: 16 / 9;
  background: var(--surface-sunken);
  overflow: hidden;
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1200ms var(--ease);
}

.card--link:hover .card__media img {
  transform: scale(1.03);
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--space-4);
  flex: 1;
}

.card__body p {
  margin: 0;
  color: var(--text-muted);
}

.card__title {
  font-size: 20px;
  line-height: 28px;
  font-weight: 800;
}

.card__title a {
  color: var(--text);
  text-decoration: none;
}

.card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card__meta {
  margin-top: auto;
  padding-top: 8px;
}

.panel {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.panel--flush {
  padding: 0;
  overflow: hidden;
}

.panel > h2,
.panel > header h2 {
  font-size: 18px;
  line-height: 26px;
  margin-bottom: var(--space-3);
}

.panel + .panel {
  margin-top: var(--space-3);
}

.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

@media (max-width: 640px) {
  .grid--3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge--teal {
  background: var(--atrium-teal);
  border-color: var(--atrium-teal);
  color: var(--dusk-ink);
}

.badge--purple {
  background: var(--carpet-purple);
  border-color: var(--carpet-purple);
  color: var(--skylight);
}

.badge--orange {
  background: var(--sunset-orange);
  border-color: var(--sunset-orange);
  color: var(--dusk-ink);
}

.badge--lime {
  background: var(--signal-lime);
  border-color: var(--signal-lime);
  color: var(--dusk-ink);
}

.badge--soft {
  background: var(--surface-sunken);
  border-color: var(--line);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  text-decoration: none;
}

a.tag:hover,
.tag[aria-current="page"] {
  border-color: var(--accent);
  color: var(--text);
}

.tag[aria-current="page"] {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
}

.status-dot--ok {
  background: var(--atrium-teal);
}

.status-dot--warn {
  background: var(--signal-lime);
}

[data-theme="skylight"] .status-dot--warn {
  background: #b59b00;
}

.status-dot--bad {
  background: var(--sunset-orange);
}

/* Avatars: rounded tiles like the brand icon (22% corner). */
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 22%;
  overflow: hidden;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  background: var(--surface-hover);
  color: var(--text);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--xs {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar--lg {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.avatar--xl {
  width: 112px;
  height: 112px;
  font-size: 36px;
}

.avatar--teal {
  background: var(--atrium-teal);
  color: var(--dusk-ink);
}

.avatar--purple {
  background: var(--carpet-purple);
  color: var(--skylight);
}

.avatar--orange {
  background: var(--sunset-orange);
  color: var(--dusk-ink);
}

.avatar--lime {
  background: var(--signal-lime);
  color: var(--dusk-ink);
}

.byline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 20px;
}

.byline a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.byline a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Notices and empty states
   -------------------------------------------------------------------------- */

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  line-height: 24px;
}

.notice > .icon {
  margin-top: 2px;
  color: var(--accent);
  flex: none;
}

.notice--warn {
  border-left-color: var(--sunset-orange);
}

.notice--warn > .icon {
  color: var(--sunset-orange);
}

.notice p {
  margin: 0;
}

.notice form {
  display: inline;
}

.empty {
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--text-muted);
}

.empty .label {
  display: block;
  margin-bottom: var(--space-2);
}

.empty p {
  margin: 0 auto;
  max-width: 420px;
}

.empty .button {
  margin-top: var(--space-3);
}

/* Toolbars above lists */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
}

.toolbar form {
  display: flex;
  gap: 8px;
}

.toolbar input[type="search"] {
  min-height: 38px;
  width: 280px;
  max-width: 100%;
}

@media (max-width: 520px) {
  .toolbar form {
    width: 100%;
  }

  .toolbar input[type="search"] {
    width: auto;
    flex: 1;
  }
}

.toolbar .spacer {
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  line-height: 22px;
}

.table th {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--surface-sunken);
}

[data-theme="skylight"] .table th {
  background: var(--surface);
}

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

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.table a:hover {
  color: var(--accent);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

/* Definition lists */
.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  margin: 0;
}

.details dt {
  color: var(--text-muted);
  font-weight: 600;
}

.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Pagination and tabs
   -------------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: var(--space-5);
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.pagination a:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
}

.pagination [aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.pagination .gap {
  border: 0;
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.count--alert {
  background: var(--sunset-orange);
  color: var(--dusk-ink);
}

/* --------------------------------------------------------------------------
   Prose (rendered markdown)
   -------------------------------------------------------------------------- */

.prose {
  font-size: 17px;
  line-height: 28px;
  overflow-wrap: break-word;
}

.prose > * + * {
  margin-top: 1.1em;
}

.prose p {
  margin: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  margin-top: 1.8em;
  font-weight: 800;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.prose h1 {
  font-size: 30px;
  line-height: 38px;
}

.prose h2 {
  font-size: 26px;
  line-height: 34px;
}

.prose h3 {
  font-size: 21px;
  line-height: 30px;
}

.prose h4 {
  font-size: 18px;
}

.prose > :first-child {
  margin-top: 0;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.35em;
}

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.prose code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.prose pre {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  overflow-x: auto;
  font-size: 14px;
  line-height: 22px;
}

.prose pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}

.prose img {
  border-radius: var(--radius-md);
  margin-left: auto;
  margin-right: auto;
}

.prose hr {
  margin: 2em 0;
}

.prose table {
  display: block;
  overflow-x: auto;
  font-size: 15px;
}

.prose th,
.prose td {
  padding: 8px 12px;
  border: 1px solid var(--line);
}

.prose th {
  background: var(--surface-sunken);
}

.prose .contains-task-list {
  list-style: none;
  padding-left: 0.2em;
}

.prose .task-list-item input {
  margin-right: 8px;
  vertical-align: -3px;
}

.prose .footnotes {
  font-size: 14px;
  color: var(--text-muted);
}

.prose mark {
  background: var(--signal-lime);
  color: var(--dusk-ink);
}

.prose--compact {
  font-size: 16px;
  line-height: 26px;
}

.prose--compact h1 {
  font-size: 22px;
  line-height: 30px;
}

.prose--compact h2 {
  font-size: 20px;
  line-height: 28px;
}

.prose--compact h3,
.prose--compact h4 {
  font-size: 17px;
}

.prose--compact h1,
.prose--compact h2,
.prose--compact h3 {
  margin-top: 1.2em;
}

.embed--video {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
}

.embed--video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --------------------------------------------------------------------------
   Auth layouts
   -------------------------------------------------------------------------- */

.auth {
  display: grid;
  place-items: center;
  padding: var(--space-6) 0;
}

.auth__panel {
  width: min(460px, 100%);
  padding: var(--space-5);
}

.auth__panel h1 {
  margin-bottom: var(--space-2);
}

.auth__panel > p {
  color: var(--text-muted);
}

.auth__alt {
  margin-top: var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

@media (max-width: 520px) {
  .auth {
    padding: var(--space-4) 0;
  }

  .auth__panel {
    padding: var(--space-4) var(--space-3);
  }
}

fieldset.field {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

fieldset.field > legend {
  margin: 0 0 6px;
  padding: 0;
  font-weight: 600;
}

.stepper {
  justify-self: start;
}
