/* Organoisette – GTD organizer, Nirvana-like layout */
:root {
  --bg: #f5f5f5;
  --surface: #fff;
  --border: #e0e0e0;
  --border-muted: rgba(0, 0, 0, 0.06);
  --text: #1a1a1a;
  --text-muted: #666;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --header-bg: #2563eb;
  --header-text: #fff;
  --nav-width: 260px;
  --header-height: 52px;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --bg-hover: rgba(0, 0, 0, 0.03);
  --accent: rgba(37, 99, 235, 0.08);
  --error: #b91c1c;
  --error-bg: #fee2e2;
}

html.theme-dark {
  --bg: #1a1a1a;
  --surface: #2d2d2d;
  --border: #404040;
  --border-muted: rgba(255, 255, 255, 0.08);
  --text: #e5e5e5;
  --text-muted: #a3a3a3;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --header-bg: #2a2a2a;
  --header-text: #fafafa;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --accent: rgba(59, 130, 246, 0.15);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.15);
  --input-bg: #252525;
  --input-color: #e5e5e5;
}

/* Dark: area manager buttons – ensure readable text */
html.theme-dark .area-manager-list .area-manager-actions button,
html.theme-dark .area-manager-list .area-manager-name,
html.theme-dark .area-manager-list .area-manager-status-select {
  color: var(--text);
}
html.theme-dark .area-manager-list .area-manager-actions button:hover {
  color: var(--text);
}
html.theme-dark .modal .form-actions button:not(.primary) {
  color: var(--text);
}

/* Dark: inputs/selects/textareas – darker gray, pale text */
html.theme-dark input,
html.theme-dark select,
html.theme-dark textarea {
  background: var(--input-bg);
  color: var(--input-color);
  border-color: var(--border);
}
html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder {
  color: var(--text-muted);
}

* {
  box-sizing: border-box;
}

/* Any element with .hidden is not displayed */
.hidden { display: none !important; }

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100%;
}

/* When app is visible: no page scroll, only main content scrolls – avoids gray gap below nav */
body:has(#app-screen:not(.hidden)) {
  overflow: hidden;
}

/* ----- Auth screen ----- */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
#auth-screen.hidden { display: none; }

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.auth-card h1 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  color: var(--text);
}
.auth-card .tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.auth-card .tabs button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}
.auth-card .tabs button.active {
  background: var(--primary);
  color: var(--header-text);
  border-color: var(--primary);
}
.auth-card form label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  color: var(--text-muted);
}
.auth-card form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.auth-card form button[type="submit"] {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--primary);
  color: var(--header-text);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.auth-card form button[type="submit"]:hover {
  background: var(--primary-hover);
}
.auth-card .error {
  color: var(--error);
  font-size: 13px;
  margin-bottom: 1rem;
}
.auth-card .panel { display: none; }
.auth-card .panel.active { display: block; }
.auth-footer-links { margin: 1rem 0 0; font-size: 0.8125rem; text-align: center; }
.auth-footer-links a { color: var(--text-muted); text-decoration: none; }
.auth-footer-links a:hover { text-decoration: underline; color: var(--text); }
.auth-footer-sep { color: var(--text-muted); pointer-events: none; }

.auth-google-wrap { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.auth-google-divider { text-align: center; margin: 0 0 0.75rem; font-size: 0.8125rem; color: var(--text-muted); }
.auth-google-divider span { background: var(--surface); padding: 0 0.5rem; }
.auth-google-btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; padding: 0.6rem 1rem; margin-bottom: 0.5rem; font-size: 0.9375rem; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.auth-google-btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.auth-google-hint { margin: 0; font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

/* ----- App layout ----- */
#app-screen {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: var(--header-height);
}
#app-screen.hidden { display: none; }

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  color: var(--header-text);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 100;
  box-shadow: var(--shadow);
}
.app-header .header-left {
  width: calc(32px + var(--nav-width) - 1rem);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.app-header .logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.app-header .logo-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  object-fit: contain;
}
.app-header .logo {
  font-weight: 700;
  font-size: 1.1rem;
}
.app-header .spacer { flex: 1; }
.app-header .btn-header {
  padding: 0.4rem 0.75rem;
  background: rgba(255,255,255,0.2);
  color: var(--header-text);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.app-header .btn-header:hover {
  background: rgba(255,255,255,0.3);
}
.app-header .new-item-btn {
  background: rgba(255,255,255,0.95);
  color: var(--primary);
  font-weight: 500;
}
.app-header .new-item-btn:hover {
  background: var(--surface);
}

/* Header profile pill + dropdown */
.header-profile-wrap {
  position: relative;
}
.header-profile-pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.25);
  color: var(--header-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}
.header-profile-pill:hover {
  background: rgba(255,255,255,0.35);
}
.header-profile-initials {
  line-height: 1;
}
.header-profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.header-profile-avatar.hidden { display: none; }
.header-profile-initials.hidden { display: none; }

.profile-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 6px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 0.35rem 0;
  z-index: 101;
}
.profile-menu.hidden { display: none; }
.profile-menu-user {
  padding: 0.6rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.2rem;
}
.profile-menu-user-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}
.profile-menu-user-email {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 0.15rem;
  word-break: break-all;
}
.profile-menu-user-email.hidden { display: none; }
.profile-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.profile-menu-item:hover { background: var(--bg); }
.profile-menu-item kbd {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
}
.profile-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0;
}
.profile-menu-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem 0.2rem;
}

.area-filter-wrap {
  position: relative;
  display: inline-block;
}
.area-filter-wrap .filter-menu {
  z-index: 100;
}
.btn-area-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.area-dropdown-btn-visual {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.area-dropdown-btn-visual .area-dropdown-icon.area-icon-svg-wrap .area-icon-svg svg {
  width: 0.95em;
  height: 0.95em;
}
.area-dropdown-btn-visual .area-dropdown-icon {
  color: inherit;
  opacity: 0.9;
}

.search-input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 200px;
  margin-right: 0.5rem;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.app-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* ----- View mode tabs (vertical, left of nav) ----- */
.view-tabs {
  width: 32px;
  flex-shrink: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.5rem 0;
  gap: 0.75rem;
}
.view-tab {
  padding: 0.5rem 0.15rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(-180deg);
  letter-spacing: 0.02em;
  border-radius: 4px;
  margin: 0 2px;
}
.view-tab:hover {
  color: var(--text);
  background: var(--bg);
}
.view-tab.active {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}
.view-tab.view-tab-icon {
  margin-top: auto;
  writing-mode: horizontal-tb;
  transform: none;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.view-tab.view-tab-icon + .view-tab.view-tab-icon {
  margin-top: -0.65rem;
}
.view-tab.view-tab-icon .icon-gear,
.view-tab.view-tab-icon .icon-logout,
.view-tab.view-tab-icon .icon-moon,
.view-tab.view-tab-icon .icon-sun {
  display: block;
}
.view-tab.view-tab-icon .icon-moon.hidden,
.view-tab.view-tab-icon .icon-sun.hidden {
  display: none;
}

/* ----- Left nav ----- */
.app-nav {
  width: var(--nav-width);
  flex-shrink: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.75rem 0;
}
.app-nav .nav-section {
  border-top: 1px solid var(--border-muted, rgba(0, 0, 0, 0.06));
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}
.app-nav .nav-section:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.app-nav.hidden {
  display: none !important;
}
#nav-project.hidden,
#nav-goals.hidden,
#nav-reference.hidden {
  display: none !important;
}
.app-nav #nav-clarify-section.hidden {
  display: none;
}
.app-nav section {
  margin-bottom: 1rem;
}
.app-nav .section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0 1rem 0.35rem;
}
.app-nav .section-title-row .section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0;
}
.app-nav .btn-context-manager {
  padding: 0.25rem 0.4rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1;
}
.app-nav .btn-context-manager:hover {
  background: var(--bg);
  color: var(--text);
}
.app-nav .section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 1rem 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.app-nav .section-title .nav-add-project {
  margin-left: auto;
  padding: 0.15rem 0.4rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
}
.app-nav .section-title .nav-add-project:hover {
  background: var(--bg);
  color: var(--text);
}
.app-nav .section-title .nav-projects-list-btn,
.app-nav .section-title .nav-projects-expand-toggle {
  padding: 0.2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-nav .section-title .nav-projects-list-btn:hover,
.app-nav .section-title .nav-projects-expand-toggle:hover {
  background: var(--bg);
  color: var(--text);
}
.app-nav .section-title .icon-list-small {
  display: block;
}
.app-nav .section-title .nav-projects-expand-icon {
  font-size: 0.65em;
  line-height: 1;
}
.app-nav .section-title-link {
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-align: left;
}
.app-nav .section-title-link:hover {
  color: var(--text);
}
.app-nav .section-title-link.active {
  color: var(--primary);
}
.app-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-size: 14px;
  text-align: left;
  font-family: inherit;
}
.app-nav .nav-item:hover {
  background: var(--bg);
}
.app-nav .nav-item.active {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  font-weight: 500;
}
.app-nav .nav-item .count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}
.app-nav .nav-item .count-clarify,
.app-nav #nav-clarify-page .count-clarify {
  color: #c45c5c;
}
html.theme-dark .app-nav .nav-item .count-clarify,
html.theme-dark .app-nav #nav-clarify-page .count-clarify {
  color: #e08a8a;
}
.app-nav #nav-clarify-page {
  display: flex;
  align-items: center;
  width: 100%;
}
.app-nav #nav-clarify-page .nav-item-label {
  flex: 0 0 auto;
}
.app-nav #nav-clarify-page .count-clarify {
  margin-left: auto;
  font-size: 12px;
}
.app-nav .project-item {
  padding-left: 1rem;
}
.app-nav .project-disclosure {
  flex-shrink: 0;
  width: 1rem;
  margin-right: 0.05rem;
  color: var(--text-muted);
  font-size: 0.65em;
  cursor: pointer;
  text-align: center;
  line-height: 1;
  user-select: none;
}
.app-nav .project-disclosure:hover {
  color: var(--text);
}
.app-nav .project-bullet {
  flex-shrink: 0;
  width: 1rem;
  margin-right: 0.05rem;
  color: var(--text-muted);
  font-size: 1.15em;
  text-align: center;
  line-height: 1;
  user-select: none;
}
.app-nav .project-children {
  border-left: 1px solid var(--border);
  padding-left: 0.2rem;
}
/* margin-left so the vertical line aligns with parent's disclosure triangle */
.app-nav #nav-projects > .project-children {
  margin-left: 1.35rem;
}
.app-nav .project-children .project-children {
  margin-left: 1.35rem;
}
.app-nav .project-children .project-children .project-children {
  margin-left: 1.9rem;
}
.app-nav .project-children .project-children .project-children .project-children {
  margin-left: 2.45rem;
}
.app-nav .project-children.collapsed {
  display: none;
}
.app-nav .nav-item.project-item.nav-project-indent {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}
.app-nav .nav-item.nav-project-indent.nav-project-level-1 {
  padding-left: 1rem;
}
.app-nav .nav-item.nav-project-indent.nav-project-level-2 {
  padding-left: 1.55rem;
}
.app-nav .nav-item.nav-project-indent.nav-project-level-3 {
  padding-left: 2.1rem;
}
.app-nav .nav-item.nav-project-indent.nav-project-level-4 {
  padding-left: 2.65rem;
}
.app-nav .nav-item.nav-project-dragging {
  opacity: 0.6;
}
.app-nav .nav-projects-header.drag-over,
.app-nav #nav-projects-root-drop.drag-over {
  background: var(--bg);
  border-radius: var(--radius);
}
.app-nav .nav-root-drop {
  min-height: 0.5rem;
  margin: 2px 0;
  border-radius: var(--radius);
  transition: min-height 0.15s ease, background 0.15s ease;
}
.app-nav .nav-root-drop.drag-over {
  min-height: 1.5rem;
  background: var(--bg);
}
.app-nav .nav-insert-between {
  min-height: 2px;
  margin: 0 2px;
  border-radius: 2px;
  transition: min-height 0.15s ease, background 0.15s ease;
}
.app-nav #nav-projects .nav-insert-between {
  min-height: 1px;
  margin: 0 1px 0 2px;
}
.app-nav .nav-insert-between.drag-over {
  min-height: 0.75rem;
  background: var(--accent);
  opacity: 0.5;
}

