/* Stories Layout */
#view-stories.active { display: flex; flex-direction: column; }
.stories-layout { display: flex; gap: 16px; flex: 1; min-height: 0; padding-bottom: 20px; overflow: hidden; }
.stories-left { flex: 0 0 300px; overflow-y: auto; padding-right: 12px; border-right: 1px solid var(--border); }
.stories-right { flex: 1; overflow-y: auto; padding-left: 4px; }
.stories-left h3, .stories-right h3 { font-size: 13px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-mine-btn { font-size: 10px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--primary-dim); background: transparent; color: var(--primary); cursor: pointer; text-transform: none; letter-spacing: normal; white-space: nowrap; transition: all var(--transition-fast); margin-left: auto; }
.filter-mine-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.root-card, .child-card { background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; margin-bottom: 8px; cursor: pointer; transition: all var(--transition-fast); content-visibility: auto; contain-intrinsic-size: 80px; width: 100%; box-sizing: border-box; }
.root-card:hover, .child-card:hover { border-color: var(--primary-dim); background: rgba(82,183,136,0.06); }
.root-card.selected { border-color: var(--primary); background: rgba(82,183,136,0.1); }
.root-card h4, .child-card h4 { font-size: 14px; margin: 0 0 4px; color: var(--text); }
.root-card p, .child-card p { font-size: 12px; color: var(--text2); margin: 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.root-card .meta, .child-card .meta { font-size: 11px; color: var(--text3); margin-top: 6px; display: flex; gap: 12px; align-items: center; }

/* Home View */
#view-home.active { display: flex; align-items: center; justify-content: center; }
#homeContent { width: 100%; }
.home-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; text-align: center; position: relative;
  animation: fadeInUp 0.6s ease;
}
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.home-welcome .hero-decoration {
  position: relative; margin-bottom: 24px;
}
.home-welcome .hero-decoration .tree-icon {
  font-size: 72px; display: block; line-height: 1;
  animation: heroFloat 4s ease-in-out infinite;
  filter: drop-shadow(0 0 30px var(--primary-glow));
}
@keyframes heroFloat { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-8px) scale(1.02); } }
.home-welcome .hero-glow {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(82,183,136,0.15) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none; animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow { 0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; } 50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; } }
.home-welcome h1 {
  font-size: 42px; color: var(--primary); margin-bottom: 10px;
  letter-spacing: 3px; font-weight: 800;
  text-shadow: 0 0 40px var(--primary-glow);
  animation: fadeInUp 0.6s ease 0.1s both;
}
.home-welcome .subtitle {
  font-size: 16px; color: var(--text2); margin-bottom: 48px;
  line-height: 1.6; max-width: 400px; letter-spacing: 1px;
  animation: fadeInUp 0.6s ease 0.2s both;
}
.home-welcome .subtitle::before, .home-welcome .subtitle::after {
  content: ' · '; color: var(--primary); opacity: 0.4;
}
.home-actions {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  animation: fadeInUp 0.6s ease 0.3s both;
}
.home-actions .btn {
  padding: 14px 28px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 15px; cursor: pointer; background: var(--bg-surface); color: var(--text);
  transition: all var(--transition); backdrop-filter: blur(8px);
  font-weight: 600;
}
.home-actions .btn:hover { background: var(--bg-surface-hover); border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 8px 32px var(--primary-glow); }
.home-actions .btn:active { transform: translateY(-1px); }
.home-actions .btn-primary { background: var(--primary); color: var(--bg-deep); border-color: var(--primary); }

/* Story List */
.card-list { display: flex; flex-direction: column; gap: 10px; max-width: 600px; margin: 0 auto; }
.card-item {
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-active);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.card-item:hover {
  border-color: var(--primary-dim);
  background: rgba(82,183,136,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}
.card-item strong { display: block; margin-bottom: 4px; color: var(--text); }
.card-item p { font-size: 13px; color: var(--text2); margin: 0; }
.story-card {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; cursor: pointer; transition: all var(--transition);
  backdrop-filter: blur(8px); position: relative; overflow: hidden;
}
.story-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--primary), transparent);
  opacity: 0; transition: opacity var(--transition);
}
.story-card:hover { border-color: var(--border-active); transform: translateX(6px); box-shadow: 0 0 24px var(--primary-glow); }
.story-card:hover::before { opacity: 1; }
.story-card h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); font-weight: 600; }
.story-card .meta { font-size: 12px; color: var(--text3); }

