:root {
  --canvas: #f4f4f4;
  --canvas-strong: #ececec;
  --panel: #ffffff;
  --panel-soft: #f7f7f7;
  --ink: #171a20;
  --ink-soft: #393c41;
  --muted: #5c5e62;
  --line: rgba(23, 26, 32, 0.12);
  --line-strong: rgba(23, 26, 32, 0.22);
  --accent: #3e6ae1;
  --accent-strong: #244bb8;
  --accent-soft: #edf2ff;
  --blue-soft: #edf2ff;
  --green-soft: #eef8f0;
  --amber: #8a5a00;
  --amber-soft: #fff6e5;
  --red: #c20000;
  --red-soft: #fff1f1;
  --shadow: none;
  --shadow-soft: none;
  --radius-card: 4px;
  --radius-panel: 4px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: "Avenir Next", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--canvas);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(62, 106, 225, 0.8);
  outline-offset: 2px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #ffffff;
  color: var(--ink);
  outline: none;
  padding: 12px 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus {
  border-color: rgba(62, 106, 225, 0.72);
  box-shadow: 0 0 0 3px rgba(62, 106, 225, 0.14);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto 16px;
  padding: 14px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.topbar > div:first-child,
.topbar-actions {
  padding: 0 16px;
}

.topbar h1,
.panel h2,
.sheet-head h2,
.auth-copy h1 {
  margin: 0;
  line-height: 1.16;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.eyebrow.danger {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(560px, 1.3fr);
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - 126px);
}

.panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.recent-panel,
.manage-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  font-size: 18px;
  font-weight: 700;
}

.count-pill,
.hint-pill,
.user-pill,
.status-tag,
.soft-tag {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-card);
  white-space: nowrap;
}

.count-pill,
.hint-pill,
.user-pill {
  padding: 7px 10px;
  font-size: 12px;
}

