/* ════════════════════════════════════════════
   Want-To-Do Tree — style.css
   ════════════════════════════════════════════ */

/* ── TOKENS ─────────────────────────────────── */
:root {
  --main: #005630;
  --main-rgb: 0, 86, 48;
  --main-light: #007a44;
  --main-dark: #003d22;
  --sub: #f8f0e3;
  --accent: #f4e414;
  --gray: #e2e2e1;
  --gray-dark: #b0b0ae;
  --text: #1a1a1a;
  --text-light: #555;
  --white: #ffffff;
  --border: #d0d0ce;

  --shadow: 0 4px 24px rgba(0, 86, 48, .10);
  --shadow-lg: 0 8px 40px rgba(0, 86, 48, .16);

  --radius: 12px;
  --radius-sm: 8px;
  --tr: 0.22s cubic-bezier(.4, 0, .2, 1);

  --font-en: 'Inter', sans-serif;
  --font-jp-main: '砧 丸丸ゴシックBSr StdN R', 'Kinuta Marumaru Gothic BSr StdN', sans-serif;
  --font-jp-sub: '游ゴシックPr6N-M', 'Yu Gothic Pr6N', 'Yu Gothic', sans-serif;

  /* Heading colors (used by list cards / accents) */
  --h1-c: #005630;
  --h2-c: #007a44;
  --h3-c: #2e7d52;
  --h4-c: #558b6e;
  --h5-c: #7a9e8c;
  --h6-c: #9db5a8;

  /* Editor (node UI) */
  --editor-indent-step: 20px;
  --editor-marker-w: 20px;
  --editor-marker-gap: 8px;
  --editor-left-pad: 6px;

  /* Panels */
  --panel-header-height: 46px;

  /* Depth backgrounds (Tree & Guides) */
  --lv1-bg: #e7f3ef;
  --lv2-bg: #d4e9e2;
  --lv3-bg: #c1dfd4;
  --lv4-bg: #afd5c7;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-jp-main);
  background: var(--sub);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html[lang="ja"] body {
  line-height: 1.8;
}

html[lang="en"] body {
  line-height: 1.6;
}

/* ── SCROLLBAR ─────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-dark);
}

/* Header Layout (§15) */
.app-header {
  height: var(--panel-header-height);
  background: var(--main);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  user-select: none;
  z-index: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.header-view-switch {
  flex: 1;
  display: flex;
  justify-content: flex-start;
}

.header-title {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.header-actions {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.logo-img {
  height: 30px;
  width: auto;
}

.app-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

/* Dropdown System (§15) */
.dropdown-wrap {
  position: relative;
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(var(--main-rgb), 0.1);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  min-width: 240px;
  padding: 8px;
  color: var(--text);
  overflow: hidden;
  animation: dropdownIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 10px;
  transition: all 0.2s ease;
  color: var(--text);
  text-decoration: none;
}

.dropdown-item:hover {
  background: rgba(var(--main-rgb), 0.08);
  color: var(--main);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* User Info Section in Dropdown */
.user-info-section {
  padding: 10px 16px;
  background: var(--sub);
  transition: background 0.2s;
}

.user-info-section.interactive {
  cursor: pointer;
}

.user-info-section.interactive:hover {
  background: #eeebe3;
}

.user-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--main);
  margin-bottom: 4px;
}

.sub-panel {
  padding: 4px 0;
  background: rgba(0, 0, 0, 0.03);
  border-top: 1px solid var(--border);
}

.user-actions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Footer (§15) */
.app-footer {
  height: 32px;
  background: var(--main-dark);
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font-size: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 400;
}

.footer-left {
  display: flex;
  gap: 16px;
}

.footer-right {
  display: flex;
  align-items: center;
}

#btn-user-footer {
  background: rgba(255, 255, 255, 0.1);
  border: 0.1rem solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0;
  font-size: 0.7rem;
}

#btn-user-footer:hover {
  background: rgba(255, 255, 255, 0.2);
}

.dropup .dropdown-panel {
  top: auto;
  bottom: calc(100% + 4px);
  animation: dropupIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropupIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#user-menu-label {
  display: flex;
  align-items: center;
  gap: 4px;
}

#user-menu-label .arrow {
  font-size: 0.7rem;
  opacity: 0.7;
  transition: transform var(--tr);
}

