:root {
  color-scheme: light;
  --ink: #17191c;
  --muted: #667085;
  --soft: #8a94a6;
  --line: #d8dee8;
  --line-strong: #c7cfdd;
  --paper: #f6f3ed;
  --panel: #ffffff;
  --panel-soft: #fbfcfd;
  --accent: #276c70;
  --accent-strong: #1f5558;
  --rose: #aa4f68;
  --gold: #9f741d;
  --blue: #3f628a;
  --shadow: 0 16px 36px rgba(31, 39, 51, 0.11);
  --shadow-soft: 0 8px 22px rgba(31, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(39, 108, 112, 0.13) 0, rgba(39, 108, 112, 0) 260px),
    linear-gradient(90deg, rgba(170, 79, 104, 0.10), rgba(159, 116, 29, 0.08)),
    var(--paper);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(23, 25, 28, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 25, 28, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, #000, transparent 72%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 92px;
  margin-bottom: 18px;
  padding: 18px 0 10px;
  border-bottom: 1px solid rgba(31, 39, 51, 0.12);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 4vw, 4rem);
  line-height: 0.95;
}

.hidden {
  display: none !important;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.icon-button:hover {
  border-color: var(--accent);
  background: #fff;
}

.auth-panel,
.workspace {
  min-height: 620px;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding-top: 34px;
}

.login-form,
.link-form {
  display: grid;
  gap: 14px;
  width: min(430px, 100%);
  border: 1px solid rgba(216, 222, 232, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-form {
  padding: 26px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.88rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #9aa3b2;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(39, 108, 112, 0.15);
}

select {
  min-height: 45px;
  appearance: auto;
}

button[type="submit"],
.secondary {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 850;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, color 150ms ease;
}

button[type="submit"] {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(39, 108, 112, 0.22);
}

button[type="submit"]:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.secondary {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.text-button {
  min-height: 36px;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 850;
}

.text-button:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.error {
  min-height: 20px;
  margin: 0;
  color: #b42318;
  font-size: 0.88rem;
}

.workspace {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(216, 222, 232, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.category {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 11px;
  color: #303846;
  background: transparent;
  text-align: left;
}

.category strong {
  display: inline-grid;
  min-width: 28px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  background: #eef1f5;
  font-size: 0.78rem;
}

.category:hover {
  border-color: var(--line);
  background: #fff;
}

.category.active {
  border-color: rgba(39, 108, 112, 0.28);
  color: var(--accent-strong);
  background: #edf7f6;
}

.category.active strong {
  color: #fff;
  background: var(--accent);
}

#categoryList {
  display: grid;
  gap: 4px;
}

.content {
  display: grid;
  gap: 14px;
}

.link-form {
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 18px;
}

.link-form .wide,
.form-actions,
.error {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 2px;
}

.folder-create {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
}

.folder-create .secondary {
  min-height: 45px;
}

.random-panel {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(216, 222, 232, 0.92);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.random-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.mini-label {
  margin: 0 0 4px;
  color: var(--rose);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.random-head h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

#randomButton {
  min-width: 92px;
  min-height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--rose);
  font-weight: 850;
  box-shadow: 0 10px 22px rgba(170, 79, 104, 0.20);
}

#randomButton:hover {
  background: #93455b;
}

.random-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.random-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: rgba(246, 243, 237, 0.56);
}

.random-result div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.random-result strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.random-result span {
  color: var(--muted);
  font-size: 0.84rem;
}

.random-result a {
  display: inline-grid;
  flex-shrink: 0;
  min-width: 64px;
  min-height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
  text-decoration: none;
}

.tools {
  display: flex;
  justify-content: flex-end;
}

.search {
  width: min(380px, 100%);
}

.links-list {
  display: grid;
  gap: 12px;
}

.link-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(216, 222, 232, 0.92);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.link-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.link-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.link-title {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.link-title a {
  color: var(--ink);
  text-decoration: none;
}

.link-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.url-line {
  display: block;
  margin-top: 6px;
  color: var(--soft);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.url-line:hover {
  color: var(--accent);
  text-decoration: underline;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.84rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 10px;
  background: #f2f4f7;
  color: #394253;
  font-weight: 750;
}

.pill.source {
  color: #fff;
  background: var(--rose);
}

.pill.folder {
  border-color: rgba(39, 108, 112, 0.18);
  background: #edf7f6;
  color: var(--accent-strong);
}

.pill.tag {
  border-color: rgba(159, 116, 29, 0.20);
  background: #fff4dc;
  color: #785815;
}

.link-card p {
  margin: 0;
  color: #475467;
  line-height: 1.55;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.card-actions button,
.open-link {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  transition: transform 150ms ease, border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.card-actions button:hover,
.open-link:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-1px);
}

.open-link {
  border-color: rgba(39, 108, 112, 0.45);
  color: var(--accent);
  background: #f2f8f7;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 42px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.64);
  text-align: center;
}

@media (max-width: 820px) {
  body {
    background:
      linear-gradient(180deg, rgba(39, 108, 112, 0.14) 0, rgba(39, 108, 112, 0) 230px),
      var(--paper);
  }

  .topbar {
    align-items: center;
    min-height: 74px;
  }

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

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #categoryList {
    display: contents;
  }

  .link-form {
    grid-template-columns: 1fr;
  }

  .folder-create {
    grid-template-columns: 1fr;
  }

  .random-filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .shell {
    width: 100%;
    padding: 16px 14px 34px;
  }

  .topbar {
    margin-bottom: 12px;
    padding-right: 2px;
    padding-left: 2px;
  }

  h1 {
    font-size: 2.2rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .login-form,
  .link-form {
    padding: 16px;
  }

  .auth-panel {
    padding: 24px 2px 0;
  }

  input,
  select,
  textarea,
  button[type="submit"],
  .secondary {
    min-height: 48px;
  }

  .link-card header,
  .form-actions,
  .random-head,
  .random-result {
    flex-direction: column;
    align-items: stretch;
  }

  .card-actions {
    justify-content: flex-start;
  }

  .card-actions button,
  .open-link {
    min-width: 44px;
    height: 44px;
  }

  .random-panel,
  .link-card {
    padding: 15px;
  }

  #randomButton,
  .random-result a {
    width: 100%;
  }

  .search {
    width: 100%;
  }

  .form-actions button {
    width: 100%;
  }
}
