@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Sora:wght@400;500;600&display=swap");

:root {
  color-scheme: light;
  --bg: #eef3f9;
  --bg-deep: #dbe6f2;
  --ink: #1f2430;
  --muted: #6b778a;
  --accent: #05508a;
  --accent-dark: #043a66;
  --accent-cool: #1f8a70;
  --sidebar: rgba(255, 255, 255, 0.9);
  --panel: rgba(255, 255, 255, 0.8);
  --border: rgba(31, 36, 48, 0.12);
  --shadow: 0 26px 60px rgba(31, 36, 48, 0.16);
  --tree-line: rgba(31, 36, 48, 0.14);
  --dark-panel: #141516;
  --dark-panel-soft: #1e2022;
  --green: #22c55e;
  --ghost-bg: rgba(31, 36, 48, 0.08);
  --card: rgba(255, 255, 255, 0.94);
  --ink-dim: #4b5565;
  --border-strong: rgba(31, 36, 48, 0.2);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --transition-fast: 0.15s ease;
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
}

* {
  box-sizing: border-box;
}

.skip-link {
  position: fixed;
  grid-column: 1;
  grid-row: 1;
  left: 12px;
  top: 12px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border-strong);
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(31, 36, 48, 0.12);
  transform: translateY(-120%);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  opacity: 0;
  pointer-events: none;
}

.skip-link:focus {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html[data-theme="dark"] .skip-link {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

body {
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  font-family: "Sora", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 10% -10%, #d7e6f7 0%, transparent 60%),
    radial-gradient(1000px 720px at 95% 15%, #b9f1e5 0%, transparent 55%),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-deep) 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-deep: #0b0f14;
  --ink: #e5e7eb;
  --muted: #a3b0c2;
  --accent: #4aa3ff;
  --accent-dark: #1d6fc2;
  --accent-cool: #46c4a8;
  --sidebar: rgba(17, 21, 26, 0.96);
  --panel: rgba(20, 24, 30, 0.94);
  --border: rgba(226, 232, 240, 0.12);
  --shadow: 0 26px 60px rgba(5, 6, 10, 0.55);
  --tree-line: rgba(226, 232, 240, 0.16);
  --ghost-bg: rgba(226, 232, 240, 0.1);
  --card: rgba(24, 28, 36, 0.96);
  --ink-dim: #c5ced9;
  --border-strong: rgba(226, 232, 240, 0.18);
}

:root[data-theme="dark"] body {
  background: radial-gradient(1200px 600px at 10% -10%, rgba(30, 64, 175, 0.22) 0%, transparent 60%),
    radial-gradient(1000px 720px at 95% 15%, rgba(16, 185, 129, 0.18) 0%, transparent 55%),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-deep) 100%);
}

:root[data-theme="dark"] .tree-item {
  background: rgba(19, 23, 30, 0.92);
  border-color: rgba(226, 232, 240, 0.14);
  box-shadow: 0 10px 22px rgba(5, 6, 10, 0.35);
}

:root[data-theme="dark"] .tree-item:hover {
  border-color: rgba(226, 232, 240, 0.2);
  background: rgba(24, 30, 38, 0.94);
  box-shadow: 0 14px 26px rgba(5, 6, 10, 0.45);
}

:root[data-theme="dark"] .tree-item.is-active {
  border-color: rgba(74, 163, 255, 0.55);
  background: rgba(74, 163, 255, 0.14);
  box-shadow: 0 16px 28px rgba(74, 163, 255, 0.22);
}

:root[data-theme="dark"] .tree-item.is-active::before {
  box-shadow: 0 0 0 4px rgba(74, 163, 255, 0.28);
}

:root[data-theme="dark"] .tree-item-title {
  color: #e7edf7;
}

:root[data-theme="dark"] .tree-item-meta {
  color: #b7c6da;
}

:root[data-theme="dark"] .tree-item:hover .tree-item-title {
  color: #f4f8ff;
}

:root[data-theme="dark"] .tree-item:hover .tree-item-meta {
  color: #c9d7ea;
}

:root[data-theme="dark"] .tree-item.is-active .tree-item-title {
  color: #f4f8ff;
}

:root[data-theme="dark"] .tree-item.is-active .tree-item-meta {
  color: #dbe9ff;
}

:root[data-theme="dark"] .main-panel {
  background: radial-gradient(900px 520px at 70% 10%, rgba(30, 64, 175, 0.24) 0%, transparent 60%),
    linear-gradient(145deg, rgba(13, 17, 23, 0.9) 0%, rgba(7, 10, 14, 0.9) 100%);
}

.app-shell {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: 312px 1fr;
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  box-shadow: 20px 0 40px rgba(31, 36, 48, 0.08);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.sidebar-footer-panel {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 52px;
  padding: 4px 4px 4px 6px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

.sidebar-footer-profile {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
}

.sidebar-user-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 6px 4px 6px 6px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background var(--transition-fast);
}

.sidebar-user-strip:hover {
  background: rgba(5, 80, 138, 0.06);
}

.sidebar-user-strip .sidebar-footer-logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.sidebar-user-text {
  flex: 1;
  min-width: 0;
  align-self: center;
}

.user-line-primary {
  margin: 0;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.user-line-secondary {
  margin: 4px 0 0;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-all;
}

.sidebar-user-more {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  align-self: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  letter-spacing: -0.12em;
  pointer-events: none;
}

.sidebar-user-more::before {
  content: "⋮";
}

.sidebar-footer-divider {
  align-self: stretch;
  width: 1px;
  margin: 6px 2px;
  background: var(--border);
  flex-shrink: 0;
}

.theme-toggle.sidebar-theme-btn {
  flex: 0 0 auto;
  align-self: stretch;
  width: 44px;
  min-height: 0;
  height: auto;
  margin: 2px 2px 2px 0;
  border-radius: 10px;
  border: none;
  background: transparent;
  box-shadow: none;
}

.theme-toggle.sidebar-theme-btn:hover {
  background: rgba(5, 80, 138, 0.08);
  box-shadow: none;
  transform: none;
}

.sidebar-footer .profile-menu {
  left: 0;
  right: 0;
  top: auto;
  bottom: calc(100% + 8px);
  min-width: 100%;
}

.menu-item--row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
}

.menu-item-icon {
  display: inline-flex;
  color: var(--muted);
  flex-shrink: 0;
}

.menu-item--row:hover .menu-item-icon {
  color: var(--accent);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  border-radius: 14px;
  border: 1px solid rgba(31, 36, 48, 0.16);
  background: rgba(255, 255, 255, 0.9);
  padding: 0;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(31, 36, 48, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.sidebar-toggle-icon {
  width: 20px;
  height: 12px;
  display: inline-block;
  color: inherit;
  background:
    linear-gradient(currentColor 0 0) 0 0/100% 2px,
    linear-gradient(currentColor 0 0) 0 50%/100% 2px,
    linear-gradient(currentColor 0 0) 0 100%/100% 2px;
  background-repeat: no-repeat;
}

body:not(.is-sidebar-collapsed) .sidebar-toggle-icon {
  background:
    linear-gradient(currentColor 0 0) 0 0/100% 2px,
    linear-gradient(currentColor 0 0) 0 100%/100% 2px;
  background-repeat: no-repeat;
}

.sidebar-toggle:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 10px 20px rgba(31, 36, 48, 0.16);
}

.sidebar-toggle:focus-visible {
  outline: 2px solid rgba(5, 80, 138, 0.45);
  outline-offset: 2px;
}

.icon-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(31, 36, 48, 0.2);
}

.icon-btn.ghost {
  background: var(--ghost-bg);
  color: var(--ink);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--ghost-bg);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(31, 36, 48, 0.2);
}

.theme-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(31, 36, 48, 0.04);
}