/* ----- Clarify page ----- */
.view-clarify {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0;
}
.clarify-progress-wrap {
  margin-bottom: 2rem;
}
.clarify-progress-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.clarify-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.clarify-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.25s ease;
}
.clarify-progress-goal {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0;
}
.clarify-current-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.clarify-item-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}
.clarify-item-title {
  width: 100%;
  min-height: 120px;
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1.5rem;
  resize: vertical;
  font-family: inherit;
}
.clarify-item-title:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
.clarify-steps {
  margin-bottom: 1.5rem;
}
.clarify-step-question {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text);
}
.clarify-step-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.clarify-step-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}
.clarify-step-btn:hover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.06);
}
.clarify-step-btn.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
}
.clarify-step-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}
.clarify-step-hint kbd {
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.clarify-step-no-wrap.hidden,
.clarify-step-twomin-wrap.hidden,
.clarify-step-choose-wrap.hidden,
.clarify-step-defer-wrap.hidden {
  display: none;
}
.clarify-actions {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}
.clarify-actions .btn-clarify-done {
  padding: 0.6rem 1.25rem;
  font-size: 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  background: var(--primary);
  color: var(--header-text);
}
.clarify-actions .btn-clarify-done:hover {
  background: var(--primary-hover);
}
.clarify-actions .btn-clarify-done:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.clarify-actions .btn-clarify-done:disabled:hover {
  background: var(--primary);
}
.clarify-current-wrap.hidden,
.clarify-empty.hidden {
  display: none;
}
.clarify-empty {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.clarify-empty-message {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 0;
}

/* ----- Projects page (main content) ----- */
.view-projects {
  padding: 0;
  max-width: 52rem;
}
.projects-tree {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.projects-tree .nav-root-drop,
.projects-tree .nav-insert-between {
  min-height: 0.25rem;
  margin: 0 0 0.25rem;
  border-radius: 2px;
}
.projects-tree .nav-insert-between.drag-over {
  min-height: 0.5rem;
  background: var(--accent);
  opacity: 0.35;
  margin: 0 0 0.35rem;
}
/* Project rows: card style like task list items */
.project-tree-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  transition: border-left-color 0.15s ease, background 0.15s ease;
}
.project-tree-row:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.03));
}
.project-tree-row.drag-over {
  border-left-color: var(--primary);
  background: rgba(37, 99, 235, 0.06);
}
/* Root level: no hierarchy indicator */
.project-tree-row.project-tree-level-0 {
  padding-left: 1rem;
}
/* Sub-projects: visible indent + left bar for hierarchy */
.project-tree-row.project-tree-level-1 {
  margin-left: 1rem;
  border-left-color: rgba(37, 99, 235, 0.35);
  padding-left: 1rem;
}
.project-tree-row.project-tree-level-2 {
  margin-left: 2rem;
  border-left-color: rgba(37, 99, 235, 0.28);
  padding-left: 1rem;
}
.project-tree-row.project-tree-level-3 {
  margin-left: 3rem;
  border-left-color: rgba(37, 99, 235, 0.2);
  padding-left: 1rem;
}
.project-tree-row.project-tree-level-4 {
  margin-left: 4rem;
  border-left-color: rgba(37, 99, 235, 0.15);
  padding-left: 1rem;
}
.project-tree-name {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-tree-meta {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-tree-actions {
  display: flex;
  gap: 0.25rem;
}
.project-tree-action {
  padding: 0.25rem 0.5rem;
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  border-radius: 3px;
}
.project-tree-action:hover {
  color: var(--primary);
  background: var(--bg);
}
.project-tree-row.project-tree-dragging {
  opacity: 0.55;
}

/* Projects tab: subview containers */
.projects-subview {
  padding-top: 0.5rem;
}
.projects-subview.hidden {
  display: none !important;
}
.projects-view-title-row .btn-new-item { margin-left: auto; }
.projects-list-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}
#projects-list-tree-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 52rem;
}
#projects-list #projects-list-tree-wrap .nav-root-drop,
#projects-list #projects-list-tree-wrap .nav-insert-between {
  min-height: 0.25rem;
  margin: 0 0 0.25rem;
  border-radius: 2px;
}
#projects-list #projects-list-tree-wrap .nav-insert-between.drag-over {
  min-height: 0.5rem;
  background: var(--accent);
  opacity: 0.35;
  margin: 0 0 0.35rem;
}

/* Projects dashboard (overview) */
.projects-dashboard-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
}
.projects-strip-item strong {
  color: var(--text);
  margin-right: 0.25rem;
}
.projects-strip-overdue strong { color: var(--danger, #dc2626); }
.projects-strip-warning strong { color: var(--warning, #ca8a04); }
.projects-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1rem;
}
.projects-dashboard-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.projects-dashboard-card:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.03));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.projects-card-header { display: flex; flex-direction: column; gap: 0.25rem; }
.projects-card-name { font-weight: 600; color: var(--text); font-size: 0.9375rem; }
.projects-card-meta { font-size: 0.75rem; color: var(--text-muted); }
.projects-card-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.projects-card-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.2s ease;
}
.projects-card-list-summary { font-size: 0.75rem; color: var(--text-muted); }
.projects-card-actions { margin-top: 0.25rem; }
.project-card-open-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}
.project-card-open-btn:hover {
  background: var(--primary);
  color: var(--primary-inverse, #fff);
}

/* Projects dashboard charts */
.projects-dashboard-charts {
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.projects-dashboard-chart-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
}
.dashboard-filters-label { font-size: 0.875rem; color: var(--text-muted); }
.dashboard-filter-select,
.dashboard-filter-input {
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
.dashboard-filter-input { min-width: 10rem; }
.projects-chart-card { min-height: 120px; }
.projects-chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.75rem;
}
.projects-pie-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}
.projects-pie {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  flex-shrink: 0;
}
.projects-pie-legend {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  max-height: 180px;
  gap: 0.25rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.projects-pie-legend-item { display: flex; align-items: center; gap: 0.35rem; }
.projects-pie-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.projects-noproject-wrap { display: flex; flex-direction: column; gap: 0.35rem; }
.projects-noproject-row {
  display: grid;
  grid-template-columns: 6rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
}
.projects-noproject-label { color: var(--text); }
.projects-noproject-bar-wrap {
  height: 1.25rem;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.projects-noproject-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.2s ease;
  min-width: 2px;
}
.projects-noproject-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.projects-chart-empty { font-size: 0.8125rem; color: var(--text-muted); margin: 0; }

/* Projects kanban */
.projects-kanban {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  align-items: flex-start;
}
.projects-kanban-column {
  flex: 0 0 280px;
  min-width: 280px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  transition: background 0.15s ease;
}
.projects-kanban-column.drag-over {
  background: rgba(37, 99, 235, 0.08);
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}
.projects-kanban-column-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.projects-kanban-cards {
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.projects-kanban-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.75rem;
  border: 1px solid var(--border);
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: box-shadow 0.15s ease;
}
.projects-kanban-card:hover { box-shadow: var(--shadow); }
.projects-kanban-card:active { cursor: grabbing; }
.projects-kanban-card.kanban-card-dragging {
  opacity: 0.7;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.projects-kanban-card-name { font-weight: 500; font-size: 0.875rem; color: var(--text); }
.projects-kanban-card-due { font-size: 0.75rem; color: var(--text-muted); }
.projects-kanban-card-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.projects-kanban-card-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
}
.projects-kanban-card-open {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  align-self: flex-start;
  margin-top: 0.25rem;
}
.projects-kanban-card-open:hover { text-decoration: underline; }

/* ----- Main content ----- */
.app-main #view-tasks.hidden,
.app-main #view-projects.hidden,
.app-main #view-clarify.hidden {
  display: none;
}
.app-main #main-gtd.hidden,
.app-main #main-project.hidden,
.app-main #main-goals.hidden,
.app-main #main-reference.hidden {
  display: none;
}
#ref-items-panel.hidden,
#ref-collections-page.hidden,
#ref-rules-page.hidden {
  display: none !important;
}
.app-main .main-project-view,
.app-main .main-goals-view {
  padding-top: 0.5rem;
}
.app-main .main-project-view .view-subtitle,
.app-main .main-goals-view .view-subtitle {
  margin-top: 0.25rem;
}
.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 1rem 1.5rem;
  overflow-y: auto;
  background: var(--bg);
}
.app-main .view-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.app-main .view-title-row-spacer {
  flex: 1;
  min-width: 0.5rem;
}
.app-main .view-title-row .title-row-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-left: auto;
}
.app-main .view-title-row .title-row-right .search-input { margin-right: 0; }
.app-main .view-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.app-main .btn-new-item-wrap {
  flex-shrink: 0;
  position: relative;
  display: inline-flex;
  align-items: stretch;
}
.app-main .btn-new-item-wrap.hidden {
  display: none;
}
.app-main .btn-new-item {
  padding: 0.4rem 0.75rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
}
.app-main .btn-new-item-main {
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}
.app-main .btn-new-item-dropdown {
  border-radius: 0 var(--radius) var(--radius) 0;
  padding-left: 0.35rem;
  padding-right: 0.5rem;
}
.app-main .btn-new-item:hover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
}
.app-main .btn-new-item-main:hover { border-right: none; }
.app-main .new-item-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 2px;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 0.35rem 0;
  z-index: 50;
}
.app-main .new-item-menu.hidden { display: none; }
.app-main .new-item-menu-caption {
  font-size: 11px;
  font-style: italic;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem 0.2rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
}
.app-main .new-item-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.app-main .new-item-menu-item:hover { background: var(--bg); }
.app-main .new-item-menu-item kbd {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
  margin-left: 0.5rem;
}
.app-main .new-item-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0;
}
.app-main .view-title-row .search-input {
  flex-shrink: 0;
  width: 200px;
  margin-left: 0;
}
.app-main .view-title-row .search-input.hidden { display: none; }
.app-main .btn-edit-project {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}
.app-main .btn-edit-project:hover {
  color: var(--primary);
  border-color: var(--primary);
}
.app-main .btn-edit-project.hidden {
  display: none;
}
.app-main .view-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.next-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.next-filters.hidden { display: none; }
.filter-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.filter-btn:hover { background: var(--bg); }
.filter-btn.active { border-color: var(--primary); color: var(--primary); }
.filter-dropdown-wrap { position: relative; }
.filter-menu {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 2px;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 0.35rem 0;
  z-index: 20;
}
.filter-menu.hidden { display: none; }
.filter-menu-caption {
  font-size: 11px;
  font-style: italic;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem 0.2rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
}
.filter-menu-item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.filter-menu-item:hover { background: var(--bg); }
.filter-menu-item.checked::before { content: '✓ '; font-weight: bold; }

