:root {
  --bg: #f6f7f6;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --text: #17191c;
  --muted: #6f7680;
  --line: rgba(23, 25, 28, 0.08);
  --line-strong: rgba(23, 25, 28, 0.14);
  --brand: #1f7a5a;
  --brand-soft: #e7f4ee;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.05);
  --font-sans: "Segoe UI", "PingFang SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at top left, rgba(31, 122, 90, 0.06), transparent 20%),
    linear-gradient(180deg, #fafbfa 0%, #f3f5f4 100%);
  color: var(--text);
  font-family: var(--font-sans);
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px 20px 48px;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}

.app-layout, .main-shell, .stack, .field, .cards, .form-grid {
  display: grid;
  gap: 16px;
}

.main-shell {
  min-width: 0;
  max-width: 1080px;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  padding: 12px 10px;
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #131619;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.sidebar-brand h1,
.hero-copy h2,
.section-head h2,
.card-title,
.drawer-head h3,
.login-card h1 {
  margin: 0;
}

.sidebar-brand p,
.muted,
.feed-summary,
.feed-time {
  margin: 0;
  color: var(--muted);
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  align-content: start;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--muted);
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.7);
  color: var(--text);
}

.sidebar-link.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.nav-icon {
  width: 18px;
  text-align: center;
  opacity: 0.8;
}

.sidebar-logout {
  border: none;
  background: transparent;
  width: 100%;
  justify-content: flex-start;
}

.hero-shell {
  display: grid;
  gap: 22px;
}

.hero-topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
}

.hero-copy {
  display: grid;
  gap: 8px;
}

.hero-kicker {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-actions,
.search-pop,
.composer-toolbar,
.composer-toolbar-left,
.composer-toolbar-right,
.composer-bottom,
.composer-meta,
.composer-actions,
.attachment-row,
.feed-main,
.feed-head,
.feed-head-meta,
.feed-actions,
.feed-meta,
.card-actions,
.inline-fields,
.login-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-actions {
  justify-content: flex-end;
}

.search-pop {
  gap: 8px;
}

.search-input,
.field input,
.field textarea,
.composer-title,
.composer-textarea {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.search-input {
  width: 220px;
  min-height: 40px;
  padding: 0 14px;
}

.search-input:focus,
.field input:focus,
.field textarea:focus,
.composer-mini-fields input:focus,
.composer-textarea:focus {
  border-color: rgba(31, 122, 90, 0.3);
  box-shadow: 0 0 0 4px rgba(31, 122, 90, 0.08);
}

.composer {
  display: grid;
  gap: 14px;
  padding: 20px 24px 18px;
  background: var(--surface-strong);
  border: 1px solid rgba(23, 25, 28, 0.04);
  border-radius: 30px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.06);
}

.composer-editor {
  display: grid;
  gap: 10px;
  min-height: 360px;
  padding: 4px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.composer-title {
  width: 100%;
  min-height: 46px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 24px;
  font-weight: 600;
}

.composer-title:focus {
  border-color: transparent;
  box-shadow: none;
}

.composer-toolbar {
  justify-content: space-between;
  min-height: 36px;
  padding-bottom: 4px;
}

.composer-toolbar-left,
.composer-toolbar-right {
  gap: 8px;
  align-items: center;
}

.composer-textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 8px 0 2px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 17px;
  line-height: 1.78;
}

.composer-textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.composer-bottom {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.composer-meta {
  gap: 10px;
}

.composer-actions {
  margin-left: auto;
}

.field input,
.field textarea,
.meta-input {
  width: 100%;
  padding: 12px 14px;
}

.meta-input {
  min-width: 180px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.meta-input:focus {
  border-color: rgba(31, 122, 90, 0.3);
  box-shadow: 0 0 0 4px rgba(31, 122, 90, 0.08);
}

.composer-drop {
  min-height: 40px;
  border: 1px dashed transparent;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--muted);
  font-size: 13px;
  background: rgba(247,248,248,0.7);
  padding: 0 12px;
}

.composer-drop.dragover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: rgba(31, 122, 90, 0.36);
}

.attachment-row {
  gap: 8px;
}

.attachment-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: #eef1f3;
  color: var(--muted);
  font-size: 12px;
}