.profile {
  position: relative;
}

.profile-trigger:focus-visible {
  outline: 2px solid rgba(5, 80, 138, 0.45);
  outline-offset: 2px;
}

:root[data-theme="dark"] .sidebar {
  box-shadow: 20px 0 40px rgba(2, 4, 8, 0.6);
}

:root[data-theme="dark"] .sidebar-toggle {
  background: rgba(15, 19, 26, 0.9);
  border-color: var(--border);
  color: var(--ink);
  box-shadow: 0 8px 16px rgba(5, 6, 10, 0.5);
}

:root[data-theme="dark"] .sidebar-toggle:hover {
  background: rgba(20, 24, 30, 0.9);
}

:root[data-theme="dark"] .user-card {
  background: rgba(226, 232, 240, 0.06);
}

:root[data-theme="dark"] .sidebar-footer-panel {
  background: rgba(22, 26, 34, 0.96);
  border-color: var(--border);
  box-shadow: none;
}

:root[data-theme="dark"] .sidebar-user-strip:hover {
  background: rgba(74, 163, 255, 0.1);
}

:root[data-theme="dark"] .theme-toggle.sidebar-theme-btn:hover {
  background: rgba(74, 163, 255, 0.12);
}

:root[data-theme="dark"] .sidebar-footer-divider {
  background: var(--border);
}

:root[data-theme="dark"] .sidebar-footer {
  border-top-color: var(--border);
}

:root[data-theme="dark"] .sidebar-user-strip .sidebar-footer-logo {
  background: rgba(19, 24, 30, 0.95);
  border-color: rgba(226, 232, 240, 0.14);
}

:root[data-theme="dark"] .filter-input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select {
  background: rgba(19, 24, 30, 0.9);
  border-color: rgba(226, 232, 240, 0.14);
  color: var(--ink);
}

