:root {
  color-scheme: light;
  --font-sans: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --paper: #f4f0e8;
  --paper-deep: #e9e1d2;
  --card: rgba(255, 253, 248, 0.88);
  --ink: #18222d;
  --muted: #6e716f;
  --line: rgba(24, 34, 45, 0.16);
  --accent: #b84c35;
  --accent-dark: #863422;
  --green: #365f50;
  --shadow: 0 12px 34px rgba(49, 42, 31, 0.075);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(184, 76, 53, 0.09), transparent 28rem),
    radial-gradient(circle at 90% 25%, rgba(54, 95, 80, 0.08), transparent 30rem),
    var(--paper);
  font-family: var(--font-sans);
  line-height: 1.6;
}

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

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

button {
  cursor: pointer;
}

.page-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.33;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}

.shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 48px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark,
.lock-seal {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #fffaf1;
  background: var(--ink);
  border-radius: 50% 50% 46% 54% / 52% 44% 56% 48%;
  font-family: var(--font-sans);
  font-size: 21px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.03em;
}

.brand small {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.text-button {
  padding: 8px 2px;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
}

.text-button:hover {
  color: var(--ink);
  border-color: currentColor;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.current-user {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero {
  padding: 38px 2px 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.2em;
}

.hero h1 {
  max-width: 680px;
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(34px, 5.4vw, 52px);
  font-weight: 750;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.hero p {
  max-width: 520px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 28px;
}

.composer,
.archive {
  padding: 22px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.archive {
  min-width: 0;
  margin-top: 0;
}

.composer {
  position: sticky;
  top: 16px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.section-heading > div {
  display: flex;
  gap: 14px;
  align-items: baseline;
}

.section-number {
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 11px;
  font-style: italic;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.field b,
.field em {
  color: var(--accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.field em {
  color: var(--muted);
}

.field input,
.field textarea,
.field select,
.search-box input,
.filter-select,
.category-form input {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input {
  height: 46px;
  padding: 0 14px;
  font-size: 14px;
}

.field select {
  height: 46px;
  padding: 0 40px 0 14px;
  font-size: 14px;
}

.field textarea {
  min-height: 84px;
  padding: 12px 14px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-box input:focus,
.filter-select:focus,
.category-form input:focus {
  background: #fffdf8;
  border-color: rgba(184, 76, 53, 0.62);
  box-shadow: 0 0 0 4px rgba(184, 76, 53, 0.09);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.character-count,
.record-count {
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.secondary-button,
.action-button {
  border: 0;
  border-radius: 999px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 154px;
  padding: 11px 16px;
  color: #fffaf2;
  background: var(--ink);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.archive-heading {
  align-items: center;
  margin-bottom: 22px;
}

.record-count {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 142px auto;
  gap: 12px;
  margin-bottom: 14px;
}

.search-box {
  position: relative;
}

.search-box span {
  position: absolute;
  top: 50%;
  left: 16px;
  color: var(--muted);
  font-size: 20px;
  transform: translateY(-52%);
}

.search-box input {
  height: 42px;
  padding: 0 16px 0 46px;
}

.filter-select {
  height: 42px;
  padding: 0 34px 0 12px;
  font-size: 12px;
}

.secondary-button {
  padding: 0 20px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.secondary-button:hover {
  background: var(--paper-deep);
}

.category-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 18px;
  padding: 13px 2px 4px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.category-toggle small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.category-toggle[aria-expanded="true"] small {
  color: var(--accent);
}

.category-manager {
  padding-top: 12px;
}

.category-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.category-form input {
  height: 38px;
  padding: 0 12px;
  font-size: 12px;
}

.category-form .secondary-button {
  padding: 0 14px;
  font-size: 12px;
}

.category-list {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.category-item {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.category-drag-handle {
  min-height: 26px;
  font-size: 16px;
}

.category-item.is-dragging {
  z-index: 2;
  opacity: 0.55;
  pointer-events: none;
}

.category-name {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-name small {
  margin-left: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.category-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.mini-button {
  padding: 3px 6px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 10px;
}

.mini-button:hover {
  color: var(--ink);
  background: var(--paper-deep);
}

.mini-button.danger:hover {
  color: var(--accent-dark);
  background: rgba(184, 76, 53, 0.1);
}

.category-empty {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

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

.link-group {
  min-width: 0;
}

.link-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 8px;
  padding: 0 2px 7px;
  border-bottom: 1px solid var(--line);
}

.link-group-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.link-group-heading span {
  color: var(--muted);
  font-size: 10px;
}

.link-group-items {
  display: grid;
  gap: 9px;
}

.link-card {
  display: grid;
  grid-template-columns: 18px auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid var(--line);
  border-radius: 17px;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.drag-handle {
  display: grid;
  place-items: center;
  align-self: stretch;
  min-height: 38px;
  color: var(--muted);
  cursor: grab;
  font-size: 20px;
  line-height: 1;
  touch-action: none;
  user-select: none;
}

.drag-handle:hover,
.drag-handle:focus-visible {
  color: var(--accent);
  outline: none;
}

.drag-handle.disabled {
  cursor: default;
  opacity: 0.25;
}

.link-card.is-dragging {
  z-index: 2;
  opacity: 0.55;
  pointer-events: none;
  transform: scale(0.99);
}

body.is-sorting {
  cursor: grabbing;
  user-select: none;
}

.link-card:hover {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(24, 34, 45, 0.3);
  transform: translateY(-2px);
}

.link-initial {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fffaf2;
  background: var(--green);
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
}

.link-content {
  min-width: 0;
}

.link-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.link-title {
  display: block;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-badge {
  flex: 0 0 auto;
  max-width: 110px;
  padding: 2px 7px;
  overflow: hidden;
  color: var(--green);
  background: rgba(54, 95, 80, 0.09);
  border: 1px solid rgba(54, 95, 80, 0.18);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-url {
  display: block;
  width: 100%;
  padding: 0;
  margin-top: 1px;
  overflow: hidden;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: copy;
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-url:hover {
  color: var(--accent);
}

.link-note {
  margin: 6px 0 0;
  color: #8a8e8b;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.action-button {
  padding: 6px 9px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  font-size: 12px;
}

.action-button:hover {
  color: var(--ink);
  background: var(--paper-deep);
}

.action-button.danger:hover {
  color: var(--accent-dark);
  background: rgba(184, 76, 53, 0.1);
}

.status-card {
  padding: 34px 20px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 17px;
}

.empty-state span,
.empty-state strong,
.empty-state p {
  display: block;
}

.empty-state span {
  margin-bottom: 8px;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 42px;
}

.empty-state strong {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 750;
}

.empty-state p {
  margin: 4px 0 0;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 4px 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(184, 76, 53, 0.14), transparent 30rem),
    var(--paper);
}

.lock-card {
  width: min(440px, 100%);
  padding: clamp(28px, 6vw, 42px);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.lock-seal {
  width: 58px;
  height: 58px;
  margin-bottom: 28px;
  font-size: 28px;
}

.lock-card h1 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 36px;
  font-weight: 750;
  letter-spacing: -0.04em;
}

.lock-card > p:not(.eyebrow):not(.form-error) {
  margin: 10px 0 30px;
  color: var(--muted);
}

.lock-field {
  margin-bottom: 10px;
}

.form-error {
  min-height: 24px;
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 13px;
}

.full-button {
  width: 100%;
}

.auth-switch-button {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 12px;
  text-align: center;
}

.auth-switch-button:hover {
  color: var(--accent);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(380px, calc(100% - 48px));
  padding: 13px 18px;
  color: #fffaf2;
  background: var(--ink);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(24, 34, 45, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 20px, 980px);
  }

  .site-header {
    padding: 17px 2px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .brand strong {
    font-size: 20px;
  }

  .brand small {
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  .header-actions {
    gap: 8px;
  }

  .current-user {
    display: block;
    max-width: clamp(54px, 18vw, 82px);
    font-size: 10px;
  }

  .site-header .text-button {
    padding: 6px 2px;
    font-size: 13px;
  }

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

  .toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-box {
    grid-column: 1 / -1;
  }

  .composer {
    position: static;
  }

.composer,
.archive {
    padding: 18px 15px;
    border-radius: 15px;
  }

  .form-footer,
  .site-footer {
    align-items: center;
  }

  .primary-button {
    width: auto;
  }

  .link-card {
    grid-template-columns: 18px auto minmax(0, 1fr);
  }

  .link-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
