:root {
  --bg: #f7f5ef;
  --ink: #17201c;
  --muted: #64706a;
  --line: #d8d3c7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --field: rgba(255, 255, 255, 0.92);
  --surface-strong: #f2efe7;
  --accent: #146c63;
  --accent-strong: #0d4f49;
  --amber: #b86b18;
  --rose: #a74755;
  --blue: #2d6396;
  --shadow: 0 18px 50px rgba(29, 35, 31, 0.11);
}

:root[data-theme="dark"] {
  --bg: #101714;
  --ink: #eef6f1;
  --muted: #9eb0a7;
  --line: #304039;
  --panel: rgba(23, 32, 28, 0.9);
  --panel-strong: rgba(19, 27, 24, 0.98);
  --field: rgba(15, 22, 19, 0.94);
  --surface-strong: #1d2a25;
  --accent: #2db5a5;
  --accent-strong: #7ee3d7;
  --amber: #e3a039;
  --rose: #ff7488;
  --blue: #61a7e8;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(20, 108, 99, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(184, 107, 24, 0.11), transparent 30%),
    var(--bg);
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(135deg, rgba(45, 181, 165, 0.13), transparent 34%),
    linear-gradient(315deg, rgba(97, 167, 232, 0.1), transparent 30%),
    var(--bg);
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0 30px;
}