.user-menu-btn[aria-expanded="true"] .arrow {
  transform: rotate(180deg);
}


.logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}

header h1,
.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filename-badge {
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .25);
  color: rgba(255, 255, 255, .85);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: .76rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filename-badge.dirty::after {
  content: "●";
  color: var(--accent);
  font-size: 10px;
  text-shadow: 0 0 5px var(--accent);
}


/* ── VIEW SWITCH ────────────────────────────── */
.view-switch {
  display: flex;
  gap: 8px;
  margin-right: 12px;
}

.view-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-switch button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.view-switch button.active {
  background: var(--white);
  color: var(--main);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border-color: transparent;
}

.pc-only {
  display: flex;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {

  /* Mobile Full-screen views (§15.472) */
  .panel-list {
    display: none !important;
    flex-direction: column;
    /* Ensure vertical layout */
    position: fixed;
    top: var(--panel-header-height);
    bottom: 32px;
    /* footer height */
    left: 0;
    right: 0;
    width: 100% !important;
    height: auto !important;
    z-index: 100;
  }

  .panel-md,
  .panel-tree {
    display: none !important;
    position: fixed;
    top: var(--panel-header-height);
    bottom: 32px;
    /* footer height */
    left: 0;
    right: 0;
    width: 100% !important;
    height: auto !important;
    z-index: 100;
  }

  body.view-editor .panel-md {
    display: flex !important;
  }

  body.view-tree .panel-tree {
    display: flex !important;
  }

  body.view-list .panel-list {
    display: flex !important;
  }

  .resizer {
    display: none !important;
  }

  .pc-only {
    display: none;
  }

  .mobile-only {
    display: flex;
  }
}

/* ============================================================
   BUTTONS (shared)
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-en);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--tr);
  white-space: nowrap;
}

.btn-sm {
  padding: 5px 10px;
  font-size: .72rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--main-dark);
  box-shadow: 0 2px 8px rgba(244, 228, 20, .3);
}

.btn-primary:hover {
  background: #ffe800;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(244, 228, 20, .5);
}

.btn-outline {
  background: rgba(255, 255, 255, .12);
  color: var(--white);
  border: 1.5px solid rgba(255, 255, 255, .28);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, .22);
  border-color: rgba(255, 255, 255, .55);
}

.btn-ghost {
  background: transparent;
  color: rgba(255, 255, 255, .9);
  border: 1.5px solid rgba(255, 255, 255, .28);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .55);
}

/* ============================================================
   APP MENU (☰) + language popover
   index.html has #app-menu + .menu-panel [1](https://onedrive.live.com/?id=45155dfa-9f9b-46ee-85a6-f159f336afc9&cid=5dc9936d8d6b66d4&web=1)
   ============================================================ */

.app-menu {
  position: fixed;
  top: 60px;
  right: 8px;
  min-width: 220px;
  max-width: min(94vw, 360px);
  z-index: 500;
}

.menu-panel {
  background: var(--white);
  border-radius: 12px;
  padding: 14px;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: background .2s;
  color: inherit;
  text-decoration: none;
}

.menu-item:hover {
  background: rgba(0, 0, 0, .06);
}

.menu-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 10px 0;
}

.lang-popover,
#lang-sub {
  margin-top: .5rem;
  background: var(--gray);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.lang-popover button,
.menu-sub-item {
  border: none;
  background: none;
  padding: .5rem;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
}

.lang-popover button:hover,
.menu-sub-item:hover {
  background: rgba(0, 0, 0, .06);
}

/* ============================================================
   LAYOUT / PANELS
   ============================================================ */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.panel-md,
.panel-tree,
.panel-list {
  display: none;
  flex-direction: column;
  min-width: 0;
}

/* ── PC Layout ── */
@media (min-width: 769px) {
  .panel-tree {
    display: flex;
    /* Always show tree on PC by default */
    flex: 1;
  }

  body.view-tree .panel-md,
  body.view-tree .panel-list {
    display: none;
  }

  body.view-editor .panel-md {
    display: flex;
    width: 450px;
    /* Default width, resizer will adjust */
  }

  body.view-list .panel-list {
    display: flex;
    width: 450px;
  }
}

