:root {
  color-scheme: dark;
  --bg: #0d131a;
  --panel: #151e27;
  --panel-alt: #1b2733;
  --hover: #21323d;
  --border: #2c3c4b;
  --text: #f3f7fa;
  --muted: #9eb0be;
  --accent: #79edca;
  --accent-bg: #17382e;
  --danger: #ffadad;
  --radius: 0.9rem;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  padding: clamp(1rem, 3vw, 2.2rem) clamp(1rem, 4vw, 2rem) 3rem;
  background: radial-gradient(ellipse at 50% 0%, #15262a 0%, var(--bg) 62%);
}
.shell {
  max-width: 56rem;
  margin: 0 auto;
  display: grid;
  gap: 1.15rem;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.brand-badge {
  display: grid;
  place-items: center;
  min-width: 2.8rem;
  height: 2.8rem;
  padding: 0 0.55rem;
  border-radius: 0.7rem;
  background: var(--accent);
  color: #0e241e;
  font-weight: 800;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.brand h1 {
  font-size: clamp(1.3rem, 2.8vw, 1.7rem);
  letter-spacing: -0.03em;
}
.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.16rem;
}
.auth-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.account-pill {
  font-size: 0.84rem;
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
}
.button, button {
  min-height: 2.6rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 640;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.button:hover, button:hover:not(:disabled) {
  background: var(--hover);
  border-color: #466176;
}
.button.primary, button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f241e;
  font-weight: 740;
}
.button.primary:hover, button.primary:hover:not(:disabled) {
  background: #a4f5dd;
  border-color: #a4f5dd;
}
.button.ghost, button.ghost {
  background: transparent;
}
button.danger {
  color: var(--danger);
  border-color: #66434a;
  background: #332327;
}
button.danger:hover:not(:disabled) {
  background: #4b2f36;
}
button.small {
  min-height: 2.15rem;
  padding: 0.32rem 0.65rem;
  font-size: 0.82rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem;
  display: grid;
  gap: 0.9rem;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.panel-head h2 {
  font-size: 1.04rem;
  letter-spacing: -0.015em;
}
.muted {
  color: var(--muted);
  font-size: 0.86rem;
}

.create-form {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
}
.field {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}
.field label {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}
input {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.5rem 0.7rem;
  border-radius: 0.55rem;
  border: 1px solid #3f5161;
  background: #0f161d;
  color: var(--text);
  font-size: 0.95rem;
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}
.link-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 0.78rem;
  background: var(--panel-alt);
  padding: 0.4rem;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.link-card:hover {
  border-color: #49667a;
}
.link-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.55rem;
  min-width: 0;
}
.link-main:hover {
  background: var(--hover);
}
.link-badge {
  min-width: 3.3rem;
  height: 2.8rem;
  padding: 0 0.75rem;
  border-radius: 0.62rem;
  background: var(--accent-bg);
  border: 1px solid #35695a;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 1.16rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.link-copy {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}
.link-copy strong {
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-meta {
  color: var(--muted);
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-open {
  padding: 0.45rem 0.85rem;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #0e241e;
  font-weight: 740;
  font-size: 0.88rem;
}
.link-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-right: 0.3rem;
}
.edit-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem 0.5rem;
  border-top: 1px solid var(--border);
}
.empty-note {
  color: var(--muted);
  padding: 0.8rem 0.2rem;
}
.not-found {
  justify-items: start;
  padding: 1.6rem;
}
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  padding: 0.72rem 0.95rem;
  border-radius: 0.6rem;
  background: #1c362e;
  border: 1px solid #3f7261;
  color: var(--text);
  font-size: 0.9rem;
  box-shadow: 0 0.8rem 2rem #04080c80;
}
.toast.error {
  background: #3e252b;
  border-color: #7d4854;
}

@media (max-width: 720px) {
  .create-form,
  .edit-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .link-card {
    grid-template-columns: minmax(0, 1fr);
  }
  .link-actions {
    padding: 0 0.5rem 0.35rem;
    justify-content: flex-end;
  }
  .link-open {
    display: none;
  }
}
