:root {
  --drawer-width: min(560px, 92vw);
  --bg-1: #08111c;
  --bg-2: #112033;
  --panel: rgba(12, 23, 38, 0.84);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f6efe7;
  --muted: #a9bfd3;
  --accent: #ff8a5b;
  --accent-2: #4cc6cf;
  --agent: #1b3044;
  --user: #ff8a5b;
  --good: #78d69b;
  --warn: #ffd071;
  --bad: #ff6f6f;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 138, 91, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(76, 198, 207, 0.18), transparent 28%),
    linear-gradient(140deg, var(--bg-1) 0%, var(--bg-2) 100%);
  overflow-x: hidden;
  overflow-y: auto;
}

.noise {
  position: fixed;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.2;
  pointer-events: none;
}

.noise-left {
  top: -12rem;
  left: -10rem;
  background: var(--accent);
}

.noise-right {
  right: -10rem;
  bottom: -12rem;
  background: var(--accent-2);
}

.app-shell {
  position: relative;
  width: min(1160px, calc(100% - 24px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 16px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.drawer-trigger {
  position: fixed;
  top: 50%;
  left: 0;
  transform: translate(0, -50%);
  z-index: 30;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 23, 38, 0.82);
  color: var(--text);
  border-left: 0;
  border-radius: 0 18px 18px 0;
  padding: 12px 10px 12px 8px;
  cursor: pointer;
  backdrop-filter: blur(16px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 62px;
  transition: transform 180ms ease, background 180ms ease;
}

.drawer-trigger-arrow {
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 180ms ease;
}

.drawer-trigger-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
}

.drawer-trigger.is-open .drawer-trigger-arrow {
  transform: rotate(180deg);
}

.drawer-trigger.is-open {
  transform: translate(calc(var(--drawer-width) - 6px), -50%);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.46);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 24;
}

.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.hero,
.layout,
.video-row,
.media-chat-row,
.signal-grid,
.radar-like {
  display: grid;
  gap: 12px;
}

.hero {
  grid-template-columns: 1.45fr 1fr;
  align-items: end;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #ffc19e;
  font-size: 0.7rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1.02;
  font-family: Georgia, "Songti SC", serif;
}

.hero-copy,
.panel-copy,
.meta-box p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.42;
  font-size: 0.9rem;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.status-pill,
.mini-tag {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  font-size: 0.8rem;
}

.layout {
  grid-template-columns: 1fr;
  min-height: 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(320px, 0.82fr);
  gap: 16px;
  min-height: 0;
  height: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  padding: 16px;
}

.sidebar-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100dvh;
  width: var(--drawer-width);
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: rgba(12, 23, 38, 0.96);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  border-radius: 0 24px 24px 0;
  overflow: hidden;
  transform: translateX(-102%);
  transition: transform 220ms ease;
}

.sidebar-panel.is-open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px 10px 22px;
  flex: 0 0 auto;
}

.drawer-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 14px 40px 22px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sidebar-view {
  display: none;
  padding-bottom: 12px;
}

.sidebar-view.is-active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head-compact {
  align-items: flex-start;
}

h2,
h3 {
  margin: 0;
}

.primary-button,
.send-button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  padding: 9px 14px;
  border-radius: 999px;
  color: #09111f;
  background: linear-gradient(135deg, var(--accent) 0%, #ffca7c 100%);
}

.video-row {
  grid-template-columns: 1.1fr 0.9fr;
  margin-bottom: 14px;
}