:root[data-theme="dark"] .tree-empty {
  background: rgba(19, 24, 30, 0.85);
  border-color: rgba(226, 232, 240, 0.16);
}

:root[data-theme="dark"] .tree-group {
  background: transparent;
  border-color: transparent;
}

:root[data-theme="dark"] .tree-subgroup {
  background: transparent;
  border-color: transparent;
}

:root[data-theme="dark"] .tree-subgroup-title {
  color: var(--ink);
}

:root[data-theme="dark"] .tree-group-header,
:root[data-theme="dark"] .tree-subgroup-header {
  border-color: transparent;
  color: var(--ink);
}

:root[data-theme="dark"] .tree-caret::before {
  border-left-color: rgba(226, 232, 240, 0.72);
}

:root[data-theme="dark"] .tree-group-header[aria-expanded="true"] .tree-caret::before,
:root[data-theme="dark"] .tree-subgroup-header[aria-expanded="true"] .tree-caret::before {
  border-left-color: #7cc0ff;
}

:root[data-theme="dark"] .tree-folder-svg--closed .tree-folder-shape {
  fill: #f5c047;
  stroke: #dc9920;
}

:root[data-theme="dark"] .tree-folder-svg--open .tree-folder-shape {
  fill: #efa73a;
  stroke: #d88726;
}

:root[data-theme="dark"] .tree-folder-shine {
  stroke: rgba(255, 255, 255, 0.44);
}

:root[data-theme="dark"] .tree-group-header:hover,
:root[data-theme="dark"] .tree-subgroup-header:hover {
  border-color: rgba(226, 232, 240, 0.2);
  background: rgba(226, 232, 240, 0.08);
}

:root[data-theme="dark"] .tree-group-count {
  color: #b7c9e4;
  background: rgba(74, 163, 255, 0.1);
  border-color: rgba(74, 163, 255, 0.2);
}

:root[data-theme="dark"] .tree-subgroup-count {
  color: #b7c9e4;
  background: rgba(74, 163, 255, 0.08);
  border-color: rgba(74, 163, 255, 0.16);
}

:root[data-theme="dark"] .profile-menu {
  background: rgba(19, 24, 30, 0.96);
  border-color: rgba(226, 232, 240, 0.12);
  box-shadow: 0 18px 36px rgba(5, 6, 10, 0.5);
}

:root[data-theme="dark"] .menu-item {
  color: var(--ink);
}

:root[data-theme="dark"] .menu-item:hover {
  background: rgba(148, 163, 184, 0.12);
}

:root[data-theme="dark"] .empty-card {
  background: rgba(19, 24, 30, 0.92);
  border-color: rgba(226, 232, 240, 0.12);
  box-shadow: 0 24px 50px rgba(5, 6, 10, 0.5);
}

:root[data-theme="dark"] .app-toast {
  background: rgba(19, 24, 30, 0.95);
  border-color: rgba(226, 232, 240, 0.12);
}

:root[data-theme="dark"] .modal-backdrop {
  background: rgba(6, 8, 12, 0.62);
}

:root[data-theme="dark"] .modal-card {
  background: rgba(19, 24, 30, 0.96);
  border-color: rgba(226, 232, 240, 0.12);
}

:root[data-theme="dark"] .status-line {
  background: rgba(226, 232, 240, 0.08);
  color: var(--muted);
}

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 200px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 36px rgba(31, 36, 48, 0.16);
  padding: 8px;
  display: none;
  z-index: 12;
}

.profile-menu.is-open {
  display: grid;
  gap: 6px;
}

.menu-item {
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}

.menu-item:hover {
  background: rgba(5, 80, 138, 0.1);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-cool) url("/assets/perfil.png") center / cover no-repeat;
  color: transparent;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.85rem;
}


.sidebar-label {
  font-weight: 600;
  font-size: 0.7rem;
}

.search-block {
  display: grid;
  gap: 4px;
}

.filter-input-wrap {
  position: relative;
  width: 100%;
}

.filter-input {
  width: 100%;
  padding: 7px 34px 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(31, 36, 48, 0.22);
  font-family: inherit;
  font-size: 0.8125rem;
  background: #fff;
}

.filter-input::-webkit-search-decoration,
.filter-input::-webkit-search-cancel-button,
.filter-input::-webkit-search-results-button,
.filter-input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.filter-input::placeholder {
  font-size: 0.74rem;
}

.filter-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  opacity: 0.9;
}

.filter-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(5, 80, 138, 0.2);
}

.tree-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  flex: 1;
}

.tree-list {
  display: grid;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0;
  min-height: 0;
  width: 100%;
}

.tree-empty {
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed rgba(31, 36, 48, 0.18);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
}

.tree-group {
  border-radius: 0;
  padding: 0;
  border: none;
  background: transparent;
  width: 100%;
  min-width: 0;
}

.tree-group.is-collapsed .tree-group-list {
  display: none;
}

