:root {
  --page: #090909;
  --surface: #15151f;
  --surface-raised: #1a1a2e;
  --surface-pressed: #20202e;
  --text: #f4f4f5;
  --muted: #92929f;
  --line: #2c2c38;
  --accent: #d0021b;
  --accent-bright: #ff3b4f;
  --accent-soft: rgba(208, 2, 27, 0.14);
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family:
    "Segoe UI",
    "Microsoft YaHei UI",
    "PingFang SC",
    sans-serif;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
[contenteditable="true"]:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(9, 9, 9, 0.94);
  backdrop-filter: blur(18px);
}

.topbar::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--accent);
  content: "";
}

.topbar-inner {
  width: min(100% - 28px, 720px);
  min-height: 68px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-accent {
  width: 4px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-action,
.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text);
}

.topbar-action {
  width: 40px;
  height: 40px;
  border-color: var(--accent);
  border-radius: 7px;
  background: var(--accent);
  font-size: 25px;
  font-weight: 300;
  line-height: 1;
}

.topbar-action:hover {
  background: #e30c25;
}

.page {
  width: min(100% - 28px, 720px);
  margin-inline: auto;
  padding: 22px 0 calc(38px + env(safe-area-inset-bottom));
}

.workspace {
  min-width: 0;
}

.sidebar {
  min-width: 0;
}

.sidebar-brand,
.sidebar-action,
.sidebar-label {
  display: none;
}

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

.list-toolbar {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.list-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-title-wrap h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.category-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.category-pill {
  height: 32px;
  padding: 0 13px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-pill.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #ff7a88;
}

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

.need-card {
  position: relative;
  min-height: 116px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 58px;
  gap: 12px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    transform 140ms ease;
}

.need-card:hover {
  border-color: #42424f;
  background: #181823;
  transform: translateY(-1px);
}

.need-card.is-top {
  border-color: rgba(208, 2, 27, 0.48);
}

.need-card.is-selected {
  border-color: var(--accent);
  background: #1b1117;
  box-shadow: inset 3px 0 0 var(--accent);
}

.need-card.is-top::before {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  width: 3px;
  border-radius: 8px 0 0 8px;
  background: var(--accent);
  content: "";
}

.rank {
  padding-top: 2px;
  color: #5d5d69;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
}

.need-card.is-top .rank {
  color: var(--accent-bright);
}

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

.category-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 8px;
  border: 1px solid rgba(208, 2, 27, 0.34);
  border-radius: 5px;
  background: var(--accent-soft);
  color: #ff7483;
  font-size: 11px;
  font-weight: 800;
}