/* Story View */
#view-story.active {
  display: flex; flex-direction: column; height: 100%;
}
#view-story > .story-header { flex-shrink: 0; padding: 6px 0; }
#view-story > .story-header h2 { font-size: 20px; margin-bottom: 4px; font-weight: 700; }
#view-story > .story-header .meta { font-size: 12px; color: var(--text3); }
#view-story > .tree-canvas {
  flex: 1; min-height: 0; overflow: auto; padding: 28px;
  position: relative;
  cursor: grab; user-select: none;
}
#view-story > .tree-canvas > .tree-inner {
  min-width: max-content;
  width: max-content;
  padding: 0 200px 200px 0;
}
#view-story > .tree-canvas.dragging { cursor: grabbing; }
#view-story > .action-bar { flex-shrink: 0; margin: 6px 0; }
#view-story > .node-form { flex-shrink: 0; }

/* Node Detail */
#view-node { display: flex; flex-direction: column; align-items: center; flex: 1; min-height: 0; padding-bottom: 0; box-sizing: border-box; }
#view-node > .action-bar { max-width: min(75vw, 800px); width: 100%; position: sticky; top: 0; z-index: 10; background: transparent; }
#view-node > .btn-ghost { align-self: flex-start; }
.node-detail-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; margin-bottom: 18px; margin-top: 4px;
  color: var(--text); font-weight: 700; justify-content: center;
}
.node-detail-icon { flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(82,183,136,0.3)); }
.node-detail {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; backdrop-filter: blur(8px);
  width: fit-content; min-width: 280px; max-width: min(75vw, 800px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
#view-node .comments {
  margin: 16px auto; max-width: min(75vw, 800px); width: 100%; min-width: 280px;
  max-height: 20vh; overflow-y: auto;
  transition: max-height 0.3s ease;
}
#view-node .node-form { margin: 14px auto; max-width: min(75vw, 800px); width: 100%; }
.node-detail .stats { font-size: 13px; color: var(--text3); display: flex; gap: 18px; margin-top: 12px; justify-content: space-between; padding: 0 16px; }
.node-detail .stats span { display: flex; align-items: center; gap: 4px; }
.node-detail .stats .stats-left,
.node-detail .stats .stats-right { display: flex; align-items: center; gap: 14px; }

/* Comments */
.comments {
  margin: 16px 0; max-width: min(75vw, 800px); width: fit-content; min-width: 280px;
  max-height: 260px; overflow-y: auto;
  transition: max-height 0.3s ease;
}
.comments.expanded { max-height: none; }
.comments-expand {
  text-align: center; padding: 10px; font-size: 12px;
  color: var(--primary); cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background var(--transition-fast);
}
.comments-expand:hover { background: rgba(82,183,136,0.06); }
.comment-item {
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast); border-radius: 4px;
}
.comment-item:last-child { border-bottom: none; }
.btn-reply {
  font-size: 11px; color: var(--primary); cursor: pointer;
  background: none; border: none; padding: 1px 6px;
  font-family: inherit; margin-top: 1px; display: inline-block;
}
.btn-reply:hover { text-decoration: underline; }
.reply-form {
  margin-top: 4px; padding: 4px 8px;
  background: rgba(0,0,0,0.1); border-radius: var(--radius-sm);
  display: flex; gap: 4px; flex-direction: column;
}
.reply-form textarea {
  width: 100%; background: rgba(0,0,0,0.15); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px; color: var(--text);
  font-family: inherit; font-size: 13px; resize: vertical;
  box-sizing: border-box;
}
.comment-item:hover { background: rgba(255,255,255,0.03); }
.comment-item .author { font-size: 13px; font-weight: 600; color: var(--primary); }
.comment-item .time { font-size: 11px; color: var(--text3); margin-left: 10px; }
.comment-item .text { font-size: 13px; margin-top: 2px; color: var(--text2); line-height: 1.35; }

