/* Shared foundation: tokens, reset, header/footer chrome, form controls. */

:root {
  --accent: #7e46b9;
  --ink-900: #08070d;
  --ink-800: #0d0b14;
  --ink-700: #15121f;
  --ink-600: #1d1929;
  --ink-500: #2a2438;
  --line: #332b45;
  --text: #ece9f5;
  --text-dim: #a49cb8;
  --danger: #e5484d;
  --ok: #46b97e;

  --gap: 16px;
  --cell: clamp(96px, 20vw, 152px);
  --radius: 14px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

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

/* author `display` rules would otherwise win over the UA [hidden] rule */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--ink-800);
  background-image: radial-gradient(
      900px 520px at 12% -10%,
      color-mix(in srgb, var(--accent) 26%, transparent),
      transparent 70%
    ),
    radial-gradient(700px 460px at 100% 5%, rgba(87, 191, 255, 0.12), transparent 65%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 80%, white);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ chrome */

.wrap {
  width: min(1600px, 100% - 48px);
  margin-inline: auto;
}

@media (max-width: 640px) {
  .wrap {
    width: calc(100% - 28px);
  }
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

/* title.png, pinned to the top-left corner of the page */
.brand__title {
  height: clamp(34px, 4.4vw, 52px);
  width: auto;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.45));
}

/* Three slots: left / centre / right. The centre (ICP filing number) keeps its
   natural width and stays centred; the side slots shrink and scroll instead. */
.site-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 40px 0 34px;
  color: var(--text-dim);
  font-size: 13px;
}

.site-footer__side {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-footer__center {
  min-width: 0;
  text-align: center;
}

/* the filing number is a link out to the MIIT filing system */
.site-footer__link {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.site-footer__link:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* free text: stays on one line and scrolls sideways rather than crowding the centre */
.site-footer__text {
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  overscroll-behavior-x: contain;
}

.site-footer__side--right .site-footer__text {
  margin-left: auto;
}

.site-footer__logo {
  flex: none;
  width: 26px;
  height: 26px;
  opacity: 0.9;
}

/* ----------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink-600);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.16s, opacity 0.16s;
}

.btn:hover:not(:disabled) {
  background: var(--ink-500);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 70%, white);
  color: #fff;
  font-weight: 600;
}

.btn--primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 84%, white);
}

.btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 26%, var(--ink-500));
  border-color: var(--danger);
}

.btn--ghost {
  background: transparent;
}

.btn--icon {
  padding: 7px 9px;
  font-size: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label {
  font-size: 12.5px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--ink-800);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}

textarea.input {
  resize: vertical;
  min-height: 78px;
  line-height: 1.55;
}

.input:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  outline: none;
}

.input[type='color'] {
  padding: 3px;
  height: 38px;
  cursor: pointer;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink-600);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  font-size: 13.5px;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  border-color: var(--danger);
  color: #ffd9da;
}

.toast.is-ok {
  border-color: color-mix(in srgb, var(--ok) 60%, var(--line));
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