.need-title {
  margin: 8px 0 0;
  font-size: 16px;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.need-description {
  display: -webkit-box;
  margin: 7px 0 0;
  overflow: hidden;
  color: #b0b0ba;
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.need-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.like-button {
  width: 58px;
  min-height: 76px;
  display: grid;
  place-content: center;
  gap: 2px;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101018;
  color: var(--muted);
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.like-button:hover {
  border-color: #565662;
  color: var(--text);
}

.like-button.is-liked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.like-button:active {
  transform: scale(0.96);
}

.like-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.heart {
  font-size: 23px;
  line-height: 1;
}

.like-count {
  font-size: 13px;
  font-weight: 800;
}

.empty-state {
  padding: 54px 20px;
  border: 1px dashed #373743;
  border-radius: 8px;
  background: rgba(21, 21, 31, 0.72);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 16px;
}

.composer-dialog,
.detail-dialog {
  width: min(100%, 620px);
  max-width: 620px;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.composer-dialog::backdrop,
.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(4px);
}

.composer-panel,
.detail-panel {
  display: grid;
  gap: 16px;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer-panel {
  max-height: calc(100dvh - 12px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.dialog-header,
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dialog-header h2,
.detail-panel > h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  color: var(--text);
}

.category-field {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.category-field legend,
.field > span {
  padding: 0;
  color: #c9c9d0;
  font-size: 12px;
  font-weight: 700;
}

.category-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.category-option {
  position: relative;
}

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

.category-option span {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101018;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.category-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #ff7483;
}

.field {
  display: grid;
  gap: 7px;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101018;
  color: var(--text);
  outline: none;
}

.field input::placeholder {
  color: #666672;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rich-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101018;
}

.editor-toolbar {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #13131d;
}

.editor-toolbar button {
  min-width: 31px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #c6c6cf;
}

.editor-toolbar button:hover {
  border-color: var(--line);
  background: var(--surface-pressed);
  color: #ffffff;
}

.editor-toolbar .toolbar-text-button {
  margin-left: auto;
  padding-inline: 10px;
  color: #ff7483;
}

.editor-surface {
  min-height: 150px;
  max-height: 42vh;
  overflow-y: auto;
  padding: 12px;
  color: var(--text);
  outline: none;
}

.editor-surface:empty::before {
  color: #666672;
  content: attr(data-placeholder);
  pointer-events: none;
}

.editor-surface img,
.rich-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 10px 0;
  border-radius: 6px;
}

.field-note {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 2px;
}

.primary-button,
.secondary-button {
  height: 44px;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: #e30c25;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: #d8d8de;
}

.secondary-button:hover {
  background: var(--surface-pressed);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.detail-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.rich-content {
  max-height: 58vh;
  overflow-y: auto;
  color: #d9d9df;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.rich-content p {
  margin: 0 0 10px;
}

.rich-content ul,
.rich-content ol {
  margin: 8px 0;
  padding-left: 22px;
}

.detail-pane {
  display: none;
  min-width: 0;
}

.detail-pane-empty {
  min-height: 240px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  border: 1px dashed #373743;
  border-radius: 8px;
  background: rgba(21, 21, 31, 0.42);
  color: var(--muted);
  text-align: center;
}

.detail-pane-empty strong {
  color: var(--text);
  font-size: 16px;
}

.detail-pane-empty p {
  max-width: 280px;
  margin: 0;
  font-size: 12px;
}

.detail-pane .detail-panel--desktop {
  gap: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.detail-pane .rich-content {
  max-height: none;
  overflow: visible;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid #353541;
  border-radius: 7px;
  background: #20202b;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: var(--accent);
  background: var(--accent);
}

@media (min-width: 680px) {
  .composer-dialog,
  .detail-dialog {
    margin: auto;
  }

  .composer-panel,
  .detail-panel {
    border-bottom: 1px solid var(--line);
    border-radius: 10px;
  }
}

@media (min-width: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .topbar {
    position: relative;
  }

  .topbar-inner {
    width: 100%;
    min-height: 64px;
    padding-inline: 24px;
  }

  .page {
    width: 100%;
    height: calc(100dvh - 65px);
    margin: 0;
    padding: 0;
  }

  .workspace {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(320px, 0.9fr) minmax(380px, 1.1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "filters filters"
      "list detail";
  }

  .sidebar {
    grid-area: filters;
    display: flex;
    align-items: center;
    padding: 10px 24px;
    border-bottom: 1px solid var(--line);
    background: #0d0d13;
  }

  .category-bar {
    width: 100%;
    padding-bottom: 0;
  }

  .list-section {
    grid-area: list;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
    padding: 20px 18px 40px 24px;
    border-right: 1px solid var(--line);
    scrollbar-gutter: stable;
  }

  .detail-pane {
    grid-area: detail;
    display: block;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 28px 48px;
    background:
      linear-gradient(180deg, rgba(208, 2, 27, 0.045), transparent 180px),
      #0b0b10;
    scrollbar-gutter: stable;
  }

  .detail-pane-empty {
    min-height: 320px;
    margin-top: min(12vh, 110px);
  }

  .detail-panel--desktop > h2 {
    font-size: clamp(22px, 2vw, 30px);
  }

  .detail-pane .rich-content {
    padding-bottom: 32px;
    color: #d2d2da;
    font-size: 15px;
    line-height: 1.7;
  }
}

@media (min-width: 1080px) {
  .topbar {
    display: none;
  }

  .page {
    height: 100dvh;
  }

  .workspace {
    grid-template-columns: 232px minmax(380px, 460px) minmax(420px, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "side list detail";
  }

  .sidebar {
    grid-area: side;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 24px;
    padding: 26px 18px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: #0d0d13;
  }

  .sidebar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    padding-inline: 4px;
  }

  .sidebar-brand h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
  }

  .sidebar-brand p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
  }

  .sidebar-action {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--accent);
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
  }

  .sidebar-action span:first-child {
    font-size: 19px;
    font-weight: 300;
    line-height: 1;
  }

  .sidebar-action:hover {
    background: #e30c25;
  }

  .sidebar-nav {
    display: grid;
    gap: 9px;
  }

  .sidebar-label {
    display: block;
    margin: 0;
    padding-inline: 4px;
    color: #6f6f7c;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .category-bar {
    flex-direction: column;
    gap: 5px;
    overflow: visible;
  }

  .category-pill {
    width: 100%;
    height: 39px;
    justify-content: flex-start;
    padding-inline: 12px;
    text-align: left;
  }

  .list-section {
    padding-top: 24px;
  }

  .detail-pane {
    padding: 34px clamp(28px, 3vw, 54px) 56px;
  }
}

@media (max-width: 420px) {
  .topbar-inner,
  .page {
    width: min(100% - 20px, 720px);
  }

  .need-card {
    grid-template-columns: 30px minmax(0, 1fr) 54px;
    gap: 9px;
    padding: 12px;
  }

  .like-button {
    width: 54px;
  }

  .category-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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