/* Action Bar */
.action-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.action-bar .btn {
  padding: 8px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 13px; cursor: pointer; background: rgba(255,255,255,0.04); color: var(--text2);
  transition: all var(--transition-fast); display: inline-flex; align-items: center; gap: 5px;
  flex-shrink: 0;
}
.action-bar .btn:hover { background: var(--bg-surface-hover); border-color: var(--border-active); color: var(--text); }
.action-bar .btn:active { transform: scale(0.97); }
.action-bar .btn-primary { background: transparent; color: var(--text2); border-color: var(--border); }
.action-bar .btn-primary:hover { border-color: var(--primary); color: var(--primary); background: rgba(82,183,136,0.06); }
.action-bar .btn-primary.liked { background: rgba(233,106,106,0.12); color: #ff6b6b; border-color: rgba(233,106,106,0.25); }
.action-bar .btn-primary.liked:hover { background: rgba(233,106,106,0.25); border-color: #ff6b6b; box-shadow: 0 0 16px rgba(233,106,106,0.3); }
.action-bar .btn-secondary { background: transparent; color: var(--text2); border-color: var(--border); }
.action-bar .btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: rgba(224,122,95,0.08); }
.action-bar .btn-secondary.bookmarked { background: rgba(255,193,7,0.12); color: #ffc107; border-color: rgba(255,193,7,0.25); }
.action-bar .btn-secondary.bookmarked:hover { background: rgba(255,193,7,0.25); border-color: #ffc107; box-shadow: 0 0 16px rgba(255,193,7,0.3); }
.action-bar .btn-danger { background: rgba(233,106,106,0.12); color: #ff6b6b; border-color: rgba(233,106,106,0.25); }
.action-bar .btn-danger:hover { background: rgba(233,106,106,0.25); border-color: #ff6b6b; box-shadow: 0 0 16px rgba(233,106,106,0.3); }
.action-bar .btn-ghost { background: transparent; border: none; }
.action-bar .btn-ghost:hover { background: rgba(255,255,255,0.05); border: none; }
@media (max-width: 768px) {
  #storyActions.action-bar,
  #view-node > .action-bar {
    overflow-x: auto; flex-wrap: nowrap; white-space: nowrap;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  #storyActions.action-bar::-webkit-scrollbar,
  #view-node > .action-bar::-webkit-scrollbar { display: none; }
}

/* Node Form */
.node-form {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin: 14px 0; max-width: 500px; backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.node-form h4 { margin-bottom: 14px; font-size: 16px; color: var(--primary); font-weight: 600; }
.node-form textarea, .node-form select, .node-form input[type="text"] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; background: rgba(0,0,0,0.2); color: var(--text); outline: none; font-family: inherit;
  transition: all var(--transition-fast);
}
.node-form textarea:focus, .node-form select:focus { border-color: var(--primary); box-shadow: 0 0 12px var(--primary-glow); }
.node-form textarea:hover, .node-form select:hover { border-color: var(--border-active); }
.node-form .btn { margin-top: 8px; margin-right: 8px; }
.node-form .btn-primary { background: var(--primary); color: var(--bg-deep); border-color: var(--primary); }
.node-form .btn-primary:hover { background: var(--primary-light); box-shadow: 0 0 16px var(--primary-glow); }
.node-form .btn-ghost { background: transparent; color: var(--text2); border: none; }
.node-form .btn-ghost:hover { color: var(--primary); background: rgba(255,255,255,0.04); }

/* Search */
.search-bar { display: flex; gap: 10px; max-width: 500px; margin: 0 auto 20px; }
.search-bar input {
  flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: rgba(0,0,0,0.2); color: var(--text); outline: none;
  transition: all var(--transition-fast);
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 16px var(--primary-glow); }
.search-bar input:hover { border-color: var(--border-active); }

/* Status */
.status-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px;
  max-width: 650px; margin: 0 auto;
}
.status-card {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; backdrop-filter: blur(8px);
  transition: all var(--transition); cursor: default;
}
.status-card:hover { border-color: var(--border-active); transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.status-card .value { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.status-card .label { font-size: 12px; color: var(--text2); margin-top: 6px; letter-spacing: 0.5px; }

/* Export */
.export-preview {
  background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; font-size: 13px; max-height: 400px; overflow: auto; white-space: pre-wrap;
  color: var(--text2); max-width: 600px; margin: 0 auto; font-family: var(--font-mono);
  line-height: 1.6;
}

/* AI */
.ai-result {
  background: rgba(0,0,0,0.25); border-radius: var(--radius-sm); padding: 14px;
  margin-top: 12px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; color: var(--text2);
  border-left: 2px solid rgba(157,78,221,0.3);
}

/* Admin Canvas */
#view-admin { overflow: visible; }
#view-admin.active { display: flex; flex-direction: column; }
.admin-canvas {
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 20px 16px 40px; box-sizing: border-box;
}
.admin-title {
  text-align: center; font-size: 22px; margin-bottom: 20px;
  color: var(--text); font-weight: 700;
}
.admin-section {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}
.admin-section h3 {
  font-size: 16px; margin-bottom: 14px; color: var(--text); font-weight: 600;
}
.admin-section .user-item {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 6px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.admin-section .user-item:last-child { border-bottom: none; }
.admin-sec-level { color: var(--text2); font-size: 14px; }

/* Agreement Checkbox */
.agreement-group { margin-bottom: 12px; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text2); cursor: pointer;
  line-height: 1.4;
}
.checkbox-label input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--primary);
  flex-shrink: 0; cursor: pointer;
}
.agreement-link {
  color: var(--primary); text-decoration: none;
  transition: color var(--transition-fast);
}
.agreement-link:hover { color: var(--primary-light); text-decoration: underline; }

/* More Menu (three dots) */
.more-menu-wrap { position: relative; display: inline-flex; }
.more-menu-trigger {
  font-size: 16px; letter-spacing: 2px; padding: 0 4px;
  cursor: pointer; background: none; border: none; color: var(--text3);
  font-family: inherit; line-height: 1; border-radius: 4px;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.more-menu-trigger:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.more-menu-dropdown {
  position: absolute; right: 0; top: 100%; z-index: 99999;
  background: var(--bg-mid); border: 1px solid var(--border-active);
  border-radius: var(--radius-sm); padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  min-width: 100px;
}
.more-menu-item {
  display: block; width: 100%; padding: 6px 14px;
  border: none; background: none; color: var(--text2); font-size: 12px;
  cursor: pointer; border-radius: 4px; text-align: left; white-space: nowrap;
  font-family: inherit; transition: background var(--transition-fast), color var(--transition-fast);
}
.more-menu-item:hover { background: rgba(82,183,136,0.1); color: var(--text); }

/* Report Modal */
#reportReasonList { display: flex; flex-direction: column; gap: 8px; }
.report-reason {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text2); cursor: pointer;
  padding: 6px 10px; border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.report-reason:hover { background: rgba(255,255,255,0.04); }
.report-reason input[type="radio"] {
  accent-color: var(--primary); width: 14px; height: 14px; flex-shrink: 0;
}

@media (min-width: 769px) {
  #view-node { align-items: flex-start; }
  #view-node .comments { margin: 16px 0; }
  #view-node .node-form { margin: 14px 0; }
  .node-detail { max-height: 70vh; display: flex; flex-direction: column; }
  .node-detail .node-detail-scroll { flex: 1; min-height: 0; }
  .node-detail .node-title, .node-detail .stats, .node-detail #supplementBackForm { flex-shrink: 0; }
}
/* Utility overrides */
#view-search > .glass-panel {
  max-height: 100%; display: flex; flex-direction: column; overflow: hidden; margin-top: 0;
}
#searchResults { overflow-y: auto; flex: 1; min-height: 0; }
#view-stories, #view-export, #view-status { padding-top: 24px; }
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
  .node-detail { padding: 14px 4px 14px 12px; max-height: calc(100vh - 360px); display: flex; flex-direction: column; overflow: hidden; }
  .node-detail .node-detail-scroll {
    overflow-y: auto; scrollbar-gutter: stable; flex: 0 1 auto; min-height: 0;
    box-shadow: inset 0 -1px 0 rgba(82,183,136,0.1);
  }
  .node-detail .node-title, .node-detail .stats, .node-detail #supplementBackForm { flex-shrink: 0; }
  .node-detail .node-title { text-align: center; }
  .node-detail .front { text-align: justify; }
  #view-node > .btn-ghost { margin-top: auto; }
  #view-node { overflow: hidden; }
  #view-node.view.active { transform: none; }
}