.tree-subgroup.is-collapsed .tree-subgroup-list {
  display: none;
}

.tree-group-header {
  width: 100%;
  max-width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 5px 3px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.tree-group-heading {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.tree-caret {
  width: 8px;
  height: 8px;
  position: relative;
  flex: 0 0 8px;
}

.tree-caret::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #5f6c81;
  transition: transform 0.2s ease, border-left-color 0.2s ease;
  transform-origin: 35% 50%;
}

.tree-group-header[aria-expanded="true"] .tree-caret::before,
.tree-subgroup-header[aria-expanded="true"] .tree-caret::before {
  transform: rotate(90deg);
  border-left-color: var(--accent);
}

.tree-folder-icon {
  width: 18px;
  height: 15px;
  flex: 0 0 18px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tree-folder-svg {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 15px;
  overflow: visible;
  transition: opacity 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

.tree-folder-svg--closed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tree-folder-svg--open {
  opacity: 0;
  transform: translateY(1px) scale(0.95);
}

.tree-folder-shape {
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.tree-folder-svg--closed .tree-folder-shape {
  fill: #e4ab1f;
  stroke: #a76b00;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.tree-folder-svg--open .tree-folder-shape {
  fill: #de9722;
  stroke: #925a04;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.tree-folder-shine {
  fill: none;
  stroke: rgba(255, 255, 255, 0.52);
  stroke-width: 1.1;
  stroke-linecap: round;
  transition: opacity 0.2s ease;
}

.tree-group-header[aria-expanded="true"] .tree-folder-svg--closed,
.tree-subgroup-header[aria-expanded="true"] .tree-folder-svg--closed {
  opacity: 0;
  transform: translateY(-1px) scale(0.92);
}

.tree-group-header[aria-expanded="true"] .tree-folder-svg--open,
.tree-subgroup-header[aria-expanded="true"] .tree-folder-svg--open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tree-group-header:hover .tree-folder-svg--closed,
.tree-subgroup-header:hover .tree-folder-svg--closed {
  filter: saturate(1.14) brightness(1.06);
}

.tree-group-header:hover,
.tree-subgroup-header:hover {
  border-color: rgba(5, 80, 138, 0.18);
  background: rgba(5, 80, 138, 0.07);
}

.tree-group-header:focus-visible,
.tree-subgroup-header:focus-visible {
  outline: 2px solid rgba(5, 80, 138, 0.6);
  outline-offset: 2px;
}

.tree-group-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-group-count {
  justify-self: end;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  color: #3d4f6e;
  background: rgba(5, 80, 138, 0.08);
  border-radius: 999px;
  padding: 1px 6px;
  font-weight: 700;
  border: 1px solid rgba(5, 80, 138, 0.12);
  letter-spacing: 0.02em;
}

.tree-group-list {
  position: relative;
  display: grid;
  justify-items: start;
  gap: 5px;
  padding-left: 12px;
  margin: 5px 0 0 4px;
  width: 100%;
  min-width: 0;
}

.tree-group-list::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 1px;
  background: var(--tree-line);
}

.tree-subgroup {
  margin-top: 6px;
  border-radius: 0;
  padding: 0;
  border: none;
  background: transparent;
  width: 100%;
  min-width: 0;
}

.tree-subgroup:first-child {
  margin-top: 0;
}

.tree-subgroup-header {
  width: 100%;
  max-width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 4px 3px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 2px;
  gap: 8px;
}

.tree-subgroup-heading {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.tree-subgroup-title {
  margin: 0;
  font-size: 0.78rem;
  color: inherit;
  font-weight: 700;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-subgroup-count {
  justify-self: end;
  flex-shrink: 0;
  font-size: 0.6rem;
  font-variant-numeric: tabular-nums;
  color: #3d4f6e;
  background: rgba(5, 80, 138, 0.07);
  border-radius: 999px;
  padding: 1px 6px;
  font-weight: 700;
  border: 1px solid rgba(5, 80, 138, 0.1);
  letter-spacing: 0.02em;
}

.tree-subgroup-list {
  display: grid;
  justify-items: start;
  gap: 5px;
  padding-left: 12px;
  margin: 3px 0 0 4px;
  position: relative;
  width: 100%;
  min-width: 0;
}

.tree-subgroup-list::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 1px;
  background: var(--tree-line);
}

.tree-item {
  position: relative;
  width: 240px;
  max-width: 100%;
  border: 1px solid rgba(31, 36, 48, 0.11);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 9px;
  padding: 5px 8px 5px 12px;
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border 0.2s ease;
  box-shadow: 0 4px 12px rgba(31, 36, 48, 0.06);
}

.tree-item::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cool);
  box-shadow: 0 0 0 4px rgba(31, 138, 112, 0.2);
}

.tree-item::after {
  content: "";
  position: absolute;
  left: -2px;
  top: 15px;
  width: 9px;
  height: 1px;
  background: var(--tree-line);
}

.tree-item:hover {
  transform: translateY(-1px);
  border-color: rgba(5, 80, 138, 0.24);
  background: #ffffff;
  box-shadow: 0 12px 20px rgba(31, 36, 48, 0.13);
}

.tree-item.is-active {
  border-color: rgba(5, 80, 138, 0.45);
  background: rgba(5, 80, 138, 0.08);
  box-shadow: 0 12px 20px rgba(5, 80, 138, 0.16);
}

.tree-item.is-active::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(5, 80, 138, 0.22);
}

.tree-item-title {
  font-weight: 600;
  font-size: 0.78rem;
  color: #111b2c;
  line-height: 1.22;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.tree-item-meta {
  font-size: 0.62rem;
  color: #55667e;
  line-height: 1.28;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.tree-item[data-accent="sun"]::before {
  background: #6ea8d8;
  box-shadow: 0 0 0 4px rgba(110, 168, 216, 0.25);
}

.tree-item[data-accent="ocean"]::before {
  background: #2dd4bf;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.22);
}

.tree-item[data-accent="slate"]::before {
  background: #94a3b8;
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.22);
}

.tree-item[data-accent="amber"]::before {
  background: #2f6ea7;
  box-shadow: 0 0 0 4px rgba(47, 110, 167, 0.22);
}

.tree-item[data-accent="rose"]::before {
  background: #fb7185;
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.22);
}

.tree-item[data-accent="mint"]::before {
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.22);
}

