:root {
  --bg: #f4f7f9;
  --blob-a: rgba(232, 241, 250, 0.62);
  --blob-b: rgba(220, 235, 247, 0.58);
  --surface: #f0f4f8;
  --accent: #5b9bd5;
  --accent-soft: #7fb3e8;
  --text: #3a4a5c;
  --muted: #708292;
  --danger: #b2575f;
  --shadow-dark: #d1dce5;
  --shadow-light: #ffffff;
  --raised: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
  --soft: 3px 3px 8px var(--shadow-dark), -3px -3px 8px var(--shadow-light);
  --inset: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
  --link-row-height: 168px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

body {
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

button {
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(91, 155, 213, 0.36);
  outline-offset: 3px;
}

svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.hidden {
  display: none !important;
}

.blob {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(74px);
  pointer-events: none;
}

.blob-a {
  width: 280px;
  height: 220px;
  left: -80px;
  top: 36px;
  background: var(--blob-a);
  transform: rotate(-14deg) scaleX(1.24);
}

.blob-b {
  width: 340px;
  height: 250px;
  right: -120px;
  bottom: 42px;
  background: var(--blob-b);
  transform: rotate(24deg) scaleX(1.12);
}

.blob-c {
  width: 230px;
  height: 190px;
  right: 12%;
  top: 34%;
  background: rgba(232, 241, 250, 0.42);
  transform: rotate(32deg) scaleX(1.34);
}

.pin-screen,
.app-screen {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

.pin-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.pin-card {
  width: min(320px, calc(100vw - 48px));
  padding: 28px 22px 24px;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--raised);
  text-align: center;
}

.pin-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 22px 0 26px;
}

.pin-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--inset);
}

.pin-dot.filled {
  background: var(--accent-soft);
  box-shadow: inset 1px 1px 3px rgba(58, 74, 92, 0.22), inset -1px -1px 2px rgba(255, 255, 255, 0.56);
}

.pin-card.shake {
  animation: shake 180ms linear 2;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  justify-content: center;
  gap: 14px;
}

.key,
.round-button,
.small-icon-button,
.paste-button {
  border: 0;
  background: var(--surface);
  box-shadow: var(--raised);
}

.key {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 650;
}

.key:active,
.round-button:active,
.small-icon-button:active,
.paste-button:active,
.category-pill.active {
  box-shadow: var(--inset);
}

.icon-key {
  display: grid;
  place-items: center;
}

.app-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  padding: max(14px, env(safe-area-inset-top)) 12px calc(116px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 4;
  width: 100%;
  padding: 4px 0;
  background: linear-gradient(180deg, rgba(244, 247, 249, 0.96), rgba(244, 247, 249, 0.76));
  backdrop-filter: blur(8px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  column-gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 40px;
}

.category-row {
  display: flex;
  min-width: 0;
  height: 36px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--soft);
  scrollbar-width: none;
}

.category-row::-webkit-scrollbar {
  display: none;
}

.category-rail {
  width: 100%;
}

.category-pill,
.category-filler {
  flex: 0 0 auto;
  height: 36px;
  border: 0;
  border-right: 1px solid rgba(112, 130, 146, 0.16);
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 700;
}

.category-pill {
  min-width: 64px;
}

.category-filler {
  flex: 1 1 72px;
  min-width: 48px;
  pointer-events: none;
}

.category-pill:first-child {
  border-radius: 20px 0 0 20px;
}

.category-filler {
  border-radius: 0 20px 20px 0;
}

.category-pill.active {
  color: var(--accent);
}

.round-button,
.small-icon-button {
  display: grid;
  place-items: center;
  border-radius: 999px;
}

.round-button {
  width: 40px;
  height: 40px;
}

.add-button {
  position: relative;
  color: var(--accent);
  border-radius: 999px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  padding-top: 8px;
  min-height: 44px;
}

.small-icon-button {
  width: 40px;
  height: 40px;
}

.link-list {
  display: grid;
  flex: 1;
  min-height: 0;
  gap: 10px;
  grid-auto-rows: var(--link-row-height);
  align-content: start;
  overflow-y: auto;
  padding-top: 2px;
  padding-bottom: 10px;
}

.link-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 44px;
  gap: 10px;
  height: var(--link-row-height);
  min-height: var(--link-row-height);
  max-height: var(--link-row-height);
  align-items: center;
  overflow: hidden;
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--soft);
  padding: 14px 12px;
  text-align: left;
}

.link-main {
  display: grid;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.platform-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--inset);
  font-size: 18px;
  font-weight: 800;
  overflow: hidden;
}

.link-favicon,
.fallback-glyph {
  grid-area: 1 / 1;
}

.link-favicon {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
}

.link-favicon.loaded + .fallback-glyph {
  display: none;
}