.chat-panel {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.media-chat-row {
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.video-card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: rgba(255, 255, 255, 0.04);
  align-self: start;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-tags {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.video-tags span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(9, 17, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
}

.chat-stack {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
  height: 100%;
}

.side-rail {
  display: grid;
  grid-template-rows: minmax(280px, 0.86fr) minmax(320px, 1.14fr);
  gap: 16px;
  min-height: 0;
}

.calendar-panel,
.journal-panel {
  min-height: 0;
  display: grid;
}

.calendar-panel {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.calendar-nav {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.calendar-scroll {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.calendar-day {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  display: grid;
  place-items: center;
  position: relative;
}

.calendar-day.is-outside {
  opacity: 0.34;
}

.calendar-day.is-active {
  background: linear-gradient(135deg, rgba(255, 138, 91, 0.22), rgba(76, 198, 207, 0.18));
  border-color: rgba(255, 255, 255, 0.18);
}

.calendar-day.has-entry::after,
.calendar-day.is-today::before {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.calendar-day.has-entry::after {
  width: 6px;
  height: 6px;
  bottom: 6px;
  background: #ffc19e;
}

.calendar-day.is-today::before {
  width: 8px;
  height: 8px;
  top: 6px;
  right: 6px;
  background: var(--accent-2);
}

.journal-panel {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.journal-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.journal-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
  transition: background 160ms ease, color 160ms ease;
}

.journal-tab.is-active {
  background: linear-gradient(135deg, rgba(255, 138, 91, 0.22), rgba(76, 198, 207, 0.18));
  color: var(--text);
}

.journal-card-body {
  min-height: 0;
  position: relative;
}

.journal-pane {
  display: none;
  height: 100%;
}

.journal-pane.is-active {
  display: block;
}

.journal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.author-wrap {
  width: min(1160px, calc(100% - 24px));
  margin: 0 auto 24px;
  padding-bottom: 24px;
}

.author-panel {
  padding: 22px 24px;
  border-radius: 24px;
  background: rgba(10, 19, 32, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.author-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.author-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.signal-grid,
.radar-like {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.signal-card,
.metric-card {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.signal-card span,
.metric-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
  font-size: 0.8rem;
}

.signal-card strong,
.metric-card strong {
  font-size: 1.12rem;
}

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

.bubble {
  max-width: 84%;
  padding: 12px 14px;
  border-radius: 18px;
  line-height: 1.55;
  position: relative;
  animation: rise 220ms ease-out;
  font-size: 0.94rem;
}

.bubble-agent {
  align-self: flex-start;
  background: rgba(27, 48, 68, 0.95);
  border-top-left-radius: 10px;
}

.bubble-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255, 138, 91, 0.95), rgba(255, 188, 111, 0.92));
  color: #101820;
  border-top-right-radius: 10px;
}

.bubble-role {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-bottom: 4px;
}

.bubble-typing .bubble-body {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 18px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(246, 239, 231, 0.8);
  animation: blink 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
}

.send-button {
  min-width: 82px;
  height: 46px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent-2) 0%, #93efe2 100%);
  color: #09111f;
}

.emotion-core {
  display: grid;
  place-items: center;
  margin: 8px 0 14px;
}

.emotion-ring {
  width: min(232px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 14px;
  display: grid;
  place-items: center;
  background: conic-gradient(from 20deg, #78d69b, #4cc6cf, #ff8a5b, #ffd071, #78d69b);
}

.emotion-center {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  background: radial-gradient(circle at top, rgba(17, 31, 47, 0.98), rgba(8, 17, 28, 0.99));
}

.emotion-center span {
  color: var(--muted);
  font-size: 0.84rem;
}

.emotion-center strong {
  font-size: clamp(1.4rem, 3vw, 1.95rem);
}

.emotion-center small {
  color: #ffc19e;
  font-size: 0.92rem;
}

.bars {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.bar {
  display: grid;
  gap: 6px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 180ms ease-out;
  background: linear-gradient(90deg, var(--accent-2) 0%, var(--accent) 100%);
}

.meta-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.diary-body {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text);
  overflow: auto;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.diary-editor {
  min-height: 100%;
  resize: none;
  height: 100%;
}

.mini-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

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

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

@media (max-width: 980px) {
  body {
    overflow-y: auto;
  }

  .app-shell {
    width: min(100% - 18px, 100%);
    min-height: 100dvh;
    padding: 16px 0 20px;
    overflow: visible;
  }

  .hero,
  .layout,
  .video-row,
  .media-chat-row,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .status-stack {
    justify-content: flex-start;
  }

  .chat-panel,
  .media-chat-row,
  .chat-stack {
    height: auto;
  }

  .video-card {
    max-width: 520px;
  }

  .side-rail {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 640px) {
  .panel {
    padding: 14px;
    border-radius: 20px;
  }

  .author-panel {
    padding: 18px;
    border-radius: 20px;
  }

  .hero {
    gap: 10px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .signal-grid,
  .radar-like,
  .composer {
    grid-template-columns: 1fr;
  }

  .drawer-trigger {
    min-width: 56px;
    padding: 12px 9px 12px 8px;
  }

  textarea {
    min-height: 64px;
  }
}
