:root {
  --mist: #EDEFED;
  --mist-deep: #DFE5E3;
  --teal-light: #B7CBC8;
  --teal: #7C9B98;
  --lake: #33484A;
  --lake-soft: #3E5654;
  --ink: #20272A;
  --stone: #5F7674;
  --stone-light: #C7D6D3;
  --line: rgba(32,39,42,0.15);
  --bg-main: #F4F5F4;
  --status-red: #B55B5B;
  --status-red-bg: #F8EBEB;
  --status-green: #5B8B76;
  --status-green-bg: #EAF3EF;
  --status-gray: #889492;
  --status-gray-bg: #EAECEC;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--lake);
  color: var(--ink);
  font-family: 'Zen Kaku Gothic New', sans-serif;
  font-size: 13px;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.serif { font-family: 'Zen Old Mincho', serif; }
.mono { font-family: 'Space Grotesk', sans-serif; }

#login-screen {
  position: fixed; inset: 0;
  background: var(--lake);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.login-box {
  background: var(--mist);
  padding: 40px 50px;
  border-radius: 4px;
  width: 90%; max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-header .logo { font-size: 18px; letter-spacing: 0.2em; color: var(--lake); font-weight: 600; }
.login-header .sub { font-size: 10px; color: var(--stone); letter-spacing: 0.1em; margin-top: 4px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 11px; color: var(--stone); margin-bottom: 6px; letter-spacing: 0.05em; }
.form-group input { 
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); 
  background: #fff; border-radius: 3px; font-family: 'Space Grotesk', sans-serif;
  outline: none; transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--lake); }

.login-btn {
  width: 100%; padding: 12px; background: var(--lake); color: var(--mist);
  border: none; border-radius: 3px; font-size: 13px; cursor: pointer;
  letter-spacing: 0.1em; margin-top: 10px; transition: opacity 0.2s;
}
.login-btn:hover { opacity: 0.9; }
.login-error { color: #8b3a3a; font-size: 11px; margin-top: 12px; text-align: center; min-height: 16px; }

#dashboard {
  display: flex;
  width: 100%;
  height: 100%;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.sidebar {
  width: 220px;
  background: var(--lake);
  color: var(--mist);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.1);
  transition: left 0.3s ease;
}
.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header .title { font-size: 14px; letter-spacing: 0.15em; font-weight: 600; }
.sidebar-header .subtitle { font-size: 10px; color: var(--teal-light); letter-spacing: 0.05em; }

.sidebar-nav { padding: 20px 0; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; color: var(--mist-deep); text-decoration: none;
  font-size: 12px; transition: background 0.2s, color 0.2s; cursor: pointer;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,0.05); color: #fff; border-left: 3px solid var(--teal);
}
.sidebar-nav svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; }

.sidebar-footer { padding: 20px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 10px; color: var(--stone-light); line-height: 1.5; }

.main-content {
  flex: 1;
  background: var(--bg-main);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}

.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px; flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 15px; }

.hamburger { display: none; cursor: pointer; }
.hamburger svg { width: 24px; height: 24px; stroke: var(--lake); stroke-width: 2; fill: none; }

.topbar-right { display: flex; align-items: center; gap: 20px; font-size: 12px; }
.topbar-right .clock { color: var(--stone); font-variant-numeric: tabular-nums; letter-spacing: 0.05em; }
.topbar-right .user { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.avatar { width: 26px; height: 26px; background: var(--teal); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; }

.dashboard-scroll {
  padding: 30px;
  overflow-y: auto;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.tab-pane.active { display: block; }

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

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.widget-val { font-size: 28px; font-weight: 700; color: var(--lake); margin-top: 4px; letter-spacing: 0.05em; }
.widget-sub { font-size: 11px; color: var(--stone); margin-top: 8px; line-height: 1.5; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: flex; flex-direction: column;
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  background: #FAFAFA;
}
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--lake); }
.card-body { padding: 0; }

.category-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--lake);
  padding: 16px 20px 8px;
  background: #FAFBFA;
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  letter-spacing: 0.05em;
}
.category-title:first-child { border-top: none; }

.feed-container {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.archive-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  color: var(--stone);
  margin: 10px auto 10px;
  max-width: 720px;
  letter-spacing: 0.05em;
}
.archive-notice::before,
.archive-notice::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.chat-sticky-area {
  position: sticky;
  bottom: -30px;
  background: var(--bg-main);
  padding: 20px 0 30px;
  z-index: 100;
}
.chat-input-wrapper {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--teal);
  border-radius: 6px;
  display: flex;
  padding: 8px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.chat-input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  padding: 8px;
  background: transparent;
  color: var(--ink);
}
.chat-input-wrapper button {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s;
}
.chat-input-wrapper button:hover { background: var(--lake); }

