:root {
  color-scheme: dark;
  --bg: #020503;
  --panel: rgba(4, 13, 8, .86);
  --panel-strong: rgba(6, 18, 10, .96);
  --line: rgba(27, 255, 95, .24);
  --line-strong: rgba(27, 255, 95, .58);
  --text: #eaffef;
  --muted: #7aa786;
  --green: #1bff5f;
  --green-soft: rgba(27, 255, 95, .12);
  --danger: #ff4d6d;
  --shadow: 0 0 32px rgba(27, 255, 95, .08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: Inter, Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, rgba(27, 255, 95, .05), transparent 34%),
    repeating-linear-gradient(90deg, rgba(27, 255, 95, .035) 0 1px, transparent 1px 70px),
    #020503;
  color: var(--text);
}

body:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, transparent 0%, rgba(27, 255, 95, .05) 50%, transparent 100%),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 4px);
  opacity: .45;
}

button,
input {
  font: inherit;
}

.matrix-loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  overflow: hidden;
  background: #020503;
  color: var(--green);
  transition: opacity .28s ease, visibility .28s ease;
}

.loader-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.matrix-loader:before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent, rgba(27, 255, 95, .11), transparent),
    repeating-linear-gradient(180deg, rgba(27, 255, 95, .08) 0 1px, transparent 1px 7px);
  animation: matrixScan 1.5s linear infinite;
}

.matrix-loader:after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 46%, rgba(27, 255, 95, .16), transparent 22%),
    radial-gradient(circle at 50% 50%, transparent 0 18%, rgba(27, 255, 95, .08) 19%, transparent 31%);
  animation: loaderPulse 2s ease-in-out infinite;
}

.matrix-rain {
  position: absolute;
  inset: -20% 8%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 24px;
  opacity: .32;
  color: var(--green);
  font-family: Consolas, monospace;
  font-size: 14px;
}

.matrix-rain span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  animation: matrixFall 2s linear infinite;
}

.matrix-rain span:nth-child(2n) {
  animation-delay: -.35s;
}

.matrix-rain span:nth-child(3n) {
  animation-delay: -.7s;
}

.loader-mark {
  position: relative;
  z-index: 1;
  width: 92px;
  height: 92px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 0 32px rgba(27, 255, 95, .28), 0 0 0 1px rgba(27, 255, 95, .3);
  animation: markPulse 2s ease-in-out infinite;
}

.matrix-loader strong {
  position: relative;
  z-index: 1;
  font-size: 18px;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(27, 255, 95, .56);
}

.loader-line {
  position: relative;
  z-index: 1;
  width: 170px;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(27, 255, 95, .14);
}

.loader-line span {
  display: block;
  width: 45%;
  height: 100%;
  background: var(--green);
  box-shadow: 0 0 18px rgba(27, 255, 95, .8);
  animation: loaderLine 2s ease-in-out infinite;
}

@keyframes matrixScan {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

@keyframes matrixFall {
  from { transform: translateY(-35%); }
  to { transform: translateY(35%); }
}

@keyframes loaderPulse {
  0%, 100% { opacity: .6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes markPulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.04); filter: brightness(1.18); }
}

@keyframes loaderLine {
  0% { transform: translateX(-110%); }
  55% { transform: translateX(80%); }
  100% { transform: translateX(240%); }
}

.app {
  position: relative;
  width: min(100%, 940px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px 28px;
}

.lock-view {
  min-height: calc(100vh - 56px);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.brand-mark {
  width: 118px;
  height: 118px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #000;
  object-fit: cover;
  box-shadow: 0 0 22px rgba(27, 255, 95, .3);
}

.lock-view h1,
.topbar h1 {
  margin: 16px 0 8px;
  color: var(--green);
  font-size: clamp(34px, 9vw, 68px);
  line-height: .92;
  font-weight: 900;
  text-shadow: 0 0 16px rgba(27, 255, 95, .32);
}

.lock-view p {
  width: min(100%, 380px);
  margin: 0 0 20px;
  color: var(--muted);
}

.unlock-form,
.search-row {
  width: min(100%, 420px);
}

.unlock-form {
  display: grid;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, .58);
  color: var(--text);
  outline: 0;
  padding: 0 14px;
}

input::placeholder {
  color: rgba(122, 167, 134, .72);
}

input:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px var(--green-soft), 0 0 20px rgba(27, 255, 95, .12);
}