.main-panel {
  position: relative;
  background: radial-gradient(900px 520px at 70% 10%, rgba(255, 255, 255, 0.45), transparent 58%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.82) 0%, rgba(236, 242, 248, 0.78) 100%);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: clamp(6px, 0.9vw, 12px) clamp(8px, 1.2vw, 16px) clamp(8px, 0.9vw, 14px);
  gap: 8px;
}

.routine-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 8px;
}

.routine-frame-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: none;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: none;
}

/* Rotina aberta: painel encosta nas bordas, iframe preenche sem “moldura” extra */
.main-panel:has(.routine-frame-wrap:not(.is-workspace-idle)) {
  padding: 0;
  gap: 0;
}

.main-panel:has(.routine-frame-wrap:not(.is-workspace-idle)) .routine-shell {
  gap: 0;
}

.routine-frame-wrap:not(.is-workspace-idle) {
  border-radius: 0;
  border: none;
  background: transparent;
}

.routine-frame-wrap:not(.is-workspace-idle) .routine-viewport {
  background: #fff;
}

html[data-theme="dark"] .routine-frame-wrap:not(.is-workspace-idle) .routine-viewport {
  background: #0d1117;
}

.routine-frame-wrap:not(.is-workspace-idle) .routine-dock {
  border-radius: 0;
}

.routine-frame-wrap.is-visible {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.routine-frame-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 5px 10px 5px 12px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  min-height: 40px;
  flex-wrap: wrap;
  row-gap: 4px;
}

.routine-idle-hint {
  margin: 0;
  flex: 1 1 160px;
  min-width: 0;
  max-width: min(48ch, 56vw);
  padding: 0 4px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
}

.routine-idle-hint[hidden] {
  display: none !important;
}

/* display:inline-flex nos botões vence o [hidden] padrão em alguns UAs — alinhar ao estado em JS */
.frame-action-btn[hidden] {
  display: none !important;
}

.routine-frame-wrap.is-workspace-idle .routine-frame-actions {
  display: none !important;
}

.routine-frame-bar:has(.routine-tab-strip:not([hidden])) {
  align-items: flex-end;
  padding: 4px 10px 0 12px;
}

.routine-frame-bar:has(.routine-tab-strip:not([hidden])) .routine-frame-actions {
  padding-bottom: 6px;
}

html[data-theme="dark"] .routine-frame-bar {
  background: var(--sidebar);
}

html[data-theme="dark"] .routine-frame-wrap {
  background: var(--panel);
  border-color: var(--border);
}

html[data-theme="dark"] .routine-viewport {
  background: rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] .workspace-desktop--shell {
  background: rgba(0, 0, 0, 0.12);
}

html[data-theme="dark"] .frame-action-btn:hover {
  background: rgba(74, 163, 255, 0.08);
}

.routine-frame-leading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.routine-frame-leading[hidden] {
  display: none !important;
}

.routine-code-pill {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  line-height: 1.2;
  border: 1px solid var(--border-strong);
}

.routine-frame-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.routine-frame-kicker {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted);
}

.routine-frame-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.routine-frame-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.frame-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  min-height: 30px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.frame-action-btn:hover {
  border-color: var(--accent);
  background: rgba(5, 80, 138, 0.06);
  color: var(--ink);
}

.frame-action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.frame-action-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: currentColor;
  opacity: 0.85;
}

