:root {
  --ink: #101828;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #e4e7ec;
  --surface: #ffffff;
  --canvas: #f2f4f7;
  --accent: #12b76a;
  --accent-dark: #027a48;
  --accent-soft: #ecfdf3;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --focus: #84caff;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow-lg: 0 20px 48px rgb(16 24 40 / 14%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgb(18 183 106 / 11%), transparent 28rem),
    var(--canvas);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.offline-banner {
  position: sticky;
  z-index: 50;
  top: 0;
  padding: 0.55rem 1rem;
  color: #ffffff;
  background: #344054;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.app-header {
  position: relative;
  z-index: 10;
  display: flex;
  min-height: 4.75rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(0.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid rgb(228 231 236 / 75%);
  background: rgb(255 255 255 / 84%);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand > span:last-child {
  display: grid;
  gap: 0.08rem;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand small {
  color: var(--muted);
  font-size: 0.7rem;
}

.brand-mark {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  border-radius: 0.65rem;
  background:
    linear-gradient(90deg, var(--ink) 22%, transparent 22% 39%, var(--ink) 39% 61%, transparent 61% 78%, var(--ink) 78%),
    linear-gradient(var(--ink) 22%, transparent 22% 39%, var(--ink) 39% 61%, transparent 61% 78%, var(--ink) 78%);
  box-shadow: inset 0 0 0 0.42rem #ffffff, 0 0 0 1px var(--line);
}

.brand-mark span {
  position: absolute;
  inset: 0.88rem;
  border-radius: 0.12rem;
  background: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-shell {
  width: min(100%, 64rem);
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) calc(7rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.button {
  min-height: 2.75rem;
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 750;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button-primary {
  color: #ffffff;
  background: var(--ink);
  box-shadow: var(--shadow-sm);
}

.button-primary:hover {
  background: #1d2939;
}

.button-secondary,
.button-quiet {
  border-color: var(--line);
  color: #344054;
  background: #ffffff;
}

.button-secondary:hover,
.button-quiet:hover {
  background: #f9fafb;
}

.button-quiet {
  min-height: 2.35rem;
  padding: 0.48rem 0.75rem;
  font-size: 0.8rem;
}

.button-danger {
  color: #ffffff;
  background: var(--danger);
}

.button-large {
  width: 100%;
  min-height: 3rem;
}

.eyebrow {
  margin: 0 0 0.28rem;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-view {
  display: grid;
  min-height: calc(100dvh - 9rem);
  place-items: center;
}

.login-card {
  width: min(100%, 26rem);
  padding: clamp(1.5rem, 7vw, 2.4rem);
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  max-width: 11ch;
  margin: 0;
  font-size: clamp(2rem, 8vw, 2.65rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.login-copy {
  margin: 1rem 0 1.5rem;
  color: var(--muted);
  line-height: 1.55;
}

.pin-form {
  display: grid;
  gap: 0.7rem;
}

.pin-form label,
.field > span {
  color: #344054;
  font-size: 0.82rem;
  font-weight: 750;
}

.pin-form input,
.field input {
  width: 100%;
  min-height: 3rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid #d0d5dd;
  border-radius: 0.75rem;
  color: var(--ink);
  background: #ffffff;
}

.pin-form input {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.45em;
}

.pin-form input:focus,
.field input:focus {
  border-color: #53b1fd;
  box-shadow: 0 0 0 4px rgb(132 202 255 / 24%);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 650;
}

.app-view {
  display: grid;
  gap: 1rem;
}

.qr-card,
.tools-card,
.list-section {
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.qr-card {
  overflow: hidden;
  padding: clamp(1.15rem, 4vw, 1.6rem);
}

.qr-heading,
.section-heading,
.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.qr-heading h1,
.section-heading h2,
.modal-heading h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.qr-heading h1 {
  font-size: clamp(1.45rem, 6vw, 2.1rem);
}

.live-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.38rem;
  padding: 0.4rem 0.58rem;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.live-pill span {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0.22rem rgb(18 183 106 / 15%);
}

.qr-visual {
  display: grid;
  justify-items: center;
}

.qr-stage {
  display: grid;
  width: min(100%, 19rem);
  aspect-ratio: 1;
  margin: 1.35rem auto 1.2rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: #ffffff;
  box-shadow: 0 12px 28px rgb(16 24 40 / 8%);
}

#qrCanvas {
  display: block;
  width: min(86%, 264px) !important;
  height: auto !important;
  aspect-ratio: 1;
}

.qr-download-button {
  display: inline-flex;
  min-height: 2.35rem;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  margin: -0.45rem auto 1.15rem;
  padding: 0.5rem 0.78rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  color: #475467;
  background: #ffffff;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 750;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.qr-download-button:hover {
  border-color: #b7e5cd;
  color: var(--accent-dark);
  background: #f9fefb;
}

.qr-download-button:active {
  transform: translateY(1px);
}

.qr-download-button span {
  font-size: 1rem;
  line-height: 1;
}

.qr-details {
  width: 100%;
}

.active-summary {
  display: flex;
  max-width: 30rem;
  align-items: center;
  gap: 0.72rem;
  margin: 0 auto;
  padding: 0.78rem 0.9rem;
  border: 1px solid #abefc6;
  border-radius: 0.9rem;
  background: var(--accent-soft);
}

.active-summary.is-empty {
  border-color: var(--line);
  background: #f9fafb;
}

.active-dot {
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.active-summary.is-empty .active-dot {
  background: var(--subtle);
}

.active-summary div {
  display: grid;
  min-width: 0;
  gap: 0.12rem;
}

.active-summary small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.active-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.permanent-url {
  overflow: hidden;
  margin: 0.72rem auto 0;
  color: var(--subtle);
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.67rem;
}

.tools-card,
.list-section {
  padding: clamp(1.1rem, 4vw, 1.45rem);
}

.section-heading {
  margin-bottom: 1rem;
  align-items: flex-end;
}

.compact-heading {
  margin-bottom: 0.8rem;
}

.section-heading h2 {
  font-size: 1.25rem;
}

.section-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.count-badge {
  display: inline-grid;
  min-width: 1.75rem;
  height: 1.75rem;
  margin-left: 0.25rem;
  place-items: center;
  vertical-align: 0.1rem;
  border-radius: 999px;
  color: #475467;
  background: #f2f4f7;
  font-size: 0.75rem;
}

.tool-grid {
  display: grid;
  gap: 0.65rem;
}

.tool-button {
  display: grid;
  grid-template-columns: auto 1fr auto;
  min-height: 4rem;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.95rem;
  color: inherit;
  background: #ffffff;
  text-align: left;
  cursor: pointer;
}

.tool-button:hover {
  border-color: #b7e5cd;
  background: #f9fefb;
}

.tool-icon {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border-radius: 0.72rem;
  color: #ffffff;
  background: var(--ink);
  font-weight: 850;
}

.tool-button > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 0.14rem;
}

.tool-button small {
  color: var(--muted);
  font-size: 0.72rem;
}

.copy-label {
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.destination-list {
  display: grid;
  gap: 0.72rem;
}

.destination-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #ffffff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.destination-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 5px 16px rgb(16 24 40 / 6%);
}

.destination-card.is-active {
  border-color: #6ce9a6;
  box-shadow: 0 0 0 3px rgb(18 183 106 / 8%);
}

.destination-select {
  display: grid;
  width: 100%;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.92rem;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.destination-select:hover {
  background: #fcfcfd;
}

.destination-state {
  width: 0.72rem;
  height: 0.72rem;
  border: 2px solid #d0d5dd;
  border-radius: 50%;
  background: #ffffff;
}

.is-active .destination-state {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 0.25rem rgb(18 183 106 / 13%);
}

.destination-copy {
  display: grid;
  min-width: 0;
  gap: 0.28rem;
}

.destination-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.5rem;
}

.destination-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.destination-url {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-chip {
  display: none;
  flex: 0 0 auto;
  padding: 0.22rem 0.42rem;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.62rem;
  font-weight: 800;
}

.is-active .active-chip {
  display: inline-flex;
}

.select-arrow {
  color: var(--subtle);
  font-size: 1.1rem;
}

.destination-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.18rem;
  padding: 0.42rem 0.58rem;
  border-top: 1px solid #f2f4f7;
  background: #fcfcfd;
}

.row-action {
  min-height: 2.2rem;
  padding: 0.45rem 0.58rem;
  border: 0;
  border-radius: 0.55rem;
  color: #475467;
  background: transparent;
  cursor: pointer;
  font-size: 0.71rem;
  font-weight: 750;
}

.row-action:hover {
  background: #f2f4f7;
}

.copy-activation {
  margin-right: auto;
  color: var(--accent-dark);
}

.row-action-danger {
  color: #b42318;
}

.row-action-danger:hover {
  background: var(--danger-soft);
}

.empty-state {
  display: grid;
  min-height: 15rem;
  place-items: center;
  align-content: center;
  padding: 2rem;
  border: 1px dashed #d0d5dd;
  border-radius: 1rem;
  text-align: center;
}

.empty-symbol {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.8rem;
  place-items: center;
  border-radius: 1rem;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 1.7rem;
  font-weight: 300;
}

.empty-state h3 {
  margin: 0;
  font-size: 1rem;
}

.empty-state p {
  max-width: 20rem;
  margin: 0.42rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.add-button {
  position: fixed;
  z-index: 20;
  right: max(1.25rem, calc(env(safe-area-inset-right) + 0.8rem));
  bottom: max(1.25rem, calc(env(safe-area-inset-bottom) + 0.8rem));
  display: grid;
  width: 3.8rem;
  height: 3.8rem;
  place-items: center;
  border: 0;
  border-radius: 1.15rem;
  color: #ffffff;
  background: var(--ink);
  box-shadow: 0 15px 28px rgb(16 24 40 / 28%);
  cursor: pointer;
  font-size: 2rem;
  font-weight: 300;
  transition: transform 160ms ease, background-color 160ms ease;
}

.add-button:hover {
  background: #1d2939;
  transform: translateY(-2px);
}

.add-button:active {
  transform: translateY(0);
}

.modal {
  width: min(calc(100% - 1.5rem), 32rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 1.35rem;
  color: var(--ink);
  background: transparent;
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgb(16 24 40 / 55%);
  backdrop-filter: blur(4px);
}

.modal-card {
  display: grid;
  gap: 1.15rem;
  padding: clamp(1.15rem, 5vw, 1.6rem);
  background: #ffffff;
}

.modal-heading h2 {
  font-size: 1.35rem;
}

.modal-close {
  display: grid;
  width: 2.45rem;
  height: 2.45rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  color: #475467;
  background: #ffffff;
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
}

.field {
  display: grid;
  gap: 0.42rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.15rem;
}

.delete-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: max(1.25rem, calc(env(safe-area-inset-bottom) + 0.8rem));
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: 0.78rem 1rem;
  border-radius: 0.8rem;
  color: #ffffff;
  background: var(--ink);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
}

noscript {
  display: block;
  padding: 1rem;
  color: #ffffff;
  background: var(--danger);
  text-align: center;
}

@media (min-width: 46rem) {
  .page-shell {
    padding-top: 2rem;
  }

  .app-view {
    grid-template-columns: minmax(0, 1.05fr) minmax(18rem, 0.95fr);
    align-items: start;
  }

  .qr-card {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(15rem, 0.9fr) minmax(18rem, 1.1fr);
    column-gap: 2.5rem;
    align-items: center;
  }

  .qr-heading {
    grid-column: 1 / -1;
  }

  .qr-visual {
    width: 100%;
    margin: 1.5rem 0 0;
  }

  .qr-stage {
    width: 100%;
    margin: 0 0 0.75rem;
  }

  .qr-download-button {
    margin: 0 auto;
  }

  .qr-details {
    align-self: center;
  }

  .active-summary {
    width: 100%;
    margin: 0;
  }

  .permanent-url {
    width: 100%;
    margin: 0.8rem 0 0;
    text-align: left;
  }

  .tools-card {
    position: sticky;
    top: 1rem;
  }

  .list-section {
    min-height: 22rem;
  }

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

@media (max-width: 31rem) {
  .brand small,
  .section-hint {
    display: none;
  }

  .destination-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
  }

  .row-action {
    padding-inline: 0.45rem;
  }

  .modal-actions .button {
    flex: 1;
  }
}

@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;
  }
}