.link-domain {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-title {
  display: -webkit-box;
  min-width: 0;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.22;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.link-description {
  display: -webkit-box;
  min-width: 0;
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.link-action-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--soft);
  color: var(--muted);
}

.link-action-button svg {
  width: 22px;
  height: 22px;
  stroke-width: 4;
}

.skeleton .link-title,
.skeleton .link-description {
  color: transparent;
  border-radius: 8px;
  background: linear-gradient(90deg, #e7eef4, #f7fafc, #e7eef4);
  background-size: 220% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.empty-state {
  margin: 28px auto;
  max-width: 280px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.paste-button {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: max(24px, calc(18px + env(safe-area-inset-bottom)));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 188px;
  height: 72px;
  overflow: hidden;
  border-radius: 24px;
  color: var(--accent);
  padding: 0 22px;
  transform: translateX(-50%);
}

.paste-button::before {
  position: absolute;
  inset: 8px auto 8px -42%;
  width: 42%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  content: "";
  pointer-events: none;
  transform: skewX(-16deg);
  animation: paste-sheen 3200ms ease-in-out infinite;
}

.paste-button svg,
.paste-label {
  position: relative;
  z-index: 1;
}

.paste-button svg {
  width: 26px;
  height: 26px;
}

.paste-label {
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0;
  white-space: nowrap;
}

.paste-button.loading {
  animation: pulse 720ms ease-in-out infinite alternate;
}

.modal {
  position: relative;
  width: min(360px, calc(100vw - 32px));
  border: 0;
  border-radius: 18px;
  padding: 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 12px 12px 30px rgba(134, 151, 166, 0.36);
}

dialog:not([open]) {
  display: none;
}

.modal::backdrop {
  background: rgba(58, 74, 92, 0.22);
  backdrop-filter: blur(2px);
}

.modal form,
.action-sheet {
  display: grid;
  gap: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.corner-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 36px;
  border: 0;
  border-radius: 13px;
  background: var(--danger);
  color: #fff;
  padding: 0;
  box-shadow: 4px 4px 12px rgba(134, 85, 91, 0.24), -2px -2px 8px rgba(255, 255, 255, 0.7);
}

.corner-close svg {
  width: 18px;
  height: 18px;
  stroke-width: 3;
}

.modal h1 {
  margin: 0 0 2px;
  padding-right: 52px;
  font-size: 20px;
}

label {
  font-size: 13px;
  font-weight: 750;
  color: var(--muted);
}

input {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--inset);
  padding: 0 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.split-actions {
  justify-content: space-between;
}

.primary-button,
.secondary-button,
.sheet-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  background: var(--surface);
  box-shadow: var(--soft);
  font-weight: 750;
}

.primary-button {
  color: var(--accent);
}

.secondary-button,
.sheet-button {
  color: var(--text);
}

.danger-button {
  background: var(--danger);
  color: #fff;
  box-shadow: 4px 4px 12px rgba(134, 85, 91, 0.24), -2px -2px 8px rgba(255, 255, 255, 0.68);
}

.sheet-move-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
  align-items: center;
}

.sheet-move-row select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--inset);
  color: var(--text);
  padding: 0 34px 0 12px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 12px) 19px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  font-weight: 750;
}

.sheet-move-row select:focus {
  outline: 0;
}

.move-button {
  width: 100%;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(114px, calc(108px + env(safe-area-inset-bottom)));
  max-width: calc(100vw - 40px);
  border-radius: 999px;
  background: rgba(58, 74, 92, 0.92);
  color: #fff;
  padding: 10px 16px;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

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

.token-list {
  display: grid;
  gap: 8px;
}

.token-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.32);
}

.token-row span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-row button {
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--soft);
  color: var(--danger);
  font-weight: 750;
}

@keyframes shake {
  0%,
  100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

@keyframes shimmer {
  to { background-position: -220% 0; }
}

@keyframes pulse {
  to { transform: translateX(-50%) scale(1.04); }
}

@keyframes paste-sheen {
  0%,
  42% { transform: translateX(0) skewX(-16deg); opacity: 0; }
  52% { opacity: 0.8; }
  72% { transform: translateX(360%) skewX(-16deg); opacity: 0; }
  100% { transform: translateX(360%) skewX(-16deg); opacity: 0; }
}

@media (min-width: 760px) {
  .app-screen {
    max-width: 720px;
    margin: 0 auto;
  }
}

@media (hover: hover) and (pointer: fine) {
  .sheet-move-row select:focus-visible {
    box-shadow: var(--inset), 0 0 0 3px rgba(91, 155, 213, 0.28);
  }
}

@media (hover: none) and (pointer: coarse) {
  button:focus,
  button:focus-visible,
  input:focus,
  input:focus-visible,
  select:focus,
  select:focus-visible {
    outline: 0;
  }
}

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