.frame-action-icon--close {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.4 5.3 12 10.9l5.6-5.6 1.1 1.1-5.6 5.6 5.6 5.6-1.1 1.1-5.6-5.6-5.6 5.6-1.1-1.1 5.6-5.6-5.6-5.6z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.4 5.3 12 10.9l5.6-5.6 1.1 1.1-5.6 5.6 5.6 5.6-1.1 1.1-5.6-5.6-5.6 5.6-1.1-1.1 5.6-5.6-5.6-5.6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.frame-action-icon--popout {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 5h8v2H7v10h10v-6h2v8H5V5zm10-2v5l-3.5-3.5L11 10l-1.5-1.5 3.5-3.5H10V3h7v7z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 5h8v2H7v10h10v-6h2v8H5V5zm10-2v5l-3.5-3.5L11 10l-1.5-1.5 3.5-3.5H10V3h7v7z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.frame-action-icon--minimize {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 12h14v2H5v-2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 12h14v2H5v-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.frame-action-btn--minimize:hover {
  border-color: var(--accent);
  background: rgba(5, 80, 138, 0.08);
  color: var(--accent-dark);
}

.frame-action-btn--close:hover {
  border-color: #b91c1c;
  background: rgba(185, 28, 28, 0.06);
  color: #b91c1c;
}

.frame-action-btn--popout:hover {
  border-color: var(--accent-cool);
  background: rgba(31, 138, 112, 0.08);
  color: var(--ink);
}

html[data-theme="dark"] .frame-action-btn--close:hover {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(127, 29, 29, 0.2);
  color: #fecaca;
}

.routine-tab-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1 1 0;
  min-width: 0;
  padding: 0 6px 0 0;
  scrollbar-width: thin;
}

.routine-tab-strip[hidden] {
  display: none !important;
}

.routine-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: stretch;
  max-width: min(280px, 42vw);
  border-radius: 5px 5px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  background: transparent;
  color: var(--ink-dim);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.routine-tab:hover {
  background: rgba(5, 80, 138, 0.08);
  border-color: rgba(5, 80, 138, 0.2);
  color: var(--ink);
}

.routine-tab.is-active {
  background: var(--card);
  border-color: var(--border-strong);
  color: var(--ink);
  box-shadow: 0 -1px 0 var(--card);
  position: relative;
  z-index: 1;
}

.routine-tab-main {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 2px 8px 12px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-radius: 7px 0 0 0;
}

.routine-tab-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  margin: 0;
  padding: 0 6px 0 0;
  border: none;
  border-radius: 0 7px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.75;
}

.routine-tab-close:hover {
  opacity: 1;
  color: var(--ink);
  background: rgba(5, 80, 138, 0.12);
}

.routine-tab-close-icon {
  display: block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.4 5.3 12 10.9l5.6-5.6 1.1 1.1-5.6 5.6 5.6 5.6-1.1 1.1-5.6-5.6-5.6 5.6-1.1-1.1 5.6-5.6-5.6-5.6z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M6.4 5.3 12 10.9l5.6-5.6 1.1 1.1-5.6 5.6 5.6 5.6-1.1 1.1-5.6-5.6-5.6 5.6-1.1-1.1 5.6-5.6-5.6-5.6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.routine-tab-code {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.routine-tab.is-active .routine-tab-code {
  color: var(--accent);
}

.routine-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.routine-viewport {
  position: relative;
  min-height: 0;
  flex: 1;
  width: 100%;
  background: rgba(31, 36, 48, 0.04);
}

.routine-session {
  position: absolute;
  inset: 0;
  min-height: 0;
  z-index: 0;
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
}

.routine-session.is-focused {
  z-index: 2;
  visibility: visible;
  pointer-events: auto;
}

.routine-session.is-minimized {
  z-index: -1;
  visibility: hidden;
  pointer-events: none;
}

.routine-session .routine-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  animation: routineIn 0.25s var(--ease-out);
}

html[data-theme="dark"] .routine-session .routine-frame {
  background: #0d1117;
}

.routine-session-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  transition: opacity 0.2s var(--ease-out), visibility 0.2s;
}

.routine-session-loading-inner {
  display: grid;
  justify-items: center;
  gap: 16px;
  max-width: 280px;
  text-align: center;
}

.routine-session-loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: routineLoadSpin 0.75s linear infinite;
}

@keyframes routineLoadSpin {
  to {
    transform: rotate(360deg);
  }
}

.routine-session-loading-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-dim);
}

.routine-session.is-iframe-ready .routine-session-loading {
  display: none;
}

.routine-viewport-empty {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px 14px;
  pointer-events: none;
}

/* display:grid acima vence o [hidden] padrao do UA — sem isso o cartao cobre as rotinas abertas */
.routine-viewport-empty[hidden] {
  display: none !important;
}

.workspace-desktop--shell {
  background: rgba(31, 36, 48, 0.03);
}

