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

:root {
  --bg: #f5f2eb;
  --panel-left: #1a1a2e;
  --panel-right: #ffffff;
  --accent: #e8824a;
  --accent-light: #fdf0e8;
  --text-dark: #1a1a2e;
  --text-mid: #5a5a7a;
  --text-light: #9090a8;
  --border: #e8e4dc;
  --folder-bg: #f9f7f3;
  --folder-hover: #f0ede6;
  --folder-open: #fff8f4;
  --leaf-bg: #fdf6f1;
  --leaf-hover: #fbeee5;
  --content-bg: #fffdf9;
  --shadow: 0 2px 12px rgba(26,26,46,0.08);
  --shadow-lg: 0 8px 32px rgba(26,26,46,0.12);
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  display: flex;
  align-items: stretch;
  height: 100vh;
}

/* ── LEFT PANEL ── */
.left-panel {
  width: 340px; min-width: 340px; height: 100vh;
  background: var(--panel-left);
  display: flex; flex-direction: column; justify-content: center;
  padding: 3rem 2.5rem;
  position: relative; overflow: hidden; flex-shrink: 0;
}
.left-panel::before {
  content: ''; position: absolute; top: -80px; right: -80px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(232,130,74,0.12); pointer-events: none;
}
.left-panel::after {
  content: ''; position: absolute; bottom: -60px; left: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(232,130,74,0.07); pointer-events: none;
}

.greeting {
  font-size: 12px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--accent); font-weight: 500; margin-bottom: 1rem;
}
.welcome-title {
  font-family: 'DM Serif Display', serif;
  font-size: 2.6rem; line-height: 1.15; color: #ffffff; margin-bottom: 1.5rem;
}
.welcome-title em { font-style: italic; color: var(--accent); }
.welcome-sub {
  font-size: 15px; line-height: 1.7; color: rgba(255,255,255,0.55);
  margin-bottom: 2.5rem; font-weight: 300;
}
.divider { width: 40px; height: 2px; background: var(--accent); margin-bottom: 2rem; border-radius: 2px; }

/* ── RIGHT PANEL ── */
.right-panel {
  flex: 1; display: flex; flex-direction: column;
  height: 100vh; overflow: hidden; min-width: 0;
}

.top-bar {
  background: var(--panel-right); border-bottom: 1px solid var(--border);
  padding: 0 2rem; height: 58px;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-light); flex-wrap: wrap;
}
.breadcrumb span { color: var(--text-mid); }
.breadcrumb .sep { color: var(--text-light); }
.breadcrumb .current { color: var(--text-dark); font-weight: 500; }
.breadcrumb .home-link {
  cursor: pointer; color: var(--accent); transition: color 0.15s;
}
.breadcrumb .home-link:hover { color: #d4703a; }

.toolbar-btns { display: flex; gap: 8px; }

.btn {
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
  cursor: pointer; transition: all 0.15s; background: white; color: var(--text-dark);
}
.btn:hover { background: var(--folder-hover); border-color: #d0ccbf; }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: #d4703a; }

.main-area { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* ── TREE PANEL ── */
.tree-panel {
  width: 300px; min-width: 260px;
  border-right: 1px solid var(--border); background: var(--panel-right);
  overflow-y: auto; height: 100%; padding: 1.25rem 0;
}

.tree-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--text-light); padding: 0 1.25rem 0.5rem; font-weight: 500;
}



.tree-node { position: relative; }

.node-row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 1.25rem; cursor: pointer;
  transition: background 0.12s; user-select: none; position: relative;
}
.node-row:hover { background: var(--folder-hover); }
.node-row.active { background: var(--folder-open); }
.node-row.active::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}

.node-row .chevron {
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light); transition: transform 0.18s;
  flex-shrink: 0; font-size: 10px;
}
.node-row.open .chevron { transform: rotate(90deg); }
.node-row .chevron.empty { opacity: 0; }

.node-icon { font-size: 15px; flex-shrink: 0; }
.node-pin-icon { font-size: 14px; flex-shrink: 0; line-height: 1; }

.node-label {
  font-size: 14px; color: var(--text-dark); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400;
}
.node-row.leaf-node .node-label { color: var(--text-mid); font-size: 13px; }
.node-row.leaf-node:hover .node-label { color: var(--text-dark); }
.node-row.leaf-node.active .node-label { color: var(--accent); font-weight: 500; }

.node-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.node-row:hover .node-actions { opacity: 1; }
.node-action-btn {
  width: 20px; height: 20px; border: none; background: none; cursor: pointer;
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-light); transition: background 0.1s, color 0.1s;
}
.node-action-btn:hover { background: var(--border); color: var(--text-dark); }
.node-action-btn.danger:hover { background: #fde8e8; color: #c0392b; }

.children-container { display: none; }
.children-container.open { display: block; }

.indent-1 .node-row { padding-left: 2rem; }
.indent-2 .node-row { padding-left: 2.75rem; }
.indent-3 .node-row { padding-left: 3.5rem; }

/* ── CONTENT PANEL ── */
.content-panel {
  flex: 1; background: var(--content-bg);
  overflow-y: auto; height: 100%; min-width: 0;
  display: flex; flex-direction: column;
}

.content-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-light); gap: 12px; padding: 2rem; text-align: center;
}
.content-empty .big-icon { font-size: 3rem; opacity: 0.3; }
.content-empty p { font-size: 14px; max-width: 240px; line-height: 1.6; }