.attachment-remove {
  border: none;
  background: transparent;
  color: #b14e4e;
  padding: 0 4px;
}

.badge.favorite { background: #e7f4ee; color: var(--brand); }
.badge.pinned { background: #fff1d7; color: #946a00; }

.stream-section {
  display: grid;
  gap: 14px;
  padding-top: 8px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
}

.feed-item {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
}

.feed-main {
  align-items: flex-start;
  justify-content: space-between;
}

.feed-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: #fff;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.feed-content {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.feed-head {
  justify-content: space-between;
  align-items: center;
}

.feed-head-meta {
  gap: 8px;
}

.feed-star {
  color: #c99314;
}

.feed-summary {
  line-height: 1.62;
  max-width: 72ch;
}

.feed-type {
  color: var(--muted);
  font-size: 12px;
}

.feed-meta {
  gap: 8px;
}

.feed-actions {
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  align-self: center;
  opacity: 0.14;
  transition: 0.18s ease;
  gap: 6px;
}

.feed-actions form,
.feed-actions a,
.feed-actions button {
  margin: 0;
  vertical-align: middle;
}

.feed-actions form {
  display: inline-flex;
  align-items: center;
}

.feed-item:hover .feed-actions {
  opacity: 1;
}

.btn,
.ghost-btn,
.mini-btn,
.action-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}

.btn {
  background: #131619;
  color: #fff;
  border-color: #131619;
}

.mini-btn {
  min-height: 32px;
  padding: 0 11px;
  font-size: 13px;
}

.file-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiet-btn {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.quiet-btn:hover {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.icon-btn {
  width: 36px;
  padding: 0;
}

.feed-title-button {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  font: inherit;
  color: var(--text);
  font-weight: 600;
}

.feed-title-button:hover {
  color: var(--brand);
}

.danger { color: #c74a4a; }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 21, 25, 0.24);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(520px, 100%);
  height: 100%;
  padding: 24px;
  background: #fff;
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 18px;
  overflow: auto;
}

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

.drawer-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-form {
  display: grid;
  gap: 14px;
}

.detail-body {
  display: grid;
  gap: 16px;
}

.detail-file-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.detail-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

.file-preview {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8faf9;
  overflow: hidden;
}

.file-preview-empty {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  color: var(--muted);
  font-size: 14px;
}

.file-preview-image {
  display: grid;
  place-items: center;
  padding: 14px;
  background: #f5f7f6;
}

.file-preview-image img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border-radius: 14px;
}

.file-preview-frame {
  width: 100%;
  height: 480px;
  border: 0;
  background: #fff;
}

.file-preview-media {
  display: block;
  width: 100%;
  max-height: 420px;
  background: #000;
}

.file-preview-audio {
  display: block;
  width: 100%;
  padding: 18px;
}

.file-preview-text {
  max-height: 420px;
  overflow: auto;
  padding: 18px;
  background: transparent;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
}

.empty {
  padding: 36px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  text-align: center;
  color: var(--muted);
}

.tag-cloud {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.doc-block,
.doc-grid,
.doc-item,
.doc-head {
  display: grid;
  gap: 12px;
}

.doc-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.doc-head h3,
.doc-item h4 {
  margin: 0;
}

.doc-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.doc-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.72);
}

.doc-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

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

.session-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.session-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.session-head,
.session-meta,
.session-badges,
.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.session-head {
  justify-content: space-between;
}

.session-head h3 {
  margin: 0;
  font-size: 16px;
}

.session-meta {
  color: var(--muted);
  font-size: 13px;
}

.session-agent {
  margin: 0;
  word-break: break-all;
  font-size: 13px;
}

.tag-card {
  padding: 16px;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.panel {
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.section {
  padding: 20px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 24px;
}

.login-switch {
  gap: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0 0 14px;
  }

  .sidebar-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .hero-topbar,
  .hero-actions,
  .search-pop,
  .composer-toolbar,
  .composer-bottom,
  .feed-main,
  .feed-head {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    width: 100%;
  }

  .feed-actions {
    justify-content: flex-start;
    opacity: 1;
    flex-wrap: wrap;
  }

  .session-card,
  .session-head {
    flex-direction: column;
    align-items: stretch;
  }

  .drawer-panel {
    width: 100%;
  }
}