.thread-card { 
  background: #fff; 
  border: 1px solid var(--line); 
  border-radius: 6px; 
  padding: 16px 20px; 
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.msg { display: flex; gap: 12px; }
.msg-avatar { width: 36px; height: 36px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 13px; flex-shrink: 0; }
.avatar-f { background: var(--stone); }
.avatar-s { background: var(--lake); }
.avatar-a { background: var(--teal); }
.avatar-m { background: var(--status-gray); }
.avatar-e { background: #8B7355; }
.avatar-sys { background: #333; }

.msg-content { flex: 1; }
.msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg-name { font-size: 13px; font-weight: 600; color: var(--lake); }
.msg-time { font-size: 11px; color: var(--stone); }
.msg-body { font-size: 13px; color: #333; line-height: 1.6; }

::selection { background: var(--teal); color: #fff; }
.hidden-text { color: #fff; background: #fff; user-select: text; cursor: text; border-radius: 2px; }

.reply-box { margin-left: 48px; padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.reply { display: flex; gap: 12px; margin-bottom: 16px; }
.reply:last-child { margin-bottom: 0; }
.reply .msg-avatar { width: 28px; height: 28px; font-size: 11px; }

.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { 
  font-size: 10px; color: var(--stone); font-weight: 500;
  padding: 10px 20px; border-bottom: 1px solid var(--line); 
  background: #fff; 
}
.data-table td { 
  padding: 12px 20px; border-bottom: 1px solid var(--line); 
  font-size: 12px; color: var(--ink); vertical-align: middle; line-height: 1.4;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #FAFBFA; }

.col-status { width: 100px; text-align: center !important; }

.badge { 
  padding: 5px 8px; 
  border-radius: 3px; 
  font-size: 11px; 
  font-weight: 600; 
  white-space: nowrap; 
  text-align: center;
  display: inline-block;
  width: 72px;
  letter-spacing: 0.1em;
  box-sizing: border-box;
}
.badge.red { background: var(--status-red-bg); color: var(--status-red); }
.badge.green { background: var(--status-green-bg); color: var(--status-green); }
.badge.gray { background: var(--status-gray-bg); color: var(--status-gray); }
.badge.yellow { background: #FDF6E3; color: #B58900; }

.data-link {
  color: #3b82f6;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: color 0.2s;
}
.data-link:hover { color: var(--lake); }

.dialog-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: none; justify-content: center; align-items: center; z-index: 10000; opacity: 0; transition: opacity 0.3s ease; }
.dialog-overlay.show { display: flex; opacity: 1; }

.audio-player-box {
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  width: 90%;
  max-width: 400px;
  min-height: 240px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.audio-header {
  background: #1a1a1a;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #333;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  color: #888;
  letter-spacing: 0.05em;
}
.audio-header .close-btn { cursor: pointer; font-size: 14px; transition: color 0.2s; }
.audio-header .close-btn:hover { color: #fff; }

.audio-visualizer {
  flex: 1;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px;
  background: #0a0a0a;
  position: relative;
}

.wave-bar {
  width: 4px;
  height: 10px;
  background: var(--teal);
  border-radius: 2px;
  animation: wave 1s infinite ease-in-out;
  animation-play-state: paused;
}

.audio-visualizer.playing .wave-bar {
  animation-play-state: running; 
}

.play-btn {
  background: transparent;
  border: 1px solid #555;
  color: #ccc;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
  flex-shrink: 0;
}
.play-btn:hover { background: #333; color: #fff; border-color: #777; }
.play-btn svg { width: 12px; height: 12px; fill: currentColor; }

@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(3); }
}

.audio-controls {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid #222;
}

/* Progress Slider */
.progress-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
}
.progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #888;
  cursor: pointer;
}

/* Volume Wrapper */
.vol-control-wrapper {
  display: flex;
  align-items: center;
  background: #111;
  border: 1px solid #333;
  padding: 4px 10px;
  border-radius: 15px;
  gap: 6px;
}

.vol-slider {
  width: 50px;
  -webkit-appearance: none;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
  cursor: pointer;
}

.cc-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: 1px solid #555;
  color: #888;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}
.cc-btn.active { background: #eee; color: #111; border-color: #eee; }

.cc-display {
  display: none;
  padding: 16px 20px;
  background: #000;
  color: #ccc;
  font-size: 12px;
  line-height: 1.6;
  border-top: 1px dashed #333;
  font-family: 'Space Grotesk', sans-serif;
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9998;
  opacity: 0; transition: opacity 0.3s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

@media (max-width: 768px) {
  .hamburger { display: block; }
  .sidebar { position: fixed; left: -250px; top: 0; bottom: 0; width: 250px; z-index: 9999; }
  .sidebar.open { left: 0; }
  .topbar { padding: 0 15px; }
  .topbar-right .user span { display: none; }
  .dashboard-scroll { padding: 15px; }
}

.reaction-box {
  display: flex;
  gap: 6px;
  margin-top: 5px;

}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--mist);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--stone);
  cursor: default;
  user-select: none;
}
.reaction svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