.content-body { padding: 2.5rem 3rem; max-width: 680px; display: none; }
.content-body.visible { display: block; }

.content-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--accent); font-weight: 500; margin-bottom: 0.75rem;
}
.content-title {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem; color: var(--text-dark); margin-bottom: 1rem; line-height: 1.25;
}
.content-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-light);
  margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border);
}
.content-text { font-size: 15px; line-height: 1.8; color: var(--text-mid); }
.content-text b, .content-text strong { color: var(--text-dark); }
.content-text blockquote {
  border-left: 3px solid var(--accent); padding: 8px 16px; margin: 12px 0;
  background: var(--accent-light); border-radius: 0 6px 6px 0;
  font-style: italic; color: var(--text-mid);
}

/* ── ATTACHMENTS ── */
.attachments-section { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.attachments-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--text-light); font-weight: 500; margin-bottom: 0.75rem;
}
.attachment-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  background: var(--folder-bg); border: 1px solid var(--border);
  margin-bottom: 6px; transition: background 0.12s, border-color 0.12s;
}
.attachment-item:hover { background: var(--folder-hover); }
.attachment-icon { font-size: 18px; flex-shrink: 0; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-name {
  font-size: 13px; color: var(--text-dark); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attachment-size { font-size: 11px; color: var(--text-light); margin-top: 1px; }
.attachment-dl {
  font-size: 11px; color: var(--accent); font-weight: 500;
  flex-shrink: 0; text-decoration: none; white-space: nowrap;
}
.attachment-dl:hover { color: #d4703a; }

.attachment-preview-btn {
  font-size: 11px; color: var(--accent); font-weight: 500;
  background: none; border: none; cursor: pointer;
  padding: 0; margin-right: 4px; text-decoration: underline;
  font-family: 'DM Sans', sans-serif; flex-shrink: 0;
}
.attachment-preview-btn:hover { color: #d4703a; }

.image-preview-box {
  display: none; margin-top: 8px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--border); background: #000; margin-bottom: 6px;
}
.image-preview-box.open { display: block; }
.image-preview-box img {
  width: 100%; max-height: 400px; object-fit: contain; display: block; cursor: zoom-in;
}

/* ── LIGHTBOX ── */
.lightbox-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.85); align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
  max-width: 92vw; max-height: 92vh; border-radius: 6px;
  object-fit: contain; box-shadow: 0 8px 60px rgba(0,0,0,0.6);
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  color: white; font-size: 28px; cursor: pointer; background: none; border: none; line-height: 1;
}

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(26,26,46,0.45); z-index: 100;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 16px; padding: 2rem;
  width: 420px; box-shadow: var(--shadow-lg); position: relative;
}
.modal h3 {
  font-family: 'DM Serif Display', serif; font-size: 1.4rem;
  color: var(--text-dark); margin-bottom: 1.25rem;
}
.modal label {
  font-size: 12px; font-weight: 500; color: var(--text-mid);
  text-transform: uppercase; letter-spacing: 0.08em;
  display: block; margin-bottom: 5px; margin-top: 14px;
}
.modal input, .modal textarea, .modal select {
  width: 100%; font-family: 'DM Sans', sans-serif; font-size: 14px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-dark); background: var(--folder-bg);
  outline: none; transition: border-color 0.15s; resize: none;
}
.modal input:focus, .modal textarea:focus, .modal select:focus {
  border-color: var(--accent); background: white;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 1.5rem; }
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-light);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background 0.1s;
}
.modal-close:hover { background: var(--folder-hover); color: var(--text-dark); }

/* ── MOBILE HEADER ── */
.mobile-header {
  display: none; background: var(--panel-left);
  padding: 14px 16px; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.mobile-title { font-family: 'DM Serif Display', serif; font-size: 1.2rem; color: white; }
.mobile-title em { color: var(--accent); font-style: italic; }
.mobile-menu-btn {
  background: none; border: 1px solid rgba(255,255,255,0.2);
  color: white; border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}

/* ── MOBILE TREE DRAWER ── */
.mobile-tree-overlay {
  display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5);
}
.mobile-tree-overlay.open { display: block; }
.mobile-tree-drawer {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 85%; max-width: 320px; background: white;
  overflow-y: auto; padding: 1rem 0;
  transform: translateX(-100%); transition: transform 0.25s ease;
}
.mobile-tree-overlay.open .mobile-tree-drawer { transform: translateX(0); }
.mobile-tree-close {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px 16px;
  font-size: 13px; color: var(--text-light); cursor: pointer;
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
}

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 768px) {
  html, body { overflow: auto !important; height: auto !important; }
  body { flex-direction: column; overflow: auto; height: auto; min-height: 100vh; }
  .left-panel { display: none; }
  .mobile-header { display: flex; }
  .right-panel { height: auto; overflow: visible; flex: none; width: 100%; }
  .main-area { flex-direction: column; overflow: visible; height: auto; }
  .tree-panel { display: none; }
  .content-panel { overflow: visible; height: auto; min-height: 60vh; }
  .top-bar { padding: 0 12px; }
  .content-body { padding: 1.5rem 1rem; }
  .content-title { font-size: 1.5rem; }
  .modal { width: calc(100vw - 2rem); max-width: 420px; margin: 1rem; }
}
@media (hover: none) { .node-actions { opacity: 1 !important; } }