/* Area menu: subtle shortcut hint on the right */
.filter-menu-item-with-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.filter-menu-item-with-shortcut .filter-menu-item-label {
  flex: 1;
  min-width: 0;
}

/* Area dropdown: check column, then icon+dot next to text, labels aligned */
.area-dropdown-item {
  display: grid;
  grid-template-columns: 1.25em 2.5em 1fr auto;
  gap: 0.5rem;
  align-items: center;
}
.area-dropdown-item.checked::before {
  content: none;
}
.area-dropdown-item .area-dropdown-check {
  grid-column: 1;
  text-align: center;
  font-weight: bold;
  color: var(--text);
}
.area-dropdown-item .area-dropdown-visual {
  grid-column: 2;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.area-dropdown-item .filter-menu-item-label {
  grid-column: 3;
  flex: none;
  min-width: 0;
}
.area-dropdown-item .area-menu-shortcut {
  grid-column: 4;
}
.area-dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0;
}
#area-dropdown-manager .filter-menu-item-label {
  grid-column: 2 / 4;
  text-align: center;
}
.area-dropdown-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.area-dropdown-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.area-dropdown-icon.area-icon-svg-wrap .area-icon-svg svg {
  width: 1em;
  height: 1em;
}
.area-dropdown-icon-spacer {
  width: 1em;
  min-width: 1em;
  flex-shrink: 0;
}
.area-menu-shortcut {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: normal;
  letter-spacing: 0.02em;
}

.view-toolbar {
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: flex-end;
}
.view-mode-toggle {
  display: inline-flex;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.view-mode-btn {
  padding: 0.35rem 0.65rem;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  min-width: 36px;
}
.view-mode-btn:hover {
  background: var(--bg);
  color: var(--text);
}
.view-mode-btn.active {
  background: var(--primary);
  color: var(--header-text);
}
.view-mode-btn + .view-mode-btn {
  border-left: 1px solid var(--border);
}
.app-main .task-section {
  margin-bottom: 1.5rem;
}
.app-main .task-section-done .task-section-title { color: var(--text-muted); }
.app-main .task-section-done .task-list li { opacity: 0.9; }
.app-main .task-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.app-main .task-section-title.hidden {
  display: none;
  margin: 0;
}
.app-main #section-done.hidden,
.app-main #section-active.hidden { display: none; }
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.task-list li {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: default;
}
/* Task row: clear column layout [handle][check][star] [content] [area] [actions] */
.task-list li[data-task-id] {
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto auto;
  gap: 0 0.75rem;
  direction: ltr;
}
.task-list li[data-task-id] .task-drag-handle { grid-column: 1; grid-row: 1; }
.task-list li[data-task-id] .task-check { grid-column: 2; grid-row: 1; }
.task-list li[data-task-id] .task-star { grid-column: 3; grid-row: 1; }
.task-list li[data-task-id] .task-body-first { grid-column: 4; grid-row: 1; min-width: 0; }
.task-list li[data-task-id] .task-body-tags-row { grid-column: 4 / 6; grid-row: 2; min-width: 0; width: 100%; display: flex; justify-content: flex-end; align-items: center; }
.task-list li[data-task-id] .task-body-rest { grid-column: 4; grid-row: 3; min-width: 0; }
.task-list li[data-task-id] .task-area-badge { grid-column: 5; grid-row: 1; align-self: start; }
.task-list li[data-task-id] .task-actions.task-row-actions { grid-column: 6; grid-row: 1; }

/* Line 1: sub-grid so title has its own column and stays left */
.task-list li[data-task-id] .task-body-first .task-body-line1 {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}
.task-list li[data-task-id] .task-body-first .task-body-line1 .task-due-badge { grid-column: 1; }
.task-list li[data-task-id] .task-body-first .task-body-line1 .task-title { grid-column: 2; text-align: left; justify-self: start; }
.task-list li[data-task-id] .task-body-first .task-body-line1 .task-list-ref-icons { grid-column: 3; }
.task-list li[data-task-id] .task-body-first .task-body-line1 .task-meta { grid-column: 4; justify-self: end; }
.task-list li.dragging { opacity: 0.5; }
.task-list li.drag-over { border-color: var(--primary); background: rgba(37, 99, 235, 0.06); }
.task-list li.drop-placeholder {
  list-style: none;
  margin: 0.25rem 0;
  padding: 0;
  min-height: 44px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: rgba(37, 99, 235, 0.06);
  opacity: 1;
  pointer-events: none;
  flex-shrink: 0;
  box-sizing: border-box;
}
.task-list li.keyboard-selected { border-color: var(--primary); background: rgba(37, 99, 235, 0.08); }
.task-drag-handle {
  flex-shrink: 0;
  width: 20px;
  margin-top: 2px;
  cursor: grab;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  border: none;
  background: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.task-list li:active .task-drag-handle { cursor: grabbing; }
.task-drag-handle:hover { color: var(--text); }
.task-drag-handle::before { content: '⋮⋮'; letter-spacing: -2px; }
.task-list .task-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
.task-list .task-check.done {
  background: var(--primary);
  border-color: var(--primary);
}
.task-star {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}
.task-star:hover { color: #f59e0b; }
.task-star.starred { color: #f59e0b; }
.task-list .task-body { flex: 1; min-width: 0; text-align: left; }
.task-list .task-area-badge {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  align-self: flex-start;
  padding: 0.15rem 0.4rem;
  padding-left: 0.6rem;
  margin-left: 0.15rem;
  border-radius: 4px;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-left: 1px solid var(--border);
}
.task-list .task-area-badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}
.task-list .task-area-badge-icon.area-icon-svg-wrap .area-icon-svg svg {
  width: 14px;
  height: 14px;
}
.task-list .task-area-badge-name {
  line-height: 1;
}

/* View mode: compact = single line (title + meta on same line) */
.task-list li.task-view-compact .task-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.task-list .task-body-line1 {
  min-width: 0;
}
.task-list li.task-view-compact .task-body-line1 {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.task-list li.task-view-compact .task-title {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-list li.task-view-compact .task-meta { flex-shrink: 0; min-width: 0; }
.task-list li.task-view-compact .task-body-tags-row { display: none; }
.task-list li.task-view-compact .task-list-ref-icons { flex-shrink: 0; }
.task-list li.task-view-compact .task-notes-preview,
.task-list li.task-view-compact .task-checklist { display: none; }

/* View mode: medium = title + first line of notes */
.task-list li.task-view-medium .task-body { display: flex; flex-direction: column; align-items: stretch; }
.task-list li.task-view-medium .task-body-line1 { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.task-list li[data-task-id].task-view-medium .task-body-first .task-body-line1 { display: grid; }
.task-list li.task-view-medium .task-title { margin-bottom: 0; flex: 1; min-width: 0; }
.task-list li.task-view-medium .task-meta { flex-shrink: 0; }
.task-list li.task-view-medium .task-notes-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 0.25rem;
  padding-left: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-list li.task-view-medium .task-notes-preview.empty { display: none; }
.task-list li.task-view-medium .task-checklist { display: none; }

/* View mode: full = title + meta on first line, then full notes + checklist */
.task-list li.task-view-full .task-body { display: flex; flex-direction: column; align-items: stretch; }
.task-list li.task-view-full .task-body-line1 { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.task-list li[data-task-id].task-view-full .task-body-first .task-body-line1 { display: grid; }
.task-list li.task-view-full .task-title { margin-bottom: 0; flex: 1; min-width: 0; }
.task-list li.task-view-full .task-meta { flex-shrink: 0; }
.task-list li.task-view-full .task-notes-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 0.35rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.task-list li.task-view-full .task-notes-preview.empty { display: none; }

.task-list .task-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
  text-align: left !important;
  flex: 1;
  min-width: 0;
}
.task-list .task-due-badge {
  flex-shrink: 0;
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--border);
  color: var(--text);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  margin-right: 0.5rem;
}
.task-list .task-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  min-width: 5rem;
}

/* Ref icons in task list: right of title, clickable, tooltip = ref title */
.task-list-ref-icons {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.35rem;
  margin-right: 1.25rem;
}
.task-list-ref-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-muted);
  box-shadow: 0 0 0 1px var(--border);
}
.task-list-ref-icon:hover {
  color: var(--primary);
  background: var(--bg-hover);
  box-shadow: 0 0 0 1px var(--primary);
}
.task-list-ref-icon img {
  width: 16px;
  height: 16px;
  display: block;
  object-fit: contain;
  filter: brightness(0) opacity(0.75);
}
.task-list-ref-icon:hover img {
  filter: brightness(0) opacity(1);
}
/* Favicons: show in color (no filter) */
.task-list-ref-icon img[src*='.ico'] {
  filter: none;
}
.task-list-ref-icon:hover img[src*='.ico'] {
  filter: none;
}
.theme-dark .task-list-ref-icon img {
  filter: brightness(0) invert(1) opacity(0.8);
}
.theme-dark .task-list-ref-icon:hover img {
  filter: brightness(0) invert(1);
}
.theme-dark .task-list-ref-icon img[src*='.ico'] {
  filter: invert(1);
}
.theme-dark .task-list-ref-icon:hover img[src*='.ico'] {
  filter: invert(1);
}

.task-list .task-body-tags-row {
  margin-top: 0.35rem;
  text-align: right;
  flex-shrink: 0;
}
.task-list .task-body-tags-row .task-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}
.task-list .task-tags span {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: var(--bg);
  border-radius: 4px;
  font-size: 11px;
}
.task-list .task-body-tags-row .task-tags span {
  margin-right: 0;
}
.task-list .task-meta .task-tags span {
  margin-right: 0.25rem;
}
.task-list .task-checklist {
  margin-top: 0.5rem;
  margin-left: -0.4rem;
  padding-left: 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-muted);
}
.task-list .task-checklist li {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0;
  background: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.task-list .task-checklist-from-notes .task-checklist-check {
  flex-shrink: 0;
  width: auto;
  min-width: 1.15em;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.15em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.task-list .task-checklist-from-notes .task-checklist-check:hover {
  color: var(--primary);
}
.task-list .task-checklist-from-notes .task-checklist-label {
  flex: 1;
  min-width: 0;
  align-self: center;
  line-height: 1.4;
}
.task-list .task-checklist-from-notes li.done .task-checklist-label {
  text-decoration: line-through;
  color: var(--text-muted);
}
.task-list .task-checklist:not(.task-checklist-from-notes) li.done {
  text-decoration: line-through;
}
.task-list .task-notes-text {
  white-space: pre-wrap;
  margin-bottom: 0.35rem;
}
.task-list .task-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.25rem;
}
.task-list .task-actions button {
  padding: 0.25rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 4px;
}
.task-list .task-actions button:hover {
  background: var(--bg);
  color: var(--text);
}
.task-list .task-actions .btn-restore {
  color: var(--primary);
  font-size: 0.85rem;
}
.task-list .task-actions .btn-restore:hover {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary-hover);
}
.task-list .task-actions .btn-delete-permanent {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.task-list .task-actions .btn-delete-permanent:hover {
  background: rgba(200, 50, 50, 0.1);
  color: var(--error);
}
.task-list .task-meta .task-deleted-at {
  color: var(--text-muted);
  font-size: 0.85em;
}
.task-list .task-row-actions {
  position: relative;
}
.task-list .task-row-menu-trigger {
  padding: 0.25rem 0.4rem;
  font-size: 1.1rem;
  line-height: 1;
}
.task-list .task-row-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 2px;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
  padding: 0.25rem 0;
}
.task-list .task-row-menu.hidden {
  display: none;
}
.task-list .task-row-menu [role="menuitem"] {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}
.task-list .task-row-menu [role="menuitem"]:hover {
  background: var(--bg);
}
.task-list .task-row-menu [role="menuitem"].menu-checked {
  font-weight: 600;
  color: var(--primary);
}
.app-nav .nav-item.nav-drop.drag-over {
  background: rgba(37, 99, 235, 0.2);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}
