:root {
  color-scheme: dark;
  --bg: #090a0b;
  --surface: #0b0c0d;
  --surface-strong: #0b0c0d;
  --ink: #fafafa;
  --muted: #a1a1aa;
  --soft: #202124;
  --soft-strong: #2b2d31;
  --accent: #f5f5f5;
  --accent-strong: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --green: #5ee4ad;
  --green-soft: rgba(94, 228, 173, 0.12);
  --amber: #f6c46b;
  --amber-soft: rgba(246, 196, 107, 0.12);
  --danger: #ff7a98;
  --danger-soft: rgba(255, 122, 152, 0.12);
  --button-bg: #fafafa;
  --button-fg: #090a0b;
  --button-hover: #e5e5e5;
  --icon-muted: #a1a1aa;
  --icon-strong: #f4f4f5;
  --theme-toggle-icon: #f4f4f5;
  --notion-icon: #f4f4f5;
  --ring: rgba(250, 250, 250, 0.24);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #f8fafc;
  --ink: #142033;
  --muted: #637083;
  --soft: #dfe5ee;
  --soft-strong: #cfd8e5;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #e8efff;
  --green: #0f9f6e;
  --green-soft: #e9f8f2;
  --amber: #b45f06;
  --amber-soft: #fff4df;
  --danger: #be123c;
  --danger-soft: #fff1f3;
  --button-bg: #09090b;
  --button-fg: #fafafa;
  --button-hover: #202124;
  --icon-muted: #647083;
  --icon-strong: #111827;
  --theme-toggle-icon: #111827;
  --notion-icon: #09090b;
  --ring: rgba(9, 9, 11, 0.14);
  --shadow: 0 24px 70px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Cairo, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  background:
    linear-gradient(120deg, transparent 0 18%, color-mix(in srgb, var(--accent) 8%, transparent) 31%, transparent 46%),
    linear-gradient(300deg, transparent 0 46%, color-mix(in srgb, var(--green) 13%, transparent) 58%, transparent 74%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 38%, transparent), transparent 42%);
  filter: blur(8px);
  opacity: 0.9;
  transform: translate3d(0, 0, 0) scale(1.04);
  animation: ambient-drift 16s ease-in-out infinite alternate;
}

body::after {
  background-image:
    linear-gradient(color-mix(in srgb, var(--soft-strong) 26%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--soft-strong) 26%, transparent) 1px, transparent 1px),
    radial-gradient(color-mix(in srgb, var(--ink) 10%, transparent) 0.8px, transparent 0.8px);
  background-position:
    center,
    center,
    center;
  background-size:
    72px 72px,
    72px 72px,
    18px 18px;
  mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 82%, transparent);
  opacity: 0.42;
  transform: translate3d(0, 0, 0);
  animation: grid-drift 28s linear infinite;
}

button,
input,
select {
  font: inherit;
  font-weight: 400;
}

button {
  border: 0;
}

svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.page-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 20px;
}

.import-stack {
  display: grid;
  width: 650px;
  max-width: 100%;
  gap: 20px;
  justify-items: center;
}

.import-form {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 650px;
  max-width: 100%;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.theme-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--soft);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--theme-toggle-icon);
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.theme-toggle:hover {
  border-color: var(--soft-strong);
  background: color-mix(in srgb, var(--surface-strong) 82%, var(--ink) 18%);
  transform: translateY(-1px);
}

.theme-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

body[data-theme="dark"] .theme-icon-moon,
body[data-theme="light"] .theme-icon-sun {
  display: none;
}

.form-header {
  display: flex;
  max-width: calc(100% - 56px);
  align-items: center;
  gap: 12px;
  margin: 2px 0 10px;
  min-width: 0;
}

.notion-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  color: var(--notion-icon);
}

.notion-icon path {
  fill: currentColor;
}

.form-title {
  flex: 1;
  max-width: none;
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.35rem, 4vw, 1.72rem);
  font-weight: 400;
  line-height: 1.15;
  min-width: 0;
}

.form-loading-overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 14px;
  border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--ink);
  text-align: center;
  backdrop-filter: blur(10px);
}

.form-loading-overlay[hidden] {
  display: none;
}

.loading-orbit {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--soft);
  border-radius: 50%;
  background: var(--surface-strong);
}

.loading-orbit::before {
  position: absolute;
  inset: -5px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: color-mix(in srgb, var(--accent) 36%, transparent);
  border-radius: 50%;
  content: "";
  animation: spin 800ms linear infinite;
}

.loading-orbit span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pulse 900ms ease-in-out infinite;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}

label {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 400;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--soft);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

input {
  padding: 0 12px;
}

select {
  appearance: none;
  padding: 0 44px 0 12px;
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%2398a6ba' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 20px 20px;
  text-overflow: ellipsis;
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--soft));
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--ring);
}

.password-input-shell {
  position: relative;
}

.password-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.password-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.password-status[hidden] {
  display: none;
}

.password-status svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.password-status.is-saved {
  color: color-mix(in srgb, var(--green) 70%, var(--muted));
}

.password-input-shell input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 7px;
  background: transparent;
  color: var(--icon-muted);
  cursor: pointer;
  transform: translateY(-50%);
  transition:
    background 140ms ease,
    color 140ms ease;
}