/* ── Mobile Layout ── */
@media (max-width: 768px) {

  body.view-editor .panel-md,
  body.view-tree .panel-tree,
  body.view-list .panel-list {
    display: flex;
    flex: 1;
  }
}

/* View transitions */
.panel-md,
.panel-tree,
.panel-list {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

body.switching .panel-md,
body.switching .panel-tree,
body.switching .panel-list {
  opacity: 0;
  transform: translateY(10px);
}


.panel-header {
  height: var(--panel-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--white);
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  font-weight: 700;
  color: var(--main);
  letter-spacing: .08rem;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--main);
}

.accent-dot {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(244, 228, 20, .6);
}

.panel-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Resizer */
.resizer {
  width: 5px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--tr);
  position: relative;
  z-index: 50;
}

.resizer:hover,
.resizer.active {
  background: var(--main-light);
}

@media (max-width: 768px) {
  .app-main {
    flex-direction: column;
  }

  .resizer {
    display: none;
  }
}

/* ============================================================
   LIST VIEW (restore)
   ============================================================ */
.panel-list {
  background: var(--gray);
  overflow: hidden;
}

.list-body {
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.list-item {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border-radius: 1rem;
  color: var(--white);
  background: linear-gradient(135deg, var(--h4-c), var(--h3-c));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .18s ease, box-shadow .18s ease;
}

.list-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .14);
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.list-date {
  font-size: .75rem;
  color: var(--white);
  white-space: nowrap;
}

.list-actions {
  display: flex;
  gap: 6px;
}

.list-actions button {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--gray);
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-actions button:hover {
  background: var(--accent);
}

/* ============================================================
   EDITOR (node-based UI)
   ============================================================ */
/* Editor header buttons */
.panel-md .panel-actions .btn {
  background: white;
  color: var(--main);
  width: 2rem;
  justify-content: center;
  border: 1.5px solid var(--border);
}

.panel-md .panel-actions .btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--main-dark);
}

/* Editor container */
.md-editor-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: white;
}

/* Editor main */
#md-editor {
  position: absolute;
  inset: 0;
  overflow: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .84rem;
  padding: 20px 22px;
  color: var(--main);
  background-color: rgba(var(--main-rgb), .03);
  caret-color: var(--main);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Editor nodes */
#md-editor>div.md-node,
#md-editor>div.md-plain {
  position: relative;
  min-height: 1.8em;
  padding-left: calc(var(--editor-left-pad) + var(--lv, 0) * var(--editor-indent-step));
}

/* Indent guides (ARCHITECTURE.md §15) - Aligned with marker centers (left-pad + half-marker-w) */
#md-editor>.md-node {
  background-image:
    linear-gradient(to right, rgba(var(--main-rgb), 0.8) 1px, transparent 1px),
    linear-gradient(to right, rgba(var(--main-rgb), 0.4) 1px, transparent 1px),
    linear-gradient(to right, rgba(var(--main-rgb), 0.15) 1px, transparent 1px),
    linear-gradient(to right, rgba(var(--main-rgb), 0.08) 1px, transparent 1px);
  background-size: 100% 100%;
  background-position: 16px 0, 36px 0, 56px 0, 76px 0;
  /* (6 + 10) + step*N */
  background-repeat: no-repeat;
}

#md-editor>.md-node[data-depth="1"] {
  background-image: none;
}

#md-editor>.md-node[data-depth="2"] {
  background-image: linear-gradient(to right, rgba(var(--main-rgb), 0.8) 1px, transparent 1px);
  background-position: 16px 0;
}

#md-editor>.md-node[data-depth="3"] {
  background-image: linear-gradient(to right, rgba(var(--main-rgb), 0.8) 1px, transparent 1px), linear-gradient(to right, rgba(var(--main-rgb), 0.4) 1px, transparent 1px);
  background-position: 16px 0, 36px 0;
}