.count-pill,
.user-pill {
  background: var(--panel-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.hint-pill {
  background: var(--blue-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(62, 106, 225, 0.18);
}

.message-flow {
  display: flex;
  flex: 1;
  min-height: 360px;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 18px 20px;
  scroll-behavior: smooth;
}

.chat-row {
  display: flex;
}

.chat-row.from-user {
  justify-content: flex-end;
}

.chat-row.from-ai {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 78%;
  padding: 11px 13px;
  border-radius: var(--radius-card);
  color: var(--ink);
  line-height: 1.6;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.chat-bubble.is-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: dotPulse 1s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

.from-user .chat-bubble {
  color: #ffffff;
  background: var(--ink);
  border-color: transparent;
}

.task-message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(90%, 520px);
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #ffffff;
  box-shadow: none;
  animation: riseIn 0.2s ease both;
}

.priority-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.priority-low {
  background: #2e8540;
}

.priority-medium {
  background: var(--accent);
}

.priority-high {
  background: var(--red);
}

.message-content {
  min-width: 0;
  padding: 0;
  text-align: left;
  background: transparent;
}

.message-content strong,
.message-content span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-content strong {
  font-size: 14px;
}

.message-content span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.composer-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  align-items: center;
  margin: 0 18px 18px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel-soft);
  box-shadow: var(--shadow-soft);
}

.composer-bar input {
  border-radius: var(--radius-card);
}

.composer-bar .primary-btn {
  width: 100%;
  min-width: 104px;
}

.mode-btn,
.primary-btn,
.ghost-btn,
.soft-btn,
.danger-btn,
.quiet-danger,
.danger-link,
.text-btn {
  border-radius: var(--radius-card);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.mode-btn:hover,
.primary-btn:hover,
.ghost-btn:hover,
.soft-btn:hover,
.danger-btn:hover,
.quiet-danger:hover,
.danger-link:hover,
.text-btn:hover {
  transform: none;
}

.primary-btn {
  padding: 12px 18px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: none;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.ghost-btn,
.soft-btn,
.mode-btn {
  padding: 10px 14px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.mode-btn.active,
.filter-toggle.active,
.soft-btn:hover,
.ghost-btn:hover {
  background: #eeeeee;
}

.quiet-danger,
.danger-link,
.text-btn {
  padding: 8px 10px;
  background: transparent;
}

.quiet-danger,
.danger-link {
  color: var(--red);
}

.danger-btn {
  padding: 12px 18px;
  color: #ffffff;
  background: var(--red);
}

.danger-btn:hover {
  background: #9f0000;
}

.text-btn {
  justify-self: start;
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 20px 14px;
}

.metric-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #ffffff;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  letter-spacing: 0;
}

.filter-block {
  display: grid;
  gap: 10px;
  padding: 0 20px 14px;
}

.search-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px 78px;
  gap: 10px;
}

.search-line .soft-btn {
  padding: 10px 12px;
}

.filter-toggle.active {
  color: var(--accent-strong);
  border-color: rgba(62, 106, 225, 0.24);
  background: var(--accent-soft);
}

.compact-filter-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.compact-filter-line .text-btn {
  padding: 7px 0;
}

.advanced-filters {
  display: grid;
  gap: 8px;
}

.filter-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.filter-row > span {
  color: var(--muted);
  font-size: 12px;
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-pills button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: var(--radius-card);
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
}

.filter-pills button.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(62, 106, 225, 0.24);
}

.task-list {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 0 20px 20px;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #ffffff;
  box-shadow: none;
}

.task-main {
  min-width: 0;
  padding: 0;
  text-align: left;
  background: transparent;
}

.task-title-row,
.task-actions,
.sheet-head,
.sheet-actions,
.tag-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-title-row {
  justify-content: space-between;
}

.task-main p {
  margin: 8px 0 10px;
  color: var(--muted);
  line-height: 1.55;
}

.meta-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.meta-line span,
.soft-tag {
  padding: 5px 8px;
  border-radius: var(--radius-card);
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.task-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.status-tag {
  padding: 6px 9px;
  font-size: 12px;
}

.status-pending {
  color: var(--accent-strong);
  background: var(--blue-soft);
}

.status-progress {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-done {
  color: #1f7a3f;
  background: var(--green-soft);
}

.status-deleted {
  color: var(--muted);
  background: #eeeeee;
}

.empty-block {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-card);
  background: #ffffff;
}

.empty-block p {
  max-width: 340px;
  margin: 8px auto 0;
  color: var(--muted);
  line-height: 1.6;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 22px;
  background: rgba(23, 26, 32, 0.26);
  backdrop-filter: blur(6px);
}

.bottom-sheet {
  width: min(760px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: #ffffff;
  box-shadow: none;
  animation: sheetUp 0.22s ease both;
}

.drag-handle {
  width: 46px;
  height: 4px;
  margin: 12px auto 8px;
  border-radius: var(--radius-card);
  background: rgba(23, 26, 32, 0.18);
}

.sheet-head {
  justify-content: space-between;
  padding: 14px 22px 12px;
}

.sheet-head h2 {
  font-size: 20px;
}

.sheet-content {
  display: grid;
  gap: 14px;
  padding: 0 22px 18px;
}

.summary-text {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.72;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.meta-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--panel-soft);
}

.meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.meta-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.raw-block {
  padding: 14px;
  border-radius: var(--radius-card);
  color: var(--muted);
  line-height: 1.72;
  background: var(--panel-soft);
}

.sheet-actions {
  justify-content: flex-end;
  padding: 14px 22px 22px;
  border-top: 1px solid var(--line);
}

.query-brief {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.query-brief span,
.compact-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: #ffffff;
}

.query-brief span {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

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

.compact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  text-align: left;
}

.compact-card span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

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

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(23, 26, 32, 0.32);
  backdrop-filter: blur(8px);
}

.auth-card {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.auth-copy p:last-child {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: var(--radius-card);
  background: var(--panel-soft);
}

.segmented button {
  padding: 10px;
  border-radius: var(--radius-card);
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: none;
  border: 1px solid var(--line);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  color: var(--ink);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  animation: riseIn 0.18s ease both;
}

.toast-success {
  color: #1f7a3f;
}

.toast-error {
  color: var(--red);
}

.skeleton-card {
  min-height: 96px;
  border-radius: var(--radius-card);
  background: linear-gradient(90deg, #eeeeee, #ffffff, #eeeeee);
  background-size: 240% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-card.short {
  min-height: 76px;
}

@keyframes sheetUp {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

@keyframes dotPulse {
  0%,
  80%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 1080px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .recent-panel {
    min-height: 620px;
  }

  .manage-panel {
    min-height: 720px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    top: 10px;
    align-items: flex-start;
    flex-direction: column;
    border-radius: var(--radius-panel);
  }

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

  .dashboard-grid {
    min-height: auto;
  }

  .panel-head,
  .sheet-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .composer-bar {
    grid-template-columns: minmax(0, 1fr) 96px;
    border-radius: var(--radius-panel);
  }

  .task-card {
    grid-template-columns: 1fr;
  }

  .task-actions,
  .sheet-actions {
    justify-content: flex-start;
  }

  .search-line {
    grid-template-columns: minmax(0, 1fr) 64px 68px;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .compact-filter-line {
    grid-template-columns: 1fr;
  }

  .sheet-backdrop {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .composer-bar {
    grid-template-columns: 1fr;
  }

  .search-line {
    grid-template-columns: 1fr 1fr;
  }

  .search-line input {
    grid-column: 1 / -1;
  }
}