.routine-viewport-empty.workspace-desktop .workspace-desktop-card {
  pointer-events: auto;
  width: min(440px, 94%);
  margin: 0 auto;
  text-align: left;
  border-radius: 8px;
  padding: 28px 28px 26px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}

html[data-theme="dark"] .routine-viewport-empty.workspace-desktop .workspace-desktop-card {
  box-shadow: none;
}

.workspace-desktop-logo {
  width: clamp(140px, 22vw, 220px);
  max-height: 72px;
  margin: 0 0 4px;
}

.workspace-empty-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--muted);
}

.workspace-empty-heading {
  margin: 0 0 12px;
  font-family: "Fraunces", serif;
  font-size: 1.35rem;
  font-weight: 650;
  line-height: 1.25;
  color: var(--ink);
}

.workspace-empty-copy {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.55;
  max-width: 42ch;
}

.workspace-empty-steps {
  margin: 0 0 16px;
  padding-left: 1.2em;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.55;
  max-width: 48ch;
}

.workspace-empty-steps li {
  margin: 0 0 8px;
  padding-left: 0.2em;
}

.workspace-empty-steps li:last-child {
  margin-bottom: 0;
}

.workspace-cta-row {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0 0 8px;
}

.workspace-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent-dark);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform 0.12s ease;
}

.workspace-cta:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.workspace-cta:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.workspace-cta:active {
  transform: translateY(1px);
}

html[data-theme="dark"] .workspace-cta {
  border-color: rgba(74, 163, 255, 0.45);
  background: rgba(74, 163, 255, 0.22);
  color: #e8f2ff;
}

html[data-theme="dark"] .workspace-cta:hover {
  background: rgba(74, 163, 255, 0.32);
  border-color: rgba(125, 189, 255, 0.55);
}

.routine-frame-wrap.is-workspace-idle .routine-viewport {
  box-shadow: inset 3px 0 0 rgba(5, 80, 138, 0.18);
}

html[data-theme="dark"] .routine-frame-wrap.is-workspace-idle .routine-viewport {
  box-shadow: inset 3px 0 0 rgba(74, 163, 255, 0.22);
}

.workspace-empty-footnote {
  margin-top: 20px;
  font-size: 0.78rem;
}

.workspace-empty-footnote::before {
  box-shadow: none;
  width: 6px;
  height: 6px;
}

.routine-dock {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 12px 10px;
  background: var(--sidebar);
  border-top: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
}

.routine-dock-kicker {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
  flex: 0 0 auto;
}

.routine-dock-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.routine-dock-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 0.75rem;
  max-width: 100%;
}

.routine-dock-chip-main {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.routine-dock-code {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--accent);
}

.routine-dock-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  color: var(--ink-dim);
}

.routine-dock-chip-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.routine-dock-restore {
  border: none;
  background: rgba(5, 80, 138, 0.1);
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.routine-dock-restore:hover {
  background: rgba(5, 80, 138, 0.18);
}

.routine-dock-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  cursor: pointer;
}

.routine-dock-close:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.tree-item.is-open:not(.is-active) {
  border-color: rgba(5, 80, 138, 0.22);
  background: rgba(5, 80, 138, 0.05);
}

.tree-item.is-open:not(.is-active) .tree-item-title {
  color: var(--ink-dim);
}

html[data-theme="dark"] .tree-item.is-open:not(.is-active) {
  border-color: rgba(74, 163, 255, 0.25);
  background: rgba(74, 163, 255, 0.08);
}

@keyframes routineIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

body.is-sidebar-collapsed .app-shell {
  grid-template-columns: 1fr;
}

body.is-sidebar-collapsed .main-panel {
  padding-left: 58px;
}

body.is-sidebar-collapsed .sidebar {
  position: absolute;
  top: 16px;
  left: 16px;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 0;
  gap: 0;
  background: transparent;
  border-right: none;
  box-shadow: none;
  overflow: visible;
  z-index: 6;
}

body.is-sidebar-collapsed .sidebar-toggle {
  width: 42px;
  height: 38px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 22px rgba(31, 36, 48, 0.18);
}

body.is-sidebar-collapsed .sidebar-head {
  justify-content: flex-start;
}

body.is-sidebar-collapsed .sidebar-label {
  display: none;
}

body.is-sidebar-collapsed .search-block,
body.is-sidebar-collapsed .tree-panel {
  display: none;
}

body.is-sidebar-collapsed .sidebar-footer {
  display: none;
}

.empty-state {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
}

.empty-card {
  width: min(520px, 90%);
  text-align: center;
  border-radius: 26px;
  padding: 48px 36px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(31, 36, 48, 0.08);
  color: var(--ink);
  box-shadow: 0 24px 50px rgba(31, 36, 48, 0.16);
}

.empty-card h1 {
  margin: 16px 0 8px;
  font-family: "Fraunces", serif;
  font-size: 2.2rem;
}