#md-editor>.md-node[data-depth="4"] {
  background-image: linear-gradient(to right, rgba(var(--main-rgb), 0.8) 1px, transparent 1px), linear-gradient(to right, rgba(var(--main-rgb), 0.4) 1px, transparent 1px), linear-gradient(to right, rgba(var(--main-rgb), 0.15) 1px, transparent 1px);
  background-position: 16px 0, 36px 0, 56px 0;
}



/* Marker */
.md-marker {
  display: inline-block;
  width: var(--editor-marker-w);
  margin-right: var(--editor-marker-gap);
  text-align: center;
  font-weight: 800;
  font-family: var(--font-en);
  cursor: move;
}

.md-marker:active {
  cursor: grabbing;
}

/* Background colors */
#md-editor>.md-node.md-h1 {
  background-color: rgba(var(--main-rgb), 1.00);
  padding: 0.2rem;
  margin-bottom: 0.1rem;
}

#md-editor>.md-node.md-h2 {
  background-color: rgba(var(--main-rgb), .55);
}

#md-editor>.md-node.md-h3 {
  background-color: rgba(var(--main-rgb), .08);
}

/* Heading */
#md-editor>.md-node.md-h1 .md-text {
  color: white;
  font-weight: 800;
  font-size: 1rem;
}

#md-editor>.md-node.md-h2 .md-text {
  color: white;
  font-weight: 600;
}

#md-editor>.md-node.md-h3 .md-text {
  color: var(--main);
  font-weight: 580;
}

/* Marker colors */
#md-editor>.md-node.md-h1 .md-marker {
  color: var(--accent);
}

#md-editor>.md-node.md-h2 .md-marker {
  color: var(--main);
}

#md-editor>.md-node.md-h3 .md-marker {
  color: var(--h3-c);
}

#md-editor>.md-node.md-plain .md-marker {
  color: var(--main);
}

/* Text */
.md-text {
  display: inline-block;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
}

/* States */
#md-editor>.cursor-line {
  background: rgba(244, 228, 20, 0.22);
  border-left: 1px solid var(--main);
  box-shadow: inset 3px 0 0 var(--main);
}

#md-editor>.selected-line {
  background: rgba(0, 86, 48, 0.08);
  border: 2px solid var(--accent);
}

/* Dragging styles */
.md-node.dragging {
  opacity: 0.4;
  background: var(--gray);
}

.md-node.drag-before::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 5;
}

.md-node.drag-after::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 5;
}



/* ============================================================
   TREE PANEL + ZOOM GROUP
   ============================================================ */
.panel-tree {
  flex: 1;
  display: flex;
  background: var(--sub);
  overflow: hidden;
  min-width: 300px;
}

.zoom-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--gray);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.zoom-btn {
  width: 27px;
  height: 27px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background var(--tr);
}

.zoom-btn:hover {
  background: var(--white);
}

.zoom-label {
  font-size: .74rem;
  font-weight: 600;
  color: var(--text-light);
  min-width: 36px;
  text-align: center;
}

/* Canvas */
.tree-canvas-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
  cursor: default;
  user-select: none;
}

#tree-svg-container {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  transform-origin: top left;
}

#tree-svg {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

#tree-nodes {
  position: absolute;
  top: 0;
  left: 0;
}

/* Nodes */
.root-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
}

.root-logo {
  max-width: 160px;
  max-height: 100px;
  object-fit: contain;
  pointer-events: none;
}

.tree-node {
  position: absolute;
}

/* Depth 2+ "For that..." (そのために…) logic via CSS (§15) */
.tree-node:not(.root-node):not(.depth-1) .node-shell::before {
  content: "そのために…";
  position: absolute;
  top: -18px;
  left: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--main-light);
  opacity: 0.7;
  pointer-events: none;
}

/* Button Highlights (§15) */
.btn-highlight {
  background-color: var(--accent) !important;
  color: var(--text) !important;
  box-shadow: 0 0 12px rgba(244, 228, 20, 0.5);
  animation: pulse-border-accent 2s infinite;
}

