:root {
  color-scheme: dark;
  --bg: #07101f;
  --panel: #0d192b;
  --panel-raised: #12233a;
  --line: #263a55;
  --line-strong: #3a587d;
  --text: #f4f7fb;
  --muted: #94a7bf;
  --accent: #6ee7f2;
  --accent-strong: #22c7d6;
  --accent-ink: #03262b;
  --danger: #ff8b8b;
  --success: #65d6a6;
  --shadow: 0 24px 70px rgb(0 0 0 / 28%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgb(110 231 242 / 3%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(110 231 242 / 3%) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  font-size: 1rem;
  line-height: 1.5;
}

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

.page-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font: 700 0.82rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px 2px 8px 2px;
  font-size: 1rem;
  box-shadow: 5px 5px 0 rgb(110 231 242 / 13%);
}

.topbar-actions, .dialog-actions > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions form { margin: 0; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, .bookmark-link:focus-visible, .edit-button:focus-visible, .icon-button:focus-visible {
  outline: 3px solid rgb(110 231 242 / 35%);
  outline-offset: 3px;
}

.button-primary { background: var(--accent); color: var(--accent-ink); }
.button-primary:hover { background: #94f1f8; }
.button-quiet { border-color: var(--line); background: transparent; color: var(--text); }
.button-quiet:hover { border-color: var(--line-strong); background: var(--panel); }
.button-danger { border-color: rgb(255 139 139 / 35%); background: transparent; color: var(--danger); }
.button-full { width: 100%; }

main { flex: 1; }

.intro {
  min-height: 250px;
  padding: 66px 0 44px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font: 700 0.76rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

.intro h1 {
  margin-bottom: 0;
  font-size: clamp(3rem, 8vw, 6.7rem);
  line-height: 0.9;
  letter-spacing: -0.07em;
}

.intro-note {
  max-width: 270px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 1.05rem;
}

.messages { display: grid; gap: 8px; margin-bottom: 26px; }
.message { padding: 13px 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.message-success { border-color: rgb(101 214 166 / 45%); color: var(--success); }
.message-error { border-color: rgb(255 139 139 / 45%); color: var(--danger); }

.category-list { display: grid; gap: 48px; padding-bottom: 70px; }

.category-heading {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-bottom: 16px;
}

.category-heading h2 { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; }
.category-heading span { color: var(--muted); font: 600 0.75rem/1 ui-monospace, monospace; }

.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.bookmark-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(13 25 43 / 82%);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.bookmark-card:hover { transform: translateY(-3px); border-color: var(--line-strong); background: var(--panel-raised); }

.bookmark-link {
  min-height: 138px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: start;
  gap: 15px;
  padding: 22px;
  color: inherit;
  text-decoration: none;
}

.bookmark-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px 3px 10px 3px;
  background: #0a1525;
  font-size: 1.3rem;
}

.bookmark-copy { min-width: 0; display: flex; flex-direction: column; }
.bookmark-copy strong { margin: 1px 0 4px; font-size: 1.05rem; overflow-wrap: anywhere; }
.bookmark-description { margin-bottom: 11px; color: var(--muted); font-size: 0.9rem; }
.bookmark-host { color: var(--accent); font: 500 0.76rem/1.3 ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-arrow { color: var(--muted); font-size: 1.05rem; }

.edit-button {
  position: absolute;
  right: 14px;
  bottom: 12px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
}

.edit-button:hover { color: var(--text); border-color: var(--line-strong); }

.empty-state {
  min-height: 330px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 40px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  text-align: center;
}

.empty-state h2 { margin: 12px 0 4px; }
.empty-state p { color: var(--muted); }
.empty-symbol { color: var(--accent); font-size: 2.3rem; }

footer {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 600 0.72rem/1 ui-monospace, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-rule { width: 30px; height: 1px; background: var(--line-strong); }

.editor-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor-dialog::backdrop { background: rgb(2 7 15 / 78%); backdrop-filter: blur(5px); }
.editor-form { padding: 26px; }

.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.dialog-heading h2 { margin-bottom: 0; font-size: 1.8rem; }
.dialog-heading .eyebrow { margin-bottom: 7px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.5rem; }

.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 90px 110px; gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span { color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.field small { font-weight: 400; }
.field input {
  width: 100%;
  min-height: 45px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #081322;
}
.field input::placeholder { color: #647891; }
.field input:focus { border-color: var(--accent-strong); }
.field-icon input { text-align: center; }

.dialog-actions { margin-top: 26px; display: flex; justify-content: flex-end; gap: 10px; }
.dialog-actions-split { justify-content: space-between; }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(440px, 100%); }
.login-shell > .brand { margin-bottom: 30px; }
.login-panel { padding: 32px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.login-panel h1 { margin-bottom: 7px; font-size: 2.2rem; letter-spacing: -0.04em; }
.login-panel > p:not(.eyebrow) { color: var(--muted); }
.login-form { display: grid; gap: 17px; margin: 26px 0 20px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

@media (max-width: 850px) {
  .bookmark-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .intro { min-height: 220px; }
}

@media (max-width: 580px) {
  .page-shell { width: min(100% - 24px, 1180px); }
  .topbar { min-height: 70px; }
  .brand > span:last-child { display: none; }
  .button { min-height: 40px; padding: 0 13px; }
  .topbar-actions { gap: 6px; }
  .intro { min-height: 205px; padding: 50px 0 34px; display: block; }
  .intro h1 { font-size: clamp(3.2rem, 19vw, 5rem); }
  .intro-note { margin-top: 22px; }
  .bookmark-grid { grid-template-columns: 1fr; }
  .bookmark-link { min-height: 122px; padding: 18px; }
  .category-list { gap: 36px; }
  .editor-form { padding: 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr) 86px; }
  .field:nth-of-type(5) { grid-column: 1 / -1; }
  .dialog-actions-split { align-items: stretch; gap: 14px; flex-direction: column-reverse; }
  .dialog-actions-split > div { justify-content: flex-end; }
  .login-panel { padding: 25px 20px; }
}

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