.empty-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.empty-footnote {
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.empty-footnote::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.2);
}

.empty-logo {
  width: clamp(180px, 28vw, 320px);
  height: auto;
  max-height: 120px;
  margin: 0 auto;
  object-fit: contain;
}

.app-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  min-width: 220px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(31, 36, 48, 0.18);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 14px 28px rgba(31, 36, 48, 0.2);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast[data-tone="warn"] {
  border-color: rgba(5, 80, 138, 0.4);
  color: #043a66;
}

.pwa-prompt {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 20px;
  background: rgba(9, 15, 14, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 22;
}

.pwa-prompt.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.pwa-card {
  width: min(520px, 94vw);
  background: var(--panel, #fff);
  border-radius: 20px;
  padding: 20px 20px 18px;
  border: 1px solid var(--border, rgba(31, 36, 48, 0.12));
  box-shadow: var(--shadow, 0 18px 36px rgba(31, 36, 48, 0.18));
  display: grid;
  gap: 12px;
}

.pwa-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pwa-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-dark, #043a66);
  font-weight: 700;
  display: block;
}

.pwa-title {
  font-size: 1.1rem;
}

.pwa-text {
  margin: 0;
  color: var(--muted, #6b778a);
  line-height: 1.5;
}

.pwa-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--muted, #6b778a);
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
}

.pwa-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pwa-button {
  background: var(--accent, #05508a);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(5, 80, 138, 0.24);
}

.pwa-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.pwa-dismiss {
  background: transparent;
  border: 1px solid rgba(31, 36, 48, 0.2);
  color: var(--ink, #1f2430);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.pwa-close {
  border: none;
  background: transparent;
  color: var(--muted, #6b778a);
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
}

.is-hidden {
  display: none;
}

.login-body {
  display: grid;
  place-items: center;
  grid-template-rows: 1fr;
  height: 100vh;
  overflow: auto;
}

.login-body.modal-open {
  overflow: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.orb-a {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle at 30% 30%, #c7dcf2, transparent 70%);
  top: -140px;
  left: -140px;
}

.orb-b {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle at 30% 30%, #b3efe6, transparent 70%);
  bottom: -180px;
  right: -140px;
}

.orb-c {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle at 60% 40%, #b7d0ec, transparent 70%);
  top: 35%;
  right: 20%;
}

.login-shell {
  width: min(420px, 90vw);
  background: var(--panel);
  border-radius: 26px;
  border: 1px solid var(--border);
  padding: 32px;
  box-shadow: var(--shadow);
  z-index: 1;
}

.login-panel {
  display: grid;
  gap: 12px;
}

.login-logo {
  width: min(220px, 72%);
  height: auto;
  max-height: 88px;
  object-fit: contain;
  justify-self: center;
}

.login-panel h1 {
  margin: 14px 0 8px;
  font-family: "Fraunces", serif;
  font-size: 2.2rem;
}

.login-panel p {
  margin: 0 0 18px;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 25, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 6;
}

.modal-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 7;
  padding: 24px;
}

.modal.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.modal-card {
  background: #fff;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  width: min(420px, 92vw);
  display: grid;
  gap: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(5, 80, 138, 0.16);
  color: var(--accent-dark);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.checkbox input {
  width: 16px;
  height: 16px;
}

label {
  font-weight: 600;
  font-size: 0.85rem;
}

input,
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(31, 36, 48, 0.2);
  font-family: inherit;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: rgba(31, 36, 48, 0.08);
  color: var(--ink);
  border: 1px solid rgba(31, 36, 48, 0.14);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

.login-assist {
  display: grid;
  margin-top: 8px;
}

:root[data-theme="dark"] button.secondary {
  background: rgba(226, 232, 240, 0.08);
  color: var(--ink);
  border-color: rgba(226, 232, 240, 0.16);
}

.not-found-actions {
  display: grid;
  gap: 12px;
  margin: 12px 0 8px;
}

.not-found-actions .action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
}

.not-found-actions .primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(5, 80, 138, 0.24);
}

.not-found-actions .secondary {
  border: 1px solid var(--border);
  color: var(--ink);
  background: transparent;
}

.status-line {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 36, 48, 0.08);
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 288px 1fr;
  }

  .sidebar {
    padding: 12px;
  }
}

@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    height: auto;
    overflow: visible;
  }

  .tree-list {
    max-height: 45vh;
  }

  .main-panel {
    min-height: 70vh;
    height: auto;
  }

  body.is-sidebar-collapsed .main-panel {
    padding-left: 0;
    padding-top: 56px;
  }

}

@media (max-width: 600px) {
  .empty-card {
    padding: 36px 24px;
  }

  .empty-card h1 {
    font-size: 1.8rem;
  }

  .app-toast {
    left: 16px;
    right: 16px;
    max-width: none;
  }

}