.password-toggle:hover {
  background: color-mix(in srgb, var(--surface-strong) 82%, var(--ink) 18%);
  color: var(--icon-strong);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.password-eye-off {
  display: none;
}

.password-toggle.is-visible .password-eye {
  display: none;
}

.password-toggle.is-visible .password-eye-off {
  display: block;
}

.post-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--soft);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--icon-muted);
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--soft-strong);
  background: color-mix(in srgb, var(--surface-strong) 82%, var(--ink) 18%);
  color: var(--icon-strong);
  transform: translateY(-1px);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button.is-loading svg {
  animation: spin 800ms linear infinite;
}

.post-select-shell {
  position: relative;
}

.submit-button {
  display: inline-flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  border: 1px solid var(--button-bg);
  border-radius: var(--radius-sm);
  background: var(--button-bg);
  color: var(--button-fg);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 400;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.submit-button:hover:not(:disabled) {
  background: var(--button-hover);
  border-color: var(--button-hover);
  transform: translateY(-1px);
}

.submit-button:active:not(:disabled) {
  transform: translateY(0);
}

.theme-toggle:focus-visible,
.submit-button:focus-visible,
.icon-button:focus-visible,
.password-toggle:focus-visible,
.dialog-close:focus-visible,
.dialog-button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

.submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.64;
  box-shadow: none;
}

.button-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
}

.submit-button.is-loading .button-spinner {
  display: inline-block;
  animation: spin 800ms linear infinite;
}

.button-icon {
  display: inline-grid;
  width: 17px;
  height: 17px;
  place-items: center;
}

.button-icon svg {
  width: 17px;
  height: 17px;
}

.submit-button.is-loading .button-icon {
  display: none;
}

.result-panel {
  overflow: hidden;
  border: 1px solid var(--soft);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--muted);
}

.result-panel[hidden] {
  display: none;
}

.result-panel.is-success {
  border-color: color-mix(in srgb, var(--green) 34%, var(--soft));
  background: var(--green-soft);
  color: var(--green);
}

.result-panel.is-error {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--soft));
  background: var(--danger-soft);
  color: var(--danger);
}

.result-panel.is-loading {
  border-color: color-mix(in srgb, var(--amber) 34%, var(--soft));
  background: var(--amber-soft);
  color: var(--amber);
}

.dialog-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent 36%),
    rgba(0, 0, 0, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.success-dialog {
  position: relative;
  display: grid;
  width: min(100%, 420px);
  justify-items: center;
  gap: 14px;
  padding: 34px 26px 24px;
  border: 1px solid var(--soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  transition:
    opacity 220ms ease,
    transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.dialog-backdrop.is-open .success-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--soft);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--muted);
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.dialog-close:hover {
  background: color-mix(in srgb, var(--surface-strong) 82%, var(--ink) 18%);
  color: var(--ink);
  transform: translateY(-1px);
}

.dialog-close svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.success-orb {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--green) 32%, var(--soft));
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.16), transparent 34%),
    var(--green-soft);
  color: var(--green);
}

.success-orb::before {
  position: absolute;
  inset: -8px;
  border: 1px solid color-mix(in srgb, var(--green) 18%, transparent);
  border-radius: inherit;
  content: "";
  animation: success-ring 900ms ease-out both;
}

.success-orb svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
}

.dialog-backdrop.is-open .success-orb svg {
  animation: draw-check 520ms 120ms ease-out forwards;
}

.success-dialog h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.26rem;
  font-weight: 400;
  line-height: 1.2;
}

.success-dialog p {
  max-width: 32ch;
  margin: -2px 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.dialog-button {
  display: inline-flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--button-bg);
  border-radius: var(--radius-sm);
  background: var(--button-bg);
  color: var(--button-fg);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 400;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.dialog-button:hover {
  background: var(--button-hover);
  border-color: var(--button-hover);
  transform: translateY(-1px);
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--soft);
  font-size: 0.84rem;
  font-weight: 400;
}

.text-button {
  padding: 4px 0;
  background: transparent;
  color: currentColor;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.twitter-page-link {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-self: center;
  padding: 2px 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 20px;
  text-align: center;
  text-decoration: none;
  text-underline-offset: 4px;
  transition: color 140ms ease;
}

.twitter-page-link:visited {
  color: var(--muted);
}

.twitter-page-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.twitter-page-link:focus-visible {
  border-radius: var(--radius-sm);
  outline: 3px solid var(--ring);
  outline-offset: 4px;
}

pre {
  max-height: 200px;
  margin: 0;
  overflow: auto;
  padding: 13px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.86rem;
  line-height: 1.55;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.36;
    transform: scale(0.82);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes ambient-drift {
  0% {
    transform: translate3d(-1.5%, -1%, 0) scale(1.04);
  }

  100% {
    transform: translate3d(1.5%, 1%, 0) scale(1.08);
  }
}

@keyframes grid-drift {
  to {
    background-position:
      calc(50% + 72px) calc(50% + 72px),
      calc(50% + 72px) calc(50% + 72px),
      calc(50% + 18px) calc(50% + 18px);
  }
}

@keyframes success-ring {
  0% {
    opacity: 0.78;
    transform: scale(0.78);
  }

  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

@keyframes draw-check {
  to {
    stroke-dashoffset: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 560px) {
  .page-shell {
    padding: 12px;
  }

  .import-form {
    gap: 14px;
    padding: 20px;
  }

  .form-header {
    margin-top: 4px;
  }

  .field-label-row {
    grid-template-columns: 1fr auto;
  }

  .post-count {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