.header-actions {
  position: absolute;
  top: 18px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 5vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.intro {
  max-width: 640px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.status-panel {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.account-menu {
  display: none;
  position: relative;
}

.signed-in .account-menu {
  display: block;
}

.account-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.account-button:hover,
.account-button:focus-visible {
  box-shadow: 0 0 0 4px rgba(20, 108, 99, 0.14);
  outline: none;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.98);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.account-email {
  margin: 0 0 6px;
  overflow: hidden;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-overflow: ellipsis;
}

.dropdown-item {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 9px;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: var(--surface-strong);
  outline: none;
}

.dropdown-item.danger {
  color: var(--rose);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2c9f72;
  box-shadow: 0 0 0 5px rgba(44, 159, 114, 0.15);
}

.toolbar-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}

.controls {
  display: grid;
  grid-template-columns: minmax(240px, 390px) 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.search-wrap {
  position: relative;
  display: block;
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.25rem;
  pointer-events: none;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  background: var(--field);
  font: inherit;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 108, 99, 0.14);
}

input[type="search"] {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 42px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tab-button,
.ghost-link,
.ghost-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.tab-button,
.ghost-link,
.ghost-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.62);
  background: var(--panel);
}

.tab-button:hover,
.tab-button.is-active,
.primary-button {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-link,
.ghost-button,
.primary-button {
  border-radius: 8px;
  min-height: 42px;
}

.ghost-link,
.ghost-button {
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.72);
  background: var(--panel);
}

.ghost-button.danger {
  color: var(--rose);
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.link-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 184px;
  padding: 18px;
  border: 1px solid rgba(23, 32, 28, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  background: var(--panel);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.folder-card {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.link-card:hover,
.link-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(20, 108, 99, 0.36);
  box-shadow: 0 24px 58px rgba(29, 35, 31, 0.15);
  outline: none;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.icon-badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 1.25rem;
  font-weight: 800;
}

.icon-badge.small {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.category-pill,
.state-pill {
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.category-pill {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-pill.active {
  color: var(--accent-strong);
  background: rgba(20, 108, 99, 0.12);
}

.link-card h2 {
  margin: 18px 0 7px;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.link-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 800;
}

.arrow {
  font-size: 1.15rem;
}

.empty-state,
.auth-panel,
.editor-panel,
.table-panel,
.settings-panel {
  border: 1px solid rgba(23, 32, 28, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.empty-state {
  margin-top: 20px;
  padding: 26px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.empty-state p,
.auth-panel p,
.loading-state,
.muted-text {
  color: var(--muted);
}

.auth-panel {
  max-width: 460px;
  padding: 24px;
}

.auth-panel h2,
.editor-panel h2,
.table-panel h2,
.settings-panel h2 {
  margin: 0;
  font-size: 1.35rem;
}

.login-options {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.login-option {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: inherit;
  background: rgba(255, 255, 255, 0.72);
  background: var(--panel);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.login-option:hover,
.login-option:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 108, 99, 0.12);
  outline: none;
}

.login-option-title {
  color: var(--accent-strong);
  font-weight: 800;
}

.login-option-copy {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.auth-form,
.editor-panel {
  display: grid;
  gap: 14px;
}

.auth-form label,
.editor-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.auth-form input,
.editor-panel input,
.editor-panel textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
}

.editor-panel textarea {
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 92px 92px;
  gap: 10px;
}

.check-row {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px !important;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.form-message {
  margin: 0;
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(45, 99, 150, 0.12);
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 700;
}

.form-message[data-type="error"] {
  background: rgba(167, 71, 85, 0.12);
  color: var(--rose);
}

.form-message[data-type="success"] {
  background: rgba(20, 108, 99, 0.12);
  color: var(--accent-strong);
}

.loading-state {
  padding: 12px 0;
  font-weight: 700;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 16px;
  align-items: start;
}

.admin-stack {
  display: grid;
  gap: 16px;
}

.admin-page .shell {
  width: min(1220px, calc(100% - 40px));
  padding: 22px 0 28px;
}

.admin-page .topbar {
  align-items: flex-start;
  padding: 8px 0 18px;
}

.admin-page h1 {
  font-size: clamp(2.4rem, 4.2vw, 4.15rem);
}

.admin-page .intro {
  margin-top: 12px;
  line-height: 1.45;
}

.admin-page .auth-panel {
  margin-top: 8px;
}

.admin-page.admin-signed-in #adminAuthPanel {
  display: none !important;
}

.admin-page .admin-layout {
  grid-template-columns: minmax(360px, 430px) 1fr;
  gap: 14px;
}

.admin-page .admin-stack {
  gap: 12px;
}

.admin-page .editor-panel,
.admin-page .table-panel {
  padding: 14px 16px;
}

.admin-page .panel-head {
  margin-bottom: 10px;
}

.admin-page .auth-form,
.admin-page .editor-panel {
  gap: 10px;
}

.admin-page .auth-form label,
.admin-page .editor-panel label {
  gap: 5px;
  font-size: 0.84rem;
}

.admin-page .auth-form input,
.admin-page .editor-panel input,
.admin-page .editor-panel textarea {
  min-height: 38px;
  padding: 8px 10px;
}

.admin-page .editor-panel textarea {
  min-height: 62px;
}

.admin-page .primary-button,
.admin-page .ghost-button,
.admin-page .ghost-link,
.admin-page .tab-button {
  min-height: 38px;
}

.admin-page .form-row {
  grid-template-columns: 1fr 92px 92px;
}

.compact-details {
  display: block;
}

.compact-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.compact-details summary::-webkit-details-marker {
  display: none;
}

.compact-details summary::after {
  content: "Open";
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.72);
  background: var(--panel);
  font-size: 0.9rem;
  font-weight: 800;
}

.compact-details[open] summary {
  margin-bottom: 12px;
}

.compact-details[open] summary::after {
  content: "Close";
}

.summary-title {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 800;
}

.compact-form {
  gap: 10px;
}

.editor-panel,
.table-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head.compact {
  margin-bottom: 0;
}

.link-list {
  display: grid;
  gap: 10px;
}

.admin-link-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
  background: var(--panel);
}

.staff-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.staff-list {
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.staff-row .admin-link-copy h3 {
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staff-row .admin-link-copy p {
  font-size: 0.78rem;
}

.staff-row .ghost-button {
  min-width: 78px;
}

.role-key {
  display: flex;
  gap: 12px;
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.role-key span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.role-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.role-dot.admin {
  background: var(--accent);
}

.role-dot.staff {
  background: var(--blue);
}

.settings-shell {
  max-width: 900px;
}

.settings-panel {
  padding: 22px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.setting-row h3,
.setting-row p {
  margin: 0;
}

.setting-row h3 {
  font-size: 1.02rem;
}

.setting-row p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.5;
}

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 56px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  cursor: pointer;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.switch input:checked + .switch-track {
  border-color: var(--accent);
  background: rgba(45, 181, 165, 0.22);
}

.switch input:checked + .switch-track::after {
  transform: translateX(24px);
  background: var(--accent);
}

.admin-link-copy {
  min-width: 0;
}

.admin-link-copy h3,
.admin-link-copy p {
  margin: 0;
}

.admin-link-copy h3 {
  font-size: 1rem;
}

.admin-link-copy p {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 20px;
  }

  .topbar,
  .controls,
  .toolbar-line,
  .admin-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    padding-top: 62px;
  }

  .header-actions {
    top: 12px;
    right: auto;
    left: 0;
  }

  .status-panel,
  .category-tabs,
  .header-actions {
    justify-self: start;
  }

  .category-tabs,
  .top-actions {
    justify-content: flex-start;
  }

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