:root {
  color-scheme: dark;
  --page-bg: #040816;
  --page-bg-soft: #081022;
  --surface: rgba(10, 15, 29, 0.78);
  --surface-strong: rgba(11, 17, 33, 0.9);
  --surface-elevated: rgba(15, 23, 44, 0.94);
  --text-main: #eef2ff;
  --text-muted: #b6c0e0;
  --text-soft: #8490b5;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(34, 211, 238, 0.28);
  --primary: #8b5cf6;
  --primary-strong: #6d28d9;
  --accent: #22d3ee;
  --success: #14b8a6;
  --danger: #fb7185;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
  --shadow-soft: 0 16px 36px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background-color: var(--page-bg);
  background-image:
    radial-gradient(circle at 10% 14%, rgba(34, 211, 238, 0.14), transparent 20%),
    radial-gradient(circle at 88% 16%, rgba(139, 92, 246, 0.2), transparent 24%),
    radial-gradient(circle at 50% 100%, rgba(59, 130, 246, 0.12), transparent 30%),
    linear-gradient(180deg, #040815 0%, #050917 52%, #02040b 100%);
  color: var(--text-main);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.page-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 26px;
  padding: 24px 26px 22px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(12, 18, 38, 0.96), rgba(7, 10, 21, 0.9)),
    var(--surface-strong);
  box-shadow: var(--shadow);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(12px);
  pointer-events: none;
}

.hero::before {
  top: -120px;
  right: -40px;
  width: 260px;
  height: 260px;
  background: rgba(124, 58, 237, 0.22);
}

.hero::after {
  bottom: -160px;
  left: -60px;
  width: 320px;
  height: 320px;
  background: rgba(34, 211, 238, 0.12);
}

.hero__topbar,
.card-form__header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hero__identity {
  min-width: 0;
}

.hero__eyebrow,
.card-form__eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1,
.card-form h2 {
  margin: 0;
  line-height: 1.08;
}

.hero h1 {
  font-size: clamp(1.72rem, 3vw, 2.7rem);
  letter-spacing: -0.03em;
}

.hero__description {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  margin: 14px 0 0;
  line-height: 1.75;
  color: var(--text-muted);
}

.hero__meta {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.hero__meta-item {
  margin: 0;
  display: grid;
  gap: 6px;
}

.hero__meta-item span {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.hero__meta-item strong {
  line-height: 1.65;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text-main);
}

.auth-panel {
  display: flex;
  justify-content: flex-end;
}

.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.auth-chip:hover,
.auth-chip:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(34, 211, 238, 0.34);
  background: rgba(255, 255, 255, 0.08);
}

.auth-chip.is-authenticated {
  border-color: rgba(20, 184, 166, 0.28);
}

.auth-chip__indicator {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #64748b;
  box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.14);
}

.auth-chip.is-authenticated .auth-chip__indicator {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
}

.auth-chip__icon {
  font-size: 1rem;
  color: var(--accent);
}

.auth-chip__text {
  font-weight: 700;
  white-space: nowrap;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.empty-state,
.link-card,
.add-card {
  aspect-ratio: 2 / 1;
}

.empty-state {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(11, 16, 30, 0.86);
  box-shadow: var(--shadow-soft);
}

.empty-state--error {
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(40, 12, 24, 0.9);
}

.empty-state__title,
.empty-state__text {
  margin: 0;
}

.empty-state__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.empty-state__text {
  line-height: 1.65;
  color: var(--text-muted);
}

.page-footer {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(8, 12, 24, 0.76);
  color: var(--text-soft);
  box-shadow: var(--shadow-soft);
}

.page-footer p {
  margin: 0;
  line-height: 1.72;
}

.link-card,
.add-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.link-card {
  color: var(--card-text, #ffffff);
  background: var(--card-bg, #0f6cbd);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.link-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.18);
}

.link-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 26%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 40%);
  pointer-events: none;
}

.card-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(2, 40px);
  gap: 8px;
}

.action-button,
.delete-button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(6, 10, 22, 0.28);
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  backdrop-filter: blur(10px);
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.action-button:hover,
.delete-button:hover,
.action-button:focus-visible,
.delete-button:focus-visible {
  transform: translateY(-1px);
  background: rgba(6, 10, 22, 0.44);
  border-color: rgba(255, 255, 255, 0.24);
}