button {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--green);
  color: #021006;
  font-weight: 850;
  cursor: pointer;
}

button:hover {
  box-shadow: 0 0 24px rgba(27, 255, 95, .22);
}

.message {
  min-height: 18px;
  color: var(--danger);
}

.panel-view {
  padding-top: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(32px, 8vw, 64px);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  min-width: 50px;
  min-height: 44px;
  padding: 0 12px;
  background: rgba(0, 0, 0, .54);
  border: 1px solid var(--line);
  color: var(--green);
}

.add-btn {
  width: 50px;
  padding: 0;
  background: var(--green);
  color: #021006;
  font-size: 28px;
  line-height: 1;
}

.edit-btn {
  width: 50px;
  padding: 0;
  font-size: 20px;
}

.edit-btn.is-active {
  background: var(--green);
  color: #021006;
}

.close-session-btn {
  width: 50px;
  padding: 0;
  font-size: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 60;
  width: min(calc(100vw - 28px), 360px);
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(3, 14, 7, .96);
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 0 28px rgba(27, 255, 95, .18);
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: opacity .22s ease, transform .22s ease;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .7);
}

.modal-dialog {
  position: relative;
  width: min(100%, 430px);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 0;
}

.modal-header h2 {
  margin: 0;
  color: var(--green);
  font-size: 20px;
}

.modal-close {
  width: 40px;
  min-height: 40px;
  padding: 0;
  background: rgba(0, 0, 0, .42);
  border: 1px solid var(--line);
  color: var(--green);
  font-size: 18px;
}

.add-form {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 14px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.delete-btn {
  min-width: 96px;
  background: rgba(255, 77, 109, .12);
  border-color: rgba(255, 77, 109, .46);
  color: #ff8ea3;
}

.search-row {
  width: 100%;
  margin-bottom: 16px;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.link-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 92px;
  align-items: center;
  min-height: 92px;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(27, 255, 95, .08);
  cursor: pointer;
}

.link-card:hover {
  border-color: var(--line-strong);
  background: rgba(5, 22, 10, .96);
  box-shadow: 0 0 22px rgba(27, 255, 95, .12);
}

.editing-list .link-card {
  cursor: pointer;
}

.selectable-card {
  border-color: var(--line-strong);
}

.selectable-card:hover {
  box-shadow: 0 0 28px rgba(27, 255, 95, .2);
}

.link-icon {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
  object-fit: contain;
  padding: 6px;
}

.link-content {
  min-width: 0;
  display: grid;
  gap: 3px;
  color: var(--text);
  text-align: left;
  text-decoration: none;
}

.link-content strong,
.link-content small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-content strong {
  color: var(--text);
}

.link-content small {
  color: var(--muted);
}

.added-at {
  color: rgba(122, 167, 134, .72) !important;
  font-size: 11px;
}

.card-actions {
  display: grid;
  gap: 8px;
}

.card-action {
  min-height: 36px;
  padding: 0 10px;
  border-color: var(--line);
  background: rgba(0, 0, 0, .48);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.panel-action {
  background: rgba(27, 255, 95, .16);
  border-color: rgba(27, 255, 95, .72);
  color: var(--green);
}

.copy-action {
  background: rgba(0, 176, 255, .16);
  border-color: rgba(0, 176, 255, .62);
  color: #60d8ff;
}

.empty-state {
  padding: 28px 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 560px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .icon-btn {
    width: 44px;
  }

  #lockAgain {
    font-size: 19px;
  }
}