@keyframes pulse-border-accent {
  0% {
    box-shadow: 0 0 0 0 rgba(244, 228, 20, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(244, 228, 20, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(244, 228, 20, 0);
  }
}

.unsaved-indicator {
  color: var(--main);
  font-weight: 700;
  font-size: 0.85rem;
  margin-left: 10px;
}


.node-shell {
  position: relative;
}

.node-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  background: var(--gray);
  color: var(--main);
  border-radius: var(--radius-sm);
  font-size: .83rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.2;
  cursor: grab;
  transition: box-shadow var(--tr), transform var(--tr), border-color var(--tr);
  touch-action: manipulation;
}

.node-box:active {
  cursor: grabbing;
}

.node-text {
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  line-height: 1.2;
  /* Match box line-height (§15) */
  cursor: text;
}

.node-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.node-date {
  font-size: 11px;
  color: rgba(var(--main-rgb), 0.6);
  line-height: 1.2;
  margin-top: 2px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.depth-1 .node-date,
.depth-2 .node-date {
  color: rgba(255, 255, 255, 0.85);
}


.node-date-input {
  position: absolute;
  right: 0rem;
  bottom: -4rem;
  width: 7rem;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--gray);
  background: rgba(255, 255, 255, .95);
  font-size: .75rem;
  z-index: 100;
}

/* Selected / Active */
.tree-node.selected-node .node-box {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 20px rgba(244, 228, 20, 0.6);
  z-index: 50;
}

.tree-node.active-node .node-box {
  outline: 3px solid var(--accent);
  box-shadow: 0 0 25px rgba(244, 228, 20, 0.7);
  transform: scale(1.02);
}

/* Depth (§15.465 match editor colors) */
.root-node .node-box {
  background: none;
  box-shadow: none;
  border: none;
  cursor: default;
}

.depth-1 .node-box {
  background: linear-gradient(135deg, var(--h1-c), var(--h2-c));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(0, 86, 48, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.depth-2 .node-box {
  background: linear-gradient(135deg, var(--h2-c), var(--h3-c));
  color: var(--white);
  box-shadow: 0 2px 8px rgba(0, 86, 48, 0.15);
}

/* Collapse */
.collapse-btn {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--main-dark);
  border: none;
  cursor: pointer;
  font-size: .65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--tr);
}

.collapse-btn:hover {
  transform: scale(1.2);
}

/* Node actions */
.node-actions {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  gap: 0.5rem;
  justify-content: flex-end;
  z-index: 100;
}

.tree-node:hover .node-actions,
.tree-node.selected-node .node-actions {
  display: flex;
}

.node-btn {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tr);
}

.node-btn-date {
  background: var(--gray);
  color: #fff;
}

.node-btn-add {
  background: var(--main);
  color: #fff;
}

.node-btn-del {
  background: #ff6b6b;
  color: #fff;
}

.node-btn:hover {
  transform: scale(1.15);
  background: var(--accent);
  color: var(--main-dark);
}

.node-btn.active {
  background: var(--accent);
  color: var(--main-dark);
  box-shadow: 0 0 10px var(--accent);
}

/* Edges */
.tree-edge {
  fill: none;
  stroke: var(--main);
  stroke-linecap: round;
}

.tree-edge-0 {
  stroke-width: 2.5;
  opacity: .48;
}

.tree-edge-1 {
  stroke-width: 2;
  opacity: .35;
}

.tree-edge-2 {
  stroke-width: 1.5;
  opacity: .26;
}

.tree-edge-3 {
  stroke-width: 1.2;
  opacity: .20;
}

/* DnD */
.node-box.drag-source {
  opacity: .35;
  transform: scale(.96);
}

.node-box.drop-child {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 14px rgba(244, 228, 20, .5);
}

.node-box.drop-before {
  border-top: 2.5px solid var(--accent) !important;
}

.node-box.drop-after {
  border-bottom: 2.5px solid var(--accent) !important;
}

/* Drop line */
.drop-line {
  position: fixed;
  z-index: 9000;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(244, 228, 20, .6);
  display: none;
  pointer-events: none;
}

/* Masking logic (§15) — Gradient fill instead of invisible */
.tree-node.masked .node-box {
  background: linear-gradient(135deg, var(--main) 0%, var(--main-dark) 100%) !important;
  color: transparent !important;
  border-color: var(--main-dark) !important;
  position: relative;
  overflow: hidden;
}