.action-button--edit {
  font-size: 0.96rem;
}

.delete-button {
  font-size: 1.4rem;
}

.link-card__surface {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
  padding: 104px 24px 24px;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(4, 8, 18, 0.06), rgba(4, 8, 18, 0.76)),
    var(--card-bg, #0f6cbd);
  color: inherit;
  cursor: pointer;
  outline: none;
  text-decoration: none;
}

.link-card__surface:focus-visible {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.68);
}

.link-card__title {
  margin: 0;
  font-size: clamp(1.28rem, 2vw, 1.86rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.link-card__description,
.link-card__url {
  margin: 0;
  line-height: 1.55;
  opacity: 0.96;
}

.link-card__description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.link-card__url {
  width: fit-content;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.add-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 26px;
  border: 1px dashed rgba(139, 92, 246, 0.42);
  background: linear-gradient(145deg, rgba(13, 19, 37, 0.98), rgba(7, 10, 20, 1));
  color: #dce3ff;
  text-align: center;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.add-card:hover,
.add-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(34, 211, 238, 0.5);
  background: linear-gradient(145deg, rgba(16, 23, 43, 1), rgba(9, 13, 26, 1));
}

.add-card--locked {
  border-color: rgba(148, 163, 184, 0.3);
}

.add-card__icon {
  font-size: clamp(3.8rem, 10vw, 5.4rem);
  line-height: 1;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.2);
}

.add-card__text {
  font-size: 1.04rem;
  font-weight: 700;
}

.add-card__hint {
  line-height: 1.6;
  color: var(--text-muted);
}

.card-dialog {
  width: min(620px, calc(100% - 24px));
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 28px;
  box-shadow: var(--shadow);
  background: transparent;
}

.card-dialog::backdrop {
  background: rgba(2, 6, 18, 0.72);
  backdrop-filter: blur(8px);
}

.card-form {
  display: grid;
  gap: 18px;
  padding: 28px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(13, 19, 38, 0.98), rgba(8, 12, 24, 0.98));
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  font-weight: 600;
  color: #e6ebff;
}

.field input,
.field textarea,
.secondary-button,
.primary-button,
.icon-button {
  border-radius: 14px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(8, 12, 23, 0.92);
  color: var(--text-main);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.12);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.field--color {
  align-items: flex-start;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

#color-input {
  width: 64px;
  height: 48px;
  padding: 6px;
  background: rgba(8, 12, 23, 0.92);
}

#color-value {
  font-weight: 700;
  color: var(--text-muted);
}

.form-error {
  margin: 0;
  color: #fda4af;
  font-weight: 600;
}

.auth-form__hint {
  margin: 0;
  line-height: 1.7;
  color: var(--text-muted);
}

.card-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.secondary-button,
.primary-button,
.icon-button {
  border: 1px solid transparent;
}

.secondary-button,
.icon-button {
  background: rgba(255, 255, 255, 0.06);
  color: #dfe7ff;
}

.secondary-button,
.primary-button {
  padding: 12px 18px;
  font-weight: 700;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
  color: #ffffff;
  box-shadow: 0 14px 30px rgba(124, 58, 237, 0.32);
}

.icon-button {
  width: 42px;
  height: 42px;
  font-size: 1.6rem;
  line-height: 1;
}

@media (max-width: 980px) {
  .hero__meta {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 24px, 1220px);
    padding-top: 22px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .hero,
  .card-form {
    padding: 22px;
  }

  .link-card__surface {
    padding: 100px 22px 22px;
  }
}

@media (max-width: 700px) {
  .hero__topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-panel {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 20px, 1220px);
    padding-bottom: 40px;
  }

  .card-actions {
    top: 12px;
    right: 12px;
    grid-template-columns: repeat(2, 36px);
  }

  .action-button,
  .delete-button {
    width: 36px;
    height: 36px;
  }

  .link-card__surface {
    padding: 94px 18px 18px;
  }

  .card-form__actions {
    flex-direction: column-reverse;
  }

  .secondary-button,
  .primary-button,
  .auth-chip {
    width: 100%;
    justify-content: center;
  }
}