.app-nav .nav-item[data-droppable="project"].drag-over {
  background: rgba(37, 99, 235, 0.2);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

/* Context menu */
.context-menu {
  position: fixed;
  z-index: 300;
  min-width: 200px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  padding: 0.35rem 0;
  border: 1px solid var(--border);
}
.context-menu.hidden { display: none; }
.context-menu-task-title {
  padding: 0.4rem 0.75rem;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.context-menu-item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: none;
  background: none;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.context-menu-item:hover {
  background: var(--bg);
}
.context-menu-subtitle {
  font-weight: 600;
  color: var(--text-muted);
  cursor: default;
}
.context-menu-sub .context-menu-item { padding-left: 1.25rem; }
.context-menu-sub .context-menu-subtitle:hover { background: none; }
.context-menu-time-wrap { position: relative; }
.context-menu-has-sub::after {
  content: '◀';
  margin-left: auto;
  font-size: 10px;
  opacity: 0.7;
}
.context-submenu {
  position: absolute;
  right: 100%;
  top: 0;
  margin-right: 2px;
  min-width: 160px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  padding: 0.35rem 0;
  border: 1px solid var(--border);
}
.context-submenu.hidden { display: none; }
.context-submenu .context-menu-item { padding: 0.4rem 0.75rem; }
.context-submenu .context-menu-item.context-menu-checked::before {
  content: '✓ ';
  font-weight: bold;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 3rem 1rem;
}
.empty-state.hidden {
  display: none;
}

/* ----- Modals / forms ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-confirm .confirm-message {
  margin: 0 0 1.25rem;
  color: var(--text);
  line-height: 1.45;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}
.modal-task-detail {
  max-width: 900px;
  padding: 0;
}
.modal-task-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  min-height: 380px;
}
.modal-task-left {
  flex: 1;
  min-width: 420px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.modal-task-header {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.modal-task-title-input {
  flex: 1;
  font-size: 1.25rem;
  font-weight: 500;
  padding: 0.6rem 0;
  margin-bottom: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  min-height: 2.5rem;
}
.modal-task-title-input:focus {
  outline: none;
  border-bottom-color: var(--primary);
}
.modal-task-star {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
  padding: 0;
}
.modal-task-star:hover,
.modal-task-star.starred { color: #f59e0b; }
.task-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.5rem 0.35rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.task-tags-wrap:focus-within {
  border-bottom-color: var(--primary);
}
.task-tags-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.task-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.35rem 0.2rem 0.5rem;
  font-size: 13px;
  border-radius: 999px;
  background: var(--bg-hover, rgba(0,0,0,0.06));
  color: var(--text);
  border: 1px solid var(--border);
}
.task-tag-pill .task-tag-pill-remove {
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  border-radius: 2px;
}
.task-tag-pill .task-tag-pill-remove:hover {
  color: var(--text);
}
.task-tags-input.modal-task-tags {
  flex: 1;
  min-width: 80px;
  margin: 0;
  padding: 0.25rem 0;
  border: none;
  font-size: 14px;
}
.task-tags-input.modal-task-tags:focus {
  outline: none;
}
.task-tags-dropdown-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1;
}
.task-tags-dropdown-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.task-tags-wrap {
  position: relative;
}
.task-tags-autocomplete {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 50;
  padding: 0.25rem 0;
}
.task-tags-autocomplete.hidden {
  display: none;
}
.task-tags-autocomplete [role="option"] {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  text-align: left;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.task-tags-autocomplete [role="option"]:hover,
.task-tags-autocomplete [role="option"].highlight {
  background: var(--bg-hover);
}
.modal-task-tags {
  margin-bottom: 0;
  font-size: 14px;
  padding: 0.5rem 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.modal-task-tags:focus {
  outline: none;
  border-bottom-color: var(--primary);
}
.modal-task-left textarea {
  min-height: 160px;
  padding: 0.75rem;
  font-size: 14px;
  resize: vertical;
}
.task-reference-block {
  margin-top: 0.75rem;
  padding: 0.5rem 0;
}
.task-reference-block.modal-task-right-ref {
  margin-top: 0;
  margin-bottom: 0.75rem;
  padding: 0;
}
#task-reference-block:not(.hidden) {
  display: block !important;
}
.task-reference-block.hidden { display: none !important; }
.task-ref-hint {
  margin: 0 0 0.5rem 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.task-ref-hint.hidden { display: none; }
.task-reference-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 13px;
}
.modal-task-right-ref .task-reference-value {
  margin-top: 0.25rem;
  margin-bottom: 0;
}
.task-ref-title {
  color: var(--text);
  font-weight: 500;
}
.task-view-ref-link {
  color: var(--primary);
  text-decoration: none;
}
.task-view-ref-link:hover { text-decoration: underline; }
.task-ref-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.task-ref-list-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 13px;
}
.task-ref-list-icon-wrap {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}
.task-ref-list-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: brightness(0);
}
.theme-dark .task-ref-list-icon {
  filter: brightness(0) invert(1);
}
.task-ref-list-icon-wrap img.task-ref-list-icon[src*='.ico'] {
  filter: none;
}
.theme-dark .task-ref-list-icon-wrap img.task-ref-list-icon[src*='.ico'] {
  filter: invert(1);
}
.task-ref-list-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 500;
}
.task-add-ref-btn {
  margin-top: 0.5rem;
  font-size: 13px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}
.task-ref-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.task-ref-actions .task-add-ref-btn {
  margin-top: 0;
}
.ref-item-for-task-notice {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--border);
  border-radius: var(--radius);
}
.ref-item-for-task-notice.hidden {
  display: none;
}
.task-add-ref-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.task-clear-ref-btn {
  font-size: 12px;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}
.task-clear-ref-btn:hover { color: var(--text); background: var(--bg-hover); }
.modal-task-right {
  width: 200px;
  flex-shrink: 0;
  padding: 1.5rem;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.modal-task-right label { margin-bottom: 0; }
.modal-task-right input,
.modal-task-right select {
  margin-bottom: 0.75rem;
}
.modal-meta-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 12px;
  font-weight: 600;
  text-transform: lowercase;
  color: var(--text-muted);
}
.modal-meta-icon { font-size: 14px; }
@media (max-width: 720px) {
  .modal-task-detail { max-width: 100%; }
  .modal-task-left { min-width: 100%; }
  .modal-task-form { flex-direction: column; }
  .modal-task-right {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.modal h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}
.modal label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 13px;
}
.modal input, .modal select, .modal textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}
.modal textarea {
  min-height: 100px;
  resize: vertical;
}
.modal .form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.modal .form-actions button {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
}
.modal .form-actions button.primary {
  background: var(--primary);
  color: var(--header-text);
  border-color: var(--primary);
}
.modal .form-actions button.primary:hover {
  background: var(--primary-hover);
}

/* Element Manager modal (Areas + Tags tabs) – larger size */
.modal.modal-element-manager {
  max-width: 720px;
  max-height: 90vh;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
}
.modal-element-manager h2 {
  font-size: 1.35rem;
}
.element-manager-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}
.element-manager-tab {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.element-manager-tab:hover {
  color: var(--text);
}
.element-manager-tab.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}
.element-manager-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.element-manager-panel.active {
  display: flex;
}
.modal-element-manager .area-manager-body,
.modal-element-manager .context-manager-body,
.modal-element-manager .team-manager-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.modal-area-manager-intro,
.modal-context-manager-intro,
.modal-team-manager-intro {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}
.team-manager-list-toolbar {
  margin-bottom: 0.75rem;
}
.team-manager-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
.team-manager-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.team-manager-item:last-child {
  border-bottom: none;
}
.team-manager-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}
.team-manager-role {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.team-manager-owner .team-manager-role {
  font-weight: 600;
  color: var(--primary);
}
.team-manager-empty {
  color: var(--text-muted);
  font-size: 0.9375rem;
  padding: 1rem 0;
}
.btn-team-remove {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-team-remove:hover {
  color: var(--danger, #b91c1c);
  border-color: var(--danger, #b91c1c);
}
.modal-invite-member .modal {
  max-width: 400px;
}
.modal-invite-member label {
  display: block;
  margin-bottom: 0.25rem;
}
.modal-invite-member input[type="email"] {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
}
.modal-invite-member .form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0;
}
.area-manager-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
  min-height: 320px;
  max-height: min(520px, 55vh);
  overflow-y: auto;
}
.area-manager-list-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}
.area-manager-list-toolbar .btn-add-area {
  padding: 0.4rem 0.75rem;
  font-size: 14px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
}

/* Modal: Add new area (popup from area manager) */
.modal.modal-area-new {
  max-width: 380px;
}
.modal-area-new label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.modal-area-new input {
  margin-bottom: 1rem;
}
.modal-area-new .area-new-color-label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.modal-area-new .area-new-color-picker {
  display: grid;
  grid-template-columns: repeat(5, 28px);
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.modal-area-new .area-new-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.modal-area-new .area-new-color-swatch:hover {
  border-color: var(--primary);
}
.modal-area-new .area-new-color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}
.modal-area-new .form-actions {
  margin-top: 0.5rem;
  margin-bottom: 0;
}
.area-manager-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}
.area-manager-list li:last-child {
  border-bottom: none;
}
.area-manager-list li.editing {
  padding: 0.5rem 1rem;
}
.area-manager-list .area-manager-visual {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}
.area-manager-list .area-manager-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface);
}
.area-manager-list .area-manager-color-swatch:hover {
  border-color: var(--primary);
}
.area-manager-list .area-manager-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.area-manager-list .area-manager-icon-btn:hover {
  border-color: var(--primary);
  background: var(--bg);
}
.area-manager-list .area-manager-icon-btn .area-icon-svg,
.area-manager-list .area-manager-icon-option .area-icon-svg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-muted);
}
.area-manager-list .area-manager-icon-btn .area-icon-svg svg,
.area-manager-list .area-manager-icon-option .area-icon-svg svg {
  width: 1.1em;
  height: 1.1em;
}
.area-manager-list .area-manager-icon-option .area-icon-svg {
  width: 100%;
  height: 100%;
}
.area-manager-list .area-manager-icon-option .area-icon-svg svg {
  width: 1.25em;
  height: 1.25em;
}
.area-manager-list .area-manager-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  border: none;
  background: transparent;
  padding: 0.3rem 0;
  outline: none;
}
.area-manager-list .area-manager-status {
  font-size: 13px;
  color: var(--text-muted);
  width: 120px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.area-manager-list .area-manager-status-readonly {
  font-style: italic;
  transform: translateY(2px);
  justify-content: flex-start;
  text-align: left;
}
.area-manager-list .area-manager-status-select {
  padding: 0.2rem 0.75rem;
  font-size: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  line-height: 1.2;
  transform: translateY(8px);
  width: 100%;
}
.area-manager-list .btn-area-default {
  font-size: 12px;
}
.area-manager-list .btn-area-default.is-default {
  font-weight: 600;
  color: var(--primary);
  border-color: var(--primary);
}
.area-manager-list li.editing .area-manager-name {
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  background: var(--surface);
}
.area-manager-list .area-manager-actions {
  display: flex;
  gap: 0.4rem;
  min-width: 11rem;
  flex-shrink: 0;
}
.area-manager-list .area-manager-actions button {
  padding: 0.35rem 0.6rem;
  font-size: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.area-manager-list .area-manager-actions .area-manager-icon-pencil,
.area-manager-list .area-manager-actions .area-manager-icon-delete,
.context-manager-list .context-manager-actions .area-manager-icon-pencil,
.context-manager-list .context-manager-actions .area-manager-icon-delete {
  display: inline-block;
}
.area-manager-list .area-manager-actions .area-manager-icon-pencil,
.context-manager-list .context-manager-actions .area-manager-icon-pencil {
  transform: rotate(-45deg);
}
.area-manager-list .area-manager-actions button:hover {
  background: var(--bg);
}
.area-manager-list .area-manager-actions button.btn-area-delete:hover {
  background: var(--error-bg, #fee2e2);
  border-color: var(--error);
  color: var(--error);
}
.area-manager-list li.area-manager-empty {
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
}

/* Context manager (tags) list – same structure as area manager */
.context-manager-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
  min-height: 200px;
  max-height: min(400px, 45vh);
  overflow-y: auto;
}
.context-manager-list-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}
.context-manager-list-toolbar .btn-new-item-wrap { flex-shrink: 0; }
.context-manager-list-toolbar .btn-new-item-main {
  border-radius: var(--radius);
  border-right: 1px solid var(--border);
}
.context-manager-list-toolbar .btn-new-item-main:hover { border-right-color: var(--primary); }
.context-manager-list-toolbar .btn-add-tag {
  padding: 0.4rem 0.75rem;
  font-size: 14px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
}
.context-manager-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}
.context-manager-list li:last-child {
  border-bottom: none;
}
.context-manager-visual {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  position: relative;
}
.context-manager-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.context-manager-color-swatch:hover {
  border-color: var(--primary);
}
.context-manager-color-picker-wrap {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 0.5rem;
  display: none;
  grid-template-columns: repeat(5, 28px);
  gap: 0.35rem;
}
.context-manager-color-picker-wrap.open {
  display: grid;
}
.context-manager-color-swatch-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.context-manager-color-swatch-option:hover,
.context-manager-color-swatch-option.selected {
  border-color: var(--text);
}
.context-manager-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
}
.context-manager-actions {
  display: flex;
  gap: 0.4rem;
}
.context-manager-actions button {
  padding: 0.35rem 0.6rem;
  font-size: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.context-manager-actions button:hover {
  background: var(--bg);
}
.context-manager-actions button.btn-tag-delete:hover {
  background: var(--error-bg, #fee2e2);
  border-color: var(--error);
  color: var(--error);
}
.context-manager-list li.context-manager-empty {
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
}

.area-manager-color-picker-wrap,
.area-manager-icon-picker-wrap {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 0.5rem;
  display: none;
}
.area-manager-color-picker-wrap.open,
.area-manager-icon-picker-wrap.open {
  display: flex;
}
.area-manager-color-picker-wrap {
  grid-template-columns: repeat(5, 28px);
  gap: 0.35rem;
}
.area-manager-color-picker-wrap.open {
  display: grid;
}
.area-manager-color-swatch-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.area-manager-color-swatch-option:hover,
.area-manager-color-swatch-option.selected {
  border-color: var(--text);
}
.area-manager-icon-picker-wrap {
  grid-template-columns: repeat(6, 36px);
  gap: 0.35rem;
}
.area-manager-icon-picker-wrap.open {
  display: grid;
}
.area-manager-icon-option {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.area-manager-icon-option:hover,
.area-manager-icon-option.selected {
  border-color: var(--primary);
  background: var(--bg);
}
.area-manager-icon-option.selected {
  background: var(--accent);
}
.form-area-new {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}
.form-area-new input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

/* Scheduled due date modal – quick date buttons */
.scheduled-quick-dates {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.scheduled-quick-dates .btn-quick-date {
  padding: 0.4rem 0.75rem;
  font-size: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.scheduled-quick-dates .btn-quick-date:hover {
  background: var(--bg);
}
.scheduled-quick-dates .btn-quick-date.active {
  background: var(--primary);
  color: var(--header-text);
  border-color: var(--primary);
}

/* Someday level modal */
.modal-someday-intro {
  margin: 0 0 1rem 0;
  font-size: 14px;
  color: var(--text-muted);
}
.someday-level-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.someday-level-choices .btn-someday-level {
  padding: 0.6rem 1rem;
  font-size: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.someday-level-choices .btn-someday-level:hover {
  background: var(--bg);
}

/* Task list section header (e.g. Someday levels) – same look as .task-section-title */
.task-list li.task-list-section-header {
  list-style: none;
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 0 0.5rem 0 !important;
  min-height: 0;
  cursor: default;
  display: block;
}
.task-list li.task-list-section-header .task-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.35rem 0;
  padding: 0;
}
.task-list li.task-list-section-header:first-child .task-section-title {
  margin-top: 0;
}
.task-list li.task-list-section-header + li:not(.task-list-section-header) {
  margin-top: 0;
}
.task-list li.task-list-section-header:not(:first-child) {
  margin-top: 1rem;
}
.task-list li.task-list-section-header.someday-drag-over .task-section-title {
  color: var(--primary);
}
/* Spacer for empty Someday sections (keeps section height and spacing) */
.task-list li.task-list-section-spacer {
  list-style: none;
  margin: 0 0 1rem 0;
  padding: 0;
  min-height: 48px;
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  pointer-events: none;
  display: block;
}
.task-list li.task-list-section-header {
  margin-bottom: 0.75rem !important;
}
.task-list li.task-list-project-header .task-section-title-link {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.task-list li.task-list-project-header .task-section-title-link:hover {
  color: var(--primary);
}
.task-list li.task-list-show-more {
  list-style: none;
  margin: 0 0 0.5rem 0;
  padding: 0.25rem 0 0.5rem;
  background: none !important;
  box-shadow: none !important;
  border: none !important;
}
.task-list-show-more-btn {
  font-size: 13px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.task-list-show-more-btn:hover {
  text-decoration: underline;
}

/* Waiting reason modal */
.modal-waiting .form-waiting { margin-top: 0.75rem; }
.modal-waiting label { display: block; margin-top: 0.5rem; margin-bottom: 0.2rem; font-size: 13px; }
.modal-waiting .waiting-field { margin-top: 0.5rem; }
.modal-waiting .waiting-field.hidden { display: none; }
.modal-waiting .waiting-follow-up { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.modal-waiting .checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; margin-bottom: 0.35rem; }
.modal-waiting .checkbox-label input[type="checkbox"] { margin: 0; }
.modal-waiting .waiting-follow-up-title { margin-top: 0.35rem; width: 100%; }

.modal-shortcuts { max-width: 480px; max-height: 85vh; overflow-y: auto; }
.shortcuts-list { margin-top: 0.75rem; }
.shortcuts-section { margin-bottom: 1rem; }
.shortcuts-section h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.35rem; }
.shortcuts-section dl { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1.5rem; align-items: baseline; margin: 0; font-size: 14px; }
.shortcuts-section dt { margin: 0; font-weight: 500; }
.shortcuts-section dd { margin: 0; }
.shortcuts-section kbd { font-family: inherit; font-size: 12px; padding: 0.15rem 0.4rem; border-radius: 4px; background: var(--bg); border: 1px solid var(--border); }

.modal-account { max-width: 440px; min-width: 360px; }
.account-section { margin-bottom: 1rem; }
.account-label { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.25rem; }
.account-value { margin: 0; font-size: 14px; }
.account-google-status { margin: 0 0 0.5rem; font-size: 14px; }
.account-google-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.account-btn-google { font-size: 13px; }

.modal-settings { max-width: 560px; min-width: 420px; }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.settings-tab { padding: 0.4rem 0.75rem; font-size: 0.8125rem; background: none; border: none; border-radius: var(--radius); color: var(--text-muted); cursor: pointer; font-family: inherit; }
.settings-tab:hover { color: var(--text); background: var(--bg-hover, rgba(0,0,0,0.04)); }
.settings-tab.active { color: var(--primary); font-weight: 500; background: var(--bg); }
.settings-panel { display: block; }
.settings-panel.hidden { display: none !important; }
.settings-hint { font-size: 0.8125rem; color: var(--text-muted); margin: 0; }
.settings-field-hint { font-size: 0.75rem; color: var(--text-muted); margin: 0.35rem 0 0; }
.settings-section { margin-bottom: 1.25rem; }
.settings-section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 0.5rem; }
.settings-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.settings-label { flex: 0 0 auto; font-size: 14px; }
.settings-select { flex: 1; min-width: 0; padding: 0.4rem 0.5rem; font-size: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.settings-checkbox { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 14px; }
.settings-checkbox input[type="checkbox"] { margin: 0; }
.settings-extension-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 0.75rem; }
.settings-extension-download { margin: 0 0 0.75rem; }
.settings-extension-download a { color: var(--link); text-decoration: underline; }
.settings-extension-download a:hover { text-decoration: none; }
.settings-extension-actions { margin-bottom: 0.75rem; }
.settings-token-new-wrap { margin-bottom: 1rem; }
.settings-token-new-wrap.hidden { display: none; }
.settings-token-row { display: flex; gap: 0.5rem; margin-top: 0.35rem; }
.settings-token-input { flex: 1; min-width: 0; padding: 0.4rem 0.5rem; font-size: 12px; font-family: monospace; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.settings-extension-warn { font-size: 12px; color: var(--text-muted); margin: 0.35rem 0 0; }
.settings-backup-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 0.75rem; }
.settings-backup-actions { margin-bottom: 1rem; }
.settings-restore-wrap { margin-top: 1rem; }
.settings-restore-row { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.35rem; }
.settings-restore-file-input { flex: 1; min-width: 0; font-size: 13px; }
.settings-backup-warn { font-size: 12px; color: var(--text-muted); margin: 0.35rem 0 0; }
.settings-tokens-list-wrap { margin-top: 0.5rem; }
.settings-tokens-list-wrap .settings-label { display: block; margin-bottom: 0.35rem; }
.settings-tokens-list { list-style: none; margin: 0; padding: 0; }
.settings-tokens-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.settings-tokens-list li:last-child { border-bottom: none; }
.settings-token-item-name { font-weight: 500; }
.settings-token-item-date { font-size: 11px; color: var(--text-muted); }

.task-waiting-block { margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.task-waiting-summary { font-size: 13px; color: var(--text-muted); }

/* ----- Reference view ----- */
.main-reference-view { display: flex; flex-direction: column; min-height: 0; overflow-x: visible; }
.ref-layout { display: flex; flex: 1; min-height: 0; overflow-x: visible; min-width: 0; }
.ref-content-wrap { flex: 1; min-width: 0; padding: 0 1rem 1rem; display: flex; flex-direction: column; overflow-x: visible; }
.ref-items-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.ref-item-row { padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto auto auto; gap: 0.25rem 0.75rem; align-items: start; }
.ref-item-row .ref-item-thumb-wrap { grid-column: 1; grid-row: 1 / -1; width: 48px; height: 48px; flex-shrink: 0; border-radius: 6px; overflow: hidden; background: var(--border); display: flex; align-items: center; justify-content: center; }
.ref-item-row .ref-item-thumb { width: 100%; height: 100%; object-fit: contain; }
.ref-item-row .ref-item-type-icon { width: 24px; height: 24px; object-fit: contain; filter: brightness(0); }
.theme-dark .ref-item-row .ref-item-type-icon { filter: brightness(0) invert(1); }
.ref-item-row .ref-item-thumb-wrap.ref-item-thumb-fail { background: var(--text-muted); opacity: 0.5; }
.ref-item-row .ref-item-thumb-wrap:empty { background: transparent; width: 0; min-width: 0; height: 0; padding: 0; overflow: hidden; }
.ref-item-row .ref-item-content { grid-column: 2; display: flex; flex-direction: column; gap: 0.2rem; }
.ref-item-row .ref-item-content .ref-item-title { font-weight: 600; }
.ref-item-row .ref-item-content .ref-item-title[href] { color: var(--primary); text-decoration: none; cursor: pointer; }
.ref-item-row .ref-item-content .ref-item-title[href]:hover { text-decoration: underline; }
.ref-item-row .ref-item-thumb-wrap[href] { cursor: pointer; text-decoration: none; color: inherit; }
.ref-item-row .ref-item-thumb-wrap.ref-item-preview-trigger,
.ref-item-row .ref-item-content .ref-item-title.ref-item-preview-trigger { cursor: pointer; }
.ref-item-row .ref-item-thumb-wrap.ref-item-preview-trigger:hover { background: var(--bg-hover); border-radius: var(--radius); }
.ref-item-row .ref-item-content .ref-item-title.ref-item-preview-trigger { color: var(--primary); }
.ref-item-row .ref-item-content .ref-item-title.ref-item-preview-trigger:hover { text-decoration: underline; }
.ref-item-row .ref-item-content .ref-item-url { font-size: 13px; color: var(--link); word-break: break-all; }
.ref-item-row .ref-item-content .ref-item-desc { font-size: 13px; color: var(--text-muted); margin: 0; }
.ref-item-row .ref-item-list-preview { margin: 0.25rem 0 0; padding-left: 1.25rem; font-size: 13px; color: var(--text-muted); }
.ref-item-row .ref-item-list-preview .ref-item-list-more { font-style: italic; }
.ref-item-row .ref-item-tags { grid-column: 2; display: flex; flex-wrap: wrap; gap: 0.25rem; }
/* Ref view mode: compact = title + icon + actions only; medium = + URL; full = + description/list */
.ref-items-list.ref-view-compact .ref-item-url,
.ref-items-list.ref-view-compact .ref-item-desc,
.ref-items-list.ref-view-compact .ref-item-list-preview,
.ref-items-list.ref-view-compact .ref-item-tags,
.ref-items-list.ref-view-compact .ref-item-dates { display: none !important; }
.ref-item-row .ref-item-dates { font-size: 12px; color: var(--text-muted); margin-top: 0.2rem; }
.ref-items-list.ref-view-compact .ref-item-row { padding: 0.35rem 0.5rem; gap: 0.35rem 0.5rem; align-items: center; min-height: 0; }
.ref-items-list.ref-view-compact .ref-item-row .ref-item-thumb-wrap { width: 32px; height: 32px; }
.ref-items-list.ref-view-compact .ref-item-row .ref-item-type-icon { width: 18px; height: 18px; }
.ref-items-list.ref-view-compact .ref-item-row .ref-item-content .ref-item-title { font-size: 0.9rem; }
.ref-items-list.ref-view-compact .ref-item-row .ref-item-action-btn { padding: 0.35rem; }
.ref-items-list.ref-view-compact .ref-item-row .ref-item-action-icon { width: 16px; height: 16px; }
.ref-items-list.ref-view-medium .ref-item-desc,
.ref-items-list.ref-view-medium .ref-item-list-preview { display: none !important; }
.ref-tag-pill { font-size: 11px; padding: 0.15rem 0.4rem; border-radius: 4px; background: var(--border); color: var(--text); }

/* Ref item preview modal (note/list read-only) */
.modal.modal-ref-preview { max-width: 560px; max-height: 85vh; display: flex; flex-direction: column; }
.ref-preview-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-shrink: 0; }
.ref-preview-title { margin: 0; font-size: 1.25rem; font-weight: 600; flex: 1; min-width: 0; word-break: break-word; }
.ref-preview-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.ref-preview-content { flex: 1; overflow-y: auto; padding: 0.5rem 0; white-space: pre-wrap; }
.ref-preview-note-body { white-space: pre-wrap; line-height: 1.5; color: var(--text); }
.ref-preview-list { margin: 0; padding-left: 1.25rem; line-height: 1.6; }
.ref-preview-list li { margin: 0.25rem 0; }
.ref-preview-empty { margin: 0; color: var(--text-muted); font-style: italic; }
.ref-preview-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); flex-shrink: 0; }
.ref-preview-tags .ref-tag-pill { font-size: 12px; padding: 0.2rem 0.5rem; }

.ref-item-row .ref-item-actions { grid-column: 3; grid-row: 1 / -1; display: flex; flex-direction: row; flex-wrap: nowrap; gap: 0.4rem; align-self: start; }
.ref-view-mode-toggle { display: inline-flex; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.ref-view-mode-toggle .view-mode-btn { border-left: none; }
.ref-view-mode-toggle .view-mode-btn:first-child { border-left: none; }
.ref-item-row .ref-item-actions button { font-size: 12px; }
.ref-item-row .ref-item-action-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease; }
.ref-item-row .ref-item-action-btn:hover { background: var(--bg-hover); }
.ref-item-row .ref-item-fav { font-size: 1.1rem; color: var(--text-muted); min-width: 2.25rem; min-height: 2.25rem; }
.ref-item-row .ref-item-fav:hover { color: #f59e0b; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.4); }
.ref-item-row .ref-item-fav.starred { color: #f59e0b; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.35); }
.ref-item-row .ref-item-fav .ref-item-star-icon { width: 20px; height: 20px; object-fit: contain; transition: filter 0.15s ease; }
.ref-item-row .ref-item-fav .ref-item-star-icon { filter: brightness(0); }
.theme-dark .ref-item-row .ref-item-fav .ref-item-star-icon { filter: brightness(0) invert(1); }
.ref-item-row .ref-item-fav:hover .ref-item-star-icon,
.ref-item-row .ref-item-fav.starred .ref-item-star-icon { filter: brightness(0) invert(72%) sepia(49%) saturate(1000%) hue-rotate(10deg); }
.theme-dark .ref-item-row .ref-item-fav:hover .ref-item-star-icon,
.theme-dark .ref-item-row .ref-item-fav.starred .ref-item-star-icon { filter: invert(72%) sepia(49%) saturate(1000%) hue-rotate(10deg); }
.ref-item-row .ref-item-action-icon { width: 20px; height: 20px; object-fit: contain; filter: brightness(0); }
.theme-dark .ref-item-row .ref-item-action-icon { filter: brightness(0) invert(1); }
.ref-item-add-task-wrap { position: relative; display: inline-flex; }
.ref-add-task-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 2px;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0;
}
.ref-add-task-dropdown.hidden { display: none !important; }
.ref-add-task-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.75rem;
  font-size: 13px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.ref-add-task-dropdown-item:hover { background: var(--bg-hover); }
.modal-add-ref-to-task { max-width: 420px; }
.modal-add-ref-to-task-ref-name {
  font-size: 13px;
  color: var(--text-muted);
  margin: -0.5rem 0 0.75rem;
}
.modal-add-ref-to-task-search { width: 100%; margin-bottom: 0.75rem; }
.add-ref-to-task-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.add-ref-to-task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.add-ref-to-task-row:last-child { border-bottom: none; }
.add-ref-to-task-row:hover { background: var(--bg-hover); }
.add-ref-to-task-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-ref-to-task-row-meta { font-size: 11px; color: var(--text-muted); text-transform: lowercase; }
.add-ref-to-task-empty { margin: 0.75rem 0; color: var(--text-muted); font-size: 13px; }
.modal-add-ref-to-task-actions { display: flex; justify-content: flex-end; }
.modal-select-ref-for-task { max-width: 480px; }
.select-ref-for-task-filters { margin-bottom: 0.75rem; }
.select-ref-for-task-filters .search-input { width: 100%; margin-bottom: 0.5rem; }
.select-ref-for-task-tag-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.select-ref-for-task-tag {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.select-ref-for-task-list.select-ref-for-task-tree {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.select-ref-for-task-collection {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.35rem 0.75rem;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  text-align: left;
  cursor: pointer;
}
.select-ref-for-task-collection:hover { background: var(--bg-hover); }
.select-ref-for-task-chevron {
  font-size: 10px;
  line-height: 1;
  opacity: 0.8;
  flex-shrink: 0;
}
.select-ref-for-task-collection.is-collapsed .select-ref-for-task-chevron { transform: none; }
.select-ref-for-task-collection.is-expanded .select-ref-for-task-chevron { transform: none; }
.select-ref-for-task-collection-unsorted { background: var(--surface); }
.select-ref-for-task-collection-level-1 { padding-left: 1.25rem; }
.select-ref-for-task-collection-level-2 { padding-left: 2rem; }
.select-ref-for-task-collection-level-3 { padding-left: 2.75rem; }
.select-ref-for-task-row {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.select-ref-for-task-row.select-ref-for-task-item-level-0 { padding-left: 1.25rem; }
.select-ref-for-task-row.select-ref-for-task-item-level-1 { padding-left: 2rem; }
.select-ref-for-task-row.select-ref-for-task-item-level-2 { padding-left: 2.75rem; }
.select-ref-for-task-row.select-ref-for-task-item-level-3 { padding-left: 3.5rem; }
.select-ref-for-task-row:last-child { border-bottom: none; }
.select-ref-for-task-row:hover { background: var(--bg-hover); }
.select-ref-for-task-empty { margin: 0.75rem 0; color: var(--text-muted); font-size: 13px; }
.modal-select-ref-actions { display: flex; justify-content: flex-end; }
.ref-btn-add { font-size: 13px; }
.ref-collection-item { margin-bottom: 0.25rem; }
#nav-reference {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-height));
}
#nav-reference .ref-nav-footer {
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--border-muted, rgba(0, 0, 0, 0.06));
  padding-top: 0.5rem;
  padding-bottom: 0.25rem;
  margin-bottom: 0;
}
#nav-reference .ref-nav-fav-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  object-fit: contain;
  /* colorize white star to amber #f59e0b */
  filter: brightness(0) invert(72%) sepia(49%) saturate(1000%) hue-rotate(10deg);
}
.ref-nav-sep {
  height: 0;
  border: none;
  margin: 0.5rem 0;
}
.ref-item-row.ref-item-dragging { opacity: 0.6; }
.ref-drop-target.ref-drop-target-active {
  background: var(--primary);
  color: var(--primary-inverse, #fff);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Reference collections page (hierarchy like projects) */
.ref-items-panel .view-title-row .view-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-title-row-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}
.ref-title-row-right .search-input { margin-right: 0; }
.ref-items-panel .view-title-row .btn-new-item-wrap { flex-shrink: 0; }
.ref-items-panel .view-title-row .btn-new-item-main {
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--radius);
  border-right: 1px solid var(--border);
}
.ref-items-panel .view-title-row .btn-new-item-main:hover { border-right-color: var(--primary); }
.ref-view-mode-row { margin-top: 0.35rem; justify-content: space-between; align-items: center; }
.ref-trash-actions-wrap { flex-shrink: 0; }
.ref-trash-actions-wrap.hidden { display: none !important; }
.ref-btn-empty-trash { color: var(--text, #1a1a1a); border-color: var(--border); }
.ref-btn-empty-trash:hover { color: var(--text, #1a1a1a); border-color: var(--text); }
.ref-collections-page { padding: 0; max-width: 52rem; width: 100%; box-sizing: border-box; min-width: 0; overflow: visible; }
.ref-collections-page-header { margin-bottom: 0.5rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; min-width: 0; }
.ref-collections-page-header .view-title-row-spacer { flex: 1; min-width: 0.5rem; }
.ref-collections-page-header .ref-collections-header-actions { flex-shrink: 0; }
.ref-collections-page-header .btn-new-item-main {
  border-radius: var(--radius);
  border-right: 1px solid var(--border);
}
.ref-collections-page-header .btn-new-item-main:hover { border-right-color: var(--primary); }
.ref-collections-page-intro { font-size: 13px; color: var(--text-muted); margin: 0 0 1rem; }
.ref-rules-list { display: flex; flex-direction: column; gap: 1.25rem; }
.ref-rules-section { display: flex; flex-direction: column; gap: 0.5rem; }
.ref-rules-section-custom { margin-top: 0.75rem; }
.ref-rules-section-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.25rem; }
.ref-rules-section-header .ref-rules-section-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.ref-rules-section-header .btn-new-item-wrap { flex-shrink: 0; }
.ref-rules-section-header .btn-new-item-main { border-radius: var(--radius); border-right: 1px solid var(--border); }
.ref-rules-section-header .btn-new-item-main:hover { border-right-color: var(--primary); }
.ref-rules-section-scroll { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; padding-right: 0.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0.5rem; }
.ref-rules-section-default .ref-rules-section-scroll { max-height: 360px; }
.ref-rules-section-empty { margin: 0; font-size: 13px; color: var(--text-muted); font-style: italic; }
.ref-rule-pattern-type-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ref-rule-pattern-type-row select { flex: 1; min-width: 0; }
.ref-rule-regex-info { position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ref-rule-regex-info.hidden { display: none !important; }
.ref-rule-regex-info-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--text-muted, #64748b); color: #fff; font-size: 12px; font-weight: 600; cursor: help; line-height: 1; }
.ref-rule-regex-info-icon:hover { background: var(--primary, #2563eb); }
.ref-rule-regex-info-bubble { position: absolute; right: 0; left: auto; top: 100%; margin-top: 4px; padding: 12px 14px; min-width: 280px; max-width: min(420px, calc(100vw - 2rem)); max-height: 320px; overflow-y: auto; font-size: 13px; line-height: 1.55; color: var(--text, #1e293b); background: var(--surface, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); z-index: 99999; white-space: pre-line; display: none; }
.ref-rule-regex-info-bubble.is-open { display: block; }
.ref-rule-regex-info { z-index: 1; }
.ref-rule-regex-info-bubble code { font-size: 12px; background: var(--bg, #f1f5f9); padding: 2px 5px; border-radius: 3px; }
.ref-rule-form-error { margin: 0 0 0.5rem 0; font-size: 13px; color: var(--error, #c00); }
.ref-rule-form-error.hidden { display: none !important; }
.ref-rules-empty { display: flex; flex-direction: column; gap: 1rem; }
.ref-rules-empty .ref-empty-state { margin: 0; }
.ref-backup-page { padding: 0; max-width: 52rem; }
.ref-backup-page-header { margin-bottom: 0.5rem; }
.ref-backup-section { margin-bottom: 2rem; }
.ref-backup-section h3 { margin: 0 0 0.35rem; font-size: 15px; font-weight: 600; color: var(--text); }
.ref-backup-desc { font-size: 13px; color: var(--text-muted); margin: 0 0 0.75rem; }
.ref-backup-file-input { display: block; margin-bottom: 0.5rem; font-size: 13px; }
.ref-backup-status { font-size: 13px; margin: 0.5rem 0 0; }
.ref-backup-status-error { color: var(--error, #b91c1c); }
.ref-rule-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.ref-rule-row .ref-rule-content { flex: 1; min-width: 0; }
.ref-rule-row .ref-rule-actions { display: flex; gap: 0.35rem; flex-shrink: 0; margin-left: auto; }
.ref-rule-row .ref-rule-action-btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 0.4rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); cursor: pointer;
}
.ref-rule-row .ref-rule-action-btn:hover { background: var(--bg-hover); }
.ref-rule-row .ref-rule-action-icon { width: 18px; height: 18px; object-fit: contain; filter: brightness(0); }
.theme-dark .ref-rule-row .ref-rule-action-icon { filter: brightness(0) invert(1); }
.ref-rule-row .ref-rule-pattern { font-weight: 500; }
.ref-rule-row .ref-rule-meta { font-size: 12px; color: var(--text-muted); }
.ref-rule-row .ref-rule-tags { font-size: 13px; color: var(--primary); }
.ref-rule-row .ref-rule-collection { font-size: 13px; color: var(--text-muted); }
.ref-rule-row .ref-rule-skip { font-size: 13px; color: var(--text-muted); font-style: italic; }
.ref-collections-tree-page { display: flex; flex-direction: column; gap: 0; }
.ref-collections-tree-page .ref-collections-drop.nav-insert-between,
.ref-collections-tree-page .ref-collections-drop[data-drop-collection-root] {
  min-height: 0.25rem; margin: 0 0 0.25rem; border-radius: 2px;
}
.ref-collections-tree-page .nav-insert-between.drag-over {
  min-height: 0.5rem; background: var(--accent); opacity: 0.35; margin: 0 0 0.35rem;
}
.ref-collection-tree-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: default;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}
.ref-collection-tree-row[draggable="true"] { cursor: grab; }
.ref-collection-tree-row[draggable="true"]:active { cursor: grabbing; }
.ref-collection-tree-row:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.03)); }
.ref-collection-tree-row.drag-over { border-left-color: var(--primary); background: rgba(37, 99, 235, 0.06); }
.ref-collection-tree-row.ref-collection-tree-unsorted { border-left-color: var(--text-muted); opacity: 0.9; }
.ref-collection-tree-row.ref-collection-tree-level-1 { margin-left: 1rem; border-left-color: rgba(37, 99, 235, 0.35); }
.ref-collection-tree-row.ref-collection-tree-level-2 { margin-left: 2rem; border-left-color: rgba(37, 99, 235, 0.28); }
.ref-collection-tree-row.ref-collection-tree-level-3 { margin-left: 3rem; border-left-color: rgba(37, 99, 235, 0.2); }
.ref-collection-tree-name { font-size: 14px; font-weight: 500; }
.ref-collection-tree-meta { font-size: 13px; color: var(--text-muted); }
.ref-collection-tree-actions { display: flex; gap: 0.25rem; }
.ref-collection-tree-action {
  padding: 0.25rem 0.5rem; font-size: 12px; color: var(--text-muted);
  background: none; border: none; cursor: pointer; font-family: inherit; border-radius: 3px;
}
.ref-collection-tree-action:hover { color: var(--primary); background: var(--bg); }
.ref-collection-tree-row.ref-collection-tree-dragging { opacity: 0.55; }

.ref-collection-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.ref-collection-icon-picker button {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
}
.ref-collection-icon-picker button:hover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
}
.ref-collection-icon-picker button.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
}
.ref-collection-icon-picker button[data-icon=""] {
  font-size: 11px;
  color: var(--text-muted);
}
.ref-empty-state { margin-top: 1rem; text-align: center; color: var(--text-muted); }
.ref-item-tags-pills { min-height: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.25rem; }
.ref-item-tag-pill { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.4rem; font-size: 0.75rem; border-radius: 4px; border: 1px solid var(--primary); background: var(--bg); color: var(--primary); }
.ref-item-tag-pill-remove { border: none; background: none; color: inherit; cursor: pointer; padding: 0 2px; font-size: 1rem; line-height: 1; opacity: 0.8; }
.ref-item-tag-pill-remove:hover { opacity: 1; }
.ref-item-tags-autocomplete-wrap { position: relative; }
.ref-item-tag-autocomplete-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 2px; max-height: 160px; overflow-y: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 20; }
.ref-item-tag-autocomplete-list.hidden { display: none !important; }
.ref-item-tag-autocomplete-item { padding: 6px 8px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.ref-item-tag-autocomplete-item:last-child { border-bottom: none; }
.ref-item-tag-autocomplete-item:hover, .ref-item-tag-autocomplete-item.highlight { background: var(--bg-hover, #f0f4ff); }
.ref-item-tag-autocomplete-item.create { font-style: italic; color: var(--text-muted); }
.ref-item-type-fields { margin-bottom: 0.5rem; }
.ref-item-type-fields.hidden { display: none !important; }
.ref-item-list-row { display: flex; gap: 0.5rem; margin-bottom: 0.35rem; align-items: center; }
.ref-item-list-row input { flex: 1; min-width: 0; }
#ref-item-list-entries { margin-bottom: 0.5rem; }
#ref-item-list-add { margin-bottom: 0.5rem; }
.ref-item-meta-wrap { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.ref-item-meta-wrap .ref-item-meta-line { margin: 0; }
.ref-item-meta-wrap code { font-size: 12px; word-break: break-all; background: var(--bg); padding: 0.15rem 0.35rem; border-radius: 4px; }
.ref-item-dates-wrap { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.ref-item-dates-wrap .ref-item-date-line { margin: 0.25rem 0 0; }
.ref-item-dates-wrap .ref-item-date-line:first-child { margin-top: 0; }
.ref-item-rules-row { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.35rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.ref-item-rules-row .secondary.small { padding: 0.35rem 0.65rem; font-size: 13px; }
.ref-item-rules-feedback { font-size: 13px; color: var(--text-muted); }
.ref-item-rules-feedback.hidden { display: none; }

/* ----- Responsive ----- */
@media (max-width: 768px) {
  .app-nav {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .app-nav.open {
    transform: translateX(0);
  }
  .app-body .nav-toggle {
    display: block;
  }
}

/* ----- Admin (nutmanager) ----- */
#admin-screen { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); }
#admin-screen.hidden { display: none !important; }
.admin-header { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.admin-back { color: var(--primary); text-decoration: none; font-size: 14px; }
.admin-back:hover { text-decoration: underline; }
.admin-title { margin: 0; font-size: 1.25rem; font-weight: 600; }
.admin-body { flex: 1; padding: 1.5rem; overflow: auto; }
.admin-tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.admin-tab { padding: 0.5rem 1rem; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-size: 14px; color: var(--text-muted); }
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-toolbar { margin-bottom: 0.75rem; }
.admin-btn-refresh { padding: 0.35rem 0.75rem; font-size: 13px; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.admin-btn-refresh:hover { background: var(--bg-hover); }
.admin-table-wrap { overflow-x: auto; }
.admin-loading { margin: 1rem 0; color: var(--text-muted); font-size: 14px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { font-weight: 600; color: var(--text-muted); }
.admin-table .admin-btn-small { padding: 0.25rem 0.5rem; font-size: 12px; cursor: pointer; margin-right: 0.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; color: var(--text); }
.admin-table .admin-btn-small:hover { background: var(--bg-hover); }
.admin-table .admin-btn-danger { border-color: var(--error); color: var(--error); }
.admin-table .admin-btn-danger:hover { background: var(--error-bg); }
.admin-edit-google-wrap { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.admin-edit-google-wrap .account-label { margin-bottom: 0.25rem; }
.admin-edit-google-wrap .account-google-status { margin: 0 0 0.5rem; }
.admin-modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.admin-modal-wrap.hidden { display: none !important; }
.admin-modal { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); max-width: 400px; width: 90%; box-shadow: var(--shadow); }
.admin-modal h2 { margin-top: 0; margin-bottom: 1rem; font-size: 1.1rem; }
.admin-modal label { display: block; margin-top: 0.75rem; margin-bottom: 0.25rem; font-size: 14px; }
.admin-modal input[type="text"], .admin-modal input[type="email"] { width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; }
.admin-modal .form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }
.profile-menu-item-admin.hidden { display: none !important; }

/* ----- Marketing one-pager (coming soon) ----- */
#marketing-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
#marketing-screen.hidden { display: none !important; }
.marketing-onepager { text-align: center; padding: 2.5rem 1.5rem; max-width: 440px; }
.marketing-logo-wrap { margin-bottom: 1rem; }
.marketing-logo { display: block; margin: 0 auto; width: 80px; height: 80px; }
.marketing-brand { margin: 0 0 0.25rem; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.marketing-headline { margin: 0 0 0.75rem; font-size: 1.25rem; font-weight: 600; color: var(--primary); }
.marketing-desc { margin: 0 0 1.75rem; color: var(--text-muted); font-size: 1rem; line-height: 1.5; }
.marketing-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }
.marketing-cta { display: inline-block; padding: 0.6rem 1.25rem; border-radius: var(--radius); font-weight: 500; text-decoration: none; transition: background 0.15s, color 0.15s; }
.marketing-cta { background: var(--primary); color: var(--header-text); }
.marketing-cta:hover { background: var(--primary-hover); color: var(--header-text); }
.marketing-cta-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.marketing-cta-secondary:hover { background: var(--bg-hover); }
.marketing-footer-links { margin: 1.5rem 0 0; font-size: 0.8125rem; }
.marketing-footer-links a { color: var(--text-muted); text-decoration: none; }
.marketing-footer-links a:hover { text-decoration: underline; color: var(--text); }