.tree-node.masked .node-box * {
  visibility: hidden;
}

.tree-node.masked .node-box::after {
  content: "MASKED";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15rem;
  visibility: visible;
}


.drop-line.visible {
  display: block;
}

/* Marquee */
.selection-marquee {
  position: absolute;
  border: 1.5px solid var(--main-light);
  background: rgba(0, 86, 48, 0.1);
  pointer-events: none;
  z-index: 9000;
  display: none;
}

/* ── MASKED NODES ─────────────────────────────── */
/* Tree View: masked (Invisibile per ARCHITECTURE.md) */
/* Removed display:none to allow gradient fill masking */

/* Editor: masked */
#md-editor>.md-node.masked-line {
  display: none !important;
}


/* ── MENU PANELS (dropdown positioning) ────────── */
.user-menu {
  position: relative;
}

.user-menu-panel {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 500;
}

.user-menu-panel button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--tr);
}

.user-menu-panel button:hover {
  background: var(--gray);
}

.file-menu {
  position: relative;
}

.file-menu-panel {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 500;
}

.file-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--tr);
}

.file-menu-item:hover {
  background: var(--gray);
}

.list-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Empty state (§15.471) */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  /* Changed from height:100% to flex:1 */
  width: 100%;
  gap: 14px;
  opacity: .65;
  pointer-events: none;
}

.empty-icon {
  font-size: 3rem;
}

.empty-state p {
  font-size: .9rem;
  color: var(--text-light);
  text-align: center;
}

/* ============================================================
   CONTEXT MENU / STATUS / TOAST
   ============================================================ */
.ctx-menu {
  position: fixed;
  z-index: 6000;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 190px;
  display: none;
  animation: ctxIn .12s ease;
}

.ctx-menu.open {
  display: block;
}

@keyframes ctxIn {
  from {
    opacity: 0;
    transform: scale(.96) translateY(-4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  font-family: var(--font-en);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--tr);
}

.ctx-item:hover {
  background: var(--gray);
}

.ctx-danger {
  color: #d93025;
}

.ctx-danger:hover {
  background: #ffe9e9;
}

.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.statusbar {
  background: var(--main-dark);
  color: rgba(255, 255, 255, .55);
  font-size: .7rem;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 4px 18px;
  flex-shrink: 0;
  letter-spacing: .02em;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff6b6b;
}

.status-dot.synced {
  background: #4cff91;
}

#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--main);
  color: var(--white);
  padding: 10px 22px;
  border-radius: 30px;
  font-size: .84rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1), opacity .32s;
  opacity: 0;
  z-index: 9500;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============================================================
   LOGIN OVERLAY / MODALS
   index.html includes #login-overlay + .login-modal etc [1](https://onedrive.live.com/?id=45155dfa-9f9b-46ee-85a6-f159f336afc9&cid=5dc9936d8d6b66d4&web=1)
   ============================================================ */

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 40, 22, 0.45);
  backdrop-filter: blur(8px);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn .3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.login-modal {
  background: var(--white);
  width: 100%;
  max-width: 420px;
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 50, 28, 0.25);
  text-align: center;
}

.login-logo {
  width: 60%;
  height: auto;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
}

.login-tabs {
  display: flex;
  background: var(--gray);
  padding: 4px;
  border-radius: 12px;
  margin: 20px 0;
}

.tab-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 10px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 9px;
  transition: all var(--tr);
  color: var(--text-light);
}

.tab-btn.active {
  background: var(--white);
  color: var(--main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--main-dark);
}

.form-group input {
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: .9rem;
  outline: none;
  transition: border-color var(--tr);
}

.form-group input:focus {
  border-color: var(--main);
}




.btn-google {
  background: var(--white);
  color: var(--text-light);
  border: 1.5px solid var(--border);
  justify-content: center;
  gap: 10px;
}

.btn-google:hover {
  background: #f1f3f4;
  border-color: #d2e3fc;
  color: var(--text);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--gray-dark);
  font-size: .8rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Generic modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 40, 20, 0.45);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.modal.show {
  display: flex;
  opacity: 1;
}

/* Modern Modal Dialog */
.modal-dialog {
  position: relative;
  width: 90%;
  max-width: 600px;
  background: white;
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 30px 90px rgba(0, 50, 28, 0.3);
  max-height: 85vh;
  overflow: auto;
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.show .modal-dialog {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--gray);
  font-size: 1.2rem;
  line-height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-dialog {
  max-width: 480px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.feedback-dialog h2 {
  color: var(--main);
  margin-bottom: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.feedback-dialog textarea {
  width: 100%;
  padding: 1.2rem;
  border-radius: 16px;
  border: 1.5px solid rgba(0, 86, 48, 0.1);
  background: rgba(255, 255, 255, 0.5);
  margin-bottom: 1.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s ease;
  resize: none;
}

.feedback-dialog textarea:focus {
  border-color: var(--main);
  background: white;
  box-shadow: 0 8px 24px rgba(0, 86, 48, 0.1);
}

.feedback-dialog button[type="submit"] {
  width: 100%;
  padding: 1rem;
  border-radius: 14px;
  border: none;
  background: var(--main);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 10px 20px rgba(0, 86, 48, 0.2);
}

.feedback-dialog button[type="submit"]:hover {
  background: var(--main-light);
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(0, 86, 48, 0.3);
}

.modal-close:hover {
  background: var(--gray-dark);
  color: white;
}

@media (max-width: 480px) {
  .modal-dialog {
    width: 90%;
    border-radius: 0;
  }
}

/* Help modal enhancements (§15) */
.help-tab.empty {
  opacity: 0.3;
  /* pointer-events: none removed to allow clicking grayed tabs (§15.463) */
  filter: grayscale(1);
}

.help-category-heading {
  margin: 0.5rem 0 1.2rem;
  color: var(--main);
  font-size: 1.05rem;
  font-weight: 800;
  border-bottom: 2px solid rgba(0, 86, 48, 0.1);
  padding-bottom: 0.6rem;
  letter-spacing: 0.05em;
}

#help-list {
  list-style: none;
  padding: 0;
}

#help-list li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.8rem;
  font-size: 0.92rem;
  line-height: 1.6;
}

#help-list li::before {
  content: "•";
  position: absolute;
  left: 0.3rem;
  color: var(--main);
  font-weight: 800;
}

/* ============================================================
   MEASUREMENT RULER (tree)
   ============================================================ */
#tree-ruler {
  z-index: -100;
  visibility: hidden;
  position: absolute;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
  font-family: var(--font-en);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
}

#tree-ruler.depth-0 {
  font-size: .9rem;
  font-weight: 700;
  padding: 10px 20px;
}

#tree-ruler.depth-1 {
  font-size: .83rem;
  font-weight: 500;
}

#tree-ruler.depth-2,
#tree-ruler.depth-3,
#tree-ruler.depth-4,
#tree-ruler.depth-5 {
  font-size: .79rem;
  font-weight: 500;
}

/* file input */
#file-input {
  display: none;
}

/* ── HELP MODAL (2-level tabs) ───────────────── */
.help-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 1.2rem;
}

.device-tabs {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray);
}

.category-tabs {
  overflow-x: auto;
  padding-bottom: 6px;
  mask-image: linear-gradient(to right, black 90%, transparent 100%);
}

.help-tab {
  padding: 8px 18px;
  background: var(--gray);
  border: none;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-light);
}



.help-tab:hover {
  background: var(--gray-dark);
  color: var(--text);
}

.help-tab.active {
  background: var(--main);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 86, 48, 0.2);
}

.help-content-area {
  min-height: 220px;
  background: rgba(var(--main-rgb), 0.04);
  padding: 24px;
  border-radius: 18px;
  border: 1px solid rgba(var(--main-rgb), 0.08);
}

#help-list {
  padding-left: 1.2rem;
  list-style: none;
}

#help-list li {
  position: relative;
  margin-bottom: 12px;
  line-height: 1.6;
  font-size: 0.9rem;
  color: var(--text);
}

#help-list li::before {
  content: "•";
  position: absolute;
  left: -1.2rem;
  color: var(--main-light);
  font-weight: bold;
}