/* Port of ShellView.swift (WindowRootView), LeftSidebar.swift and PaneView.swift; values are the Swift points. */

.window {
  display: flex;
  height: 100vh;
  background: var(--tg-canvas);
  font-size: calc(14px * var(--tg-zoom));
  overflow: hidden;
  position: relative;
}

/* Title band hairline: the chat app's faint line between the gray strip and the content. */
.hairline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: color-mix(in srgb, var(--tg-line) 60%, transparent);
}

/* MARK: Left column */

.left-column {
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--tg-chrome);
  position: relative;
  z-index: 1;
}

.left-column > .band {
  flex: none;
  height: var(--tg-tab-bar);
}

.left-sidebar {
  flex: 1;
  min-height: 0;
  display: flex;
}

.window-controls {
  position: absolute;
  top: 0;
  left: 0;
  height: var(--tg-tab-bar);
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 12px;
  z-index: 3;
}

.title-button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tg-ink2);
  border-radius: 7px;
}
.title-button:hover:not(:disabled),
.title-button.on {
  background: var(--tg-hover);
}
.title-button:disabled {
  color: var(--tg-faint);
}

/* MARK: Rail */

.rail {
  flex: none;
  width: var(--tg-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 2px 0 12px;
}

.rail .spacer {
  flex: 1;
}

.rail-button {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: var(--tg-muted);
}
.rail-button:hover:not(:disabled) {
  background: var(--tg-hover);
}
.rail-button.selected {
  color: var(--tg-accent);
}
.rail-button.selected svg {
  stroke-width: 2;
}
.rail-button:disabled {
  color: var(--tg-faint);
}
.rail-button.mark {
  color: var(--tg-muted);
}
.rail-button.mark.selected {
  color: var(--tg-ink);
}

.brand-mark {
  display: block;
  width: 17px;
  height: 17px;
  background: currentColor;
  mask: url("/assets/desktop/mark.svg") center / contain no-repeat;
}

.brand-wordmark {
  display: block;
  width: calc(78px * var(--tg-zoom));
  height: calc(78px * 24 / 102.58 * var(--tg-zoom));
  background: var(--tg-ink);
  mask: url("/assets/desktop/wordmark.svg") center / contain no-repeat;
  margin: 0 8px;
}

.profile-button {
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: var(--tg-hover);
  color: var(--tg-ink);
  font-size: calc(10px * var(--tg-zoom));
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.profile-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* MARK: List panel */

.list-panel {
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--tg-block);
  border: 1px solid var(--tg-line);
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 12px;
  overflow: hidden;
}

.list-header {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 8px 4px;
}

.list-header .brand-row {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 2px;
}

.list-header .panel-title {
  font-size: calc(16px * var(--tg-zoom));
  font-weight: 600;
  color: var(--tg-ink);
  padding: 0 6px;
}

.list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 10px;
}

.action-row {
  width: 100%;
  height: calc(28px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: calc(8px * var(--tg-zoom));
  padding: 0 8px;
  border-radius: 8px;
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-ink);
  text-align: left;
}
.action-row:hover,
.action-row.selected {
  background: var(--tg-hover);
}
.action-row .sf-wrap {
  width: calc(18px * var(--tg-zoom));
  display: flex;
  justify-content: center;
  color: var(--tg-ink2);
}
.action-row .label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.section-header {
  font-size: calc(12px * var(--tg-zoom));
  font-weight: 600;
  color: var(--tg-muted);
  padding: 14px 12px 5px;
}

.root-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 2px 0 8px;
  border-radius: 8px;
  color: var(--tg-ink);
}
.root-header .kind {
  width: calc(18px * var(--tg-zoom));
  margin-right: calc(4px * var(--tg-zoom));
  display: flex;
  justify-content: center;
  color: var(--tg-ink2);
}
.root-header .kind img {
  height: calc(13px * var(--tg-zoom));
}
.root-header .name {
  font-size: calc(13px * var(--tg-zoom));
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.root-header .fold {
  color: var(--tg-faint);
  opacity: 0;
  transition: transform 0.2s;
}
.root-header:hover .fold,
.root-header.folded .fold {
  opacity: 1;
}
.root-header.folded .fold {
  transform: rotate(-90deg);
}
.root-header .grow {
  flex: 1;
}
.root-header .more {
  opacity: 0;
}
.root-header:hover .more {
  opacity: 1;
}

.tree-row {
  width: 100%;
  height: calc(28px * var(--tg-zoom));
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 8px;
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-ink);
  text-align: left;
}
.tree-row:hover {
  background: color-mix(in srgb, var(--tg-hover) 70%, transparent);
}
.tree-row.selected {
  background: var(--tg-hover);
}
.tree-row .chevron {
  width: calc(12px * var(--tg-zoom));
  margin-right: calc(4px * var(--tg-zoom));
  display: flex;
  justify-content: center;
  color: var(--tg-faint);
  transition: transform 0.2s;
}
.tree-row.expanded .chevron {
  transform: rotate(90deg);
}
.tree-row .icon {
  width: calc(18px * var(--tg-zoom));
  margin-right: calc(8px * var(--tg-zoom));
  display: flex;
  justify-content: center;
  color: var(--tg-muted);
}
.tree-row.folder .icon {
  color: color-mix(in srgb, var(--tg-accent) 90%, transparent);
}
.tree-row.selected .icon {
  color: var(--tg-accent);
}
.tree-row .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search panel (LeftSidebar.searchPanel) */
.search-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 12px 0;
}
.search-field {
  flex: none;
  height: calc(34px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px 0 10px;
  background: var(--tg-canvas);
  border: 1px solid var(--tg-line);
  border-radius: 10px;
  color: var(--tg-muted);
}
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-ink);
}
.search-field input::placeholder {
  color: var(--tg-muted);
}
.search-field .options {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tg-muted);
}
.search-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 10px;
}
.search-caption {
  font-size: calc(12px * var(--tg-zoom));
  color: var(--tg-muted);
  padding: 8px 4px 5px;
}
.tag-row {
  width: 100%;
  height: calc(30px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px;
  border-radius: 8px;
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-ink);
  text-align: left;
}
.tag-row:hover {
  background: var(--tg-hover);
}
.tag-row .hash {
  width: calc(18px * var(--tg-zoom));
  display: flex;
  justify-content: center;
  color: var(--tg-accent);
}
.tag-row .hash svg {
  stroke-width: 2.25;
}
.tag-row .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-row .count {
  font-size: calc(11px * var(--tg-zoom));
  color: var(--tg-muted);
}
.tag-row .chev {
  color: var(--tg-faint);
}
.tag-item {
  width: 100%;
  height: calc(28px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 calc(31px * var(--tg-zoom));
  border-radius: 8px;
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-ink);
  text-align: left;
}
.tag-item:hover {
  background: var(--tg-hover);
}
.tag-item .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-item .where {
  font-size: calc(11px * var(--tg-zoom));
  color: var(--tg-muted);
}
.result-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px;
  border-radius: 8px;
  text-align: left;
}
.result-row:hover {
  background: var(--tg-hover);
}
.result-row .text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.result-row .title {
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-row .summary {
  font-size: calc(11px * var(--tg-zoom));
  color: var(--tg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-row .type {
  font-size: calc(10px * var(--tg-zoom));
  color: var(--tg-muted);
}

/* MARK: Content area and panes */

.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  position: relative;
}
.content-area.no-list::before,
.settings-area.no-list::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--tg-tab-bar);
  bottom: 0;
  width: 1px;
  background: var(--tg-line);
  z-index: 2;
}

.area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--tg-canvas);
}

.tab-strip {
  flex: none;
  height: var(--tg-tab-bar);
  display: flex;
  align-items: center;
  background: var(--tg-chrome);
  position: relative;
}
.tab-strip .tabs {
  display: flex;
  align-items: center;
  padding: 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-strip .grow {
  flex: 1;
  min-width: 4px;
}
.tab-strip .panel-toggle {
  margin-right: 10px;
}

.tab {
  height: 30px;
  min-width: calc(120px * var(--tg-zoom));
  max-width: calc(240px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px 0 10px;
  border-radius: 8px;
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-muted);
  position: relative;
}
.tab:hover {
  background: var(--tg-hover);
}
.tab.active {
  background: var(--tg-canvas);
  box-shadow: 0 0 0 0.5px color-mix(in srgb, var(--tg-line) 70%, transparent), 0 0.5px 1px rgb(0 0 0 / 0.04);
}
.tab.active.focused {
  color: var(--tg-ink2);
}
.tab .icon {
  width: 14px;
  display: flex;
  justify-content: center;
}
.tab .title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab .close {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--tg-muted);
  opacity: 0;
}
.tab.active .close,
.tab:hover .close {
  opacity: 1;
}
.tab .close:hover {
  background: var(--tg-hover);
}
.tab .close svg {
  stroke-width: 3;
}
.tab-separator {
  width: 1px;
  height: 14px;
  background: var(--tg-line);
}
.tab-separator.hidden {
  opacity: 0;
}
.tab-add {
  margin-left: 4px;
}

.pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--tg-canvas);
}

.pane-header {
  flex: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
}
.pane-header .grow {
  flex: 1;
}
.pane-header .more {
  width: 28px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tg-muted);
}

.view-switcher {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--tg-block);
  border: 1px solid var(--tg-line);
  border-radius: 999px;
}
.view-switcher button {
  height: calc(24px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 calc(10px * var(--tg-zoom));
  border-radius: 999px;
  font-size: calc(12px * var(--tg-zoom));
  color: var(--tg-muted);
}
.view-switcher button svg {
  stroke-width: 2;
}
.view-switcher button.active {
  background: var(--tg-canvas);
  color: var(--tg-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.07);
}
:root[data-theme="dark"] .view-switcher button.active {
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
}

.pane-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--tg-canvas);
}

/* New tab page */
.new-tab {
  max-width: calc(420px * var(--tg-zoom));
  margin: 0 auto;
  padding: 28px;
  box-sizing: content-box;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.new-tab h1 {
  margin: 0;
  padding-left: calc(10px * var(--tg-zoom));
  font-size: calc(24px * var(--tg-zoom));
  font-weight: 700;
  color: var(--tg-ink);
}
.new-tab .actions,
.new-tab .recent {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.new-tab-row {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--tg-zoom));
  padding: calc(8px * var(--tg-zoom)) calc(10px * var(--tg-zoom));
  border-radius: 8px;
  color: var(--tg-ink);
  text-align: left;
}
.new-tab-row:hover {
  background: var(--tg-hover);
}
.new-tab-row .icon {
  width: calc(20px * var(--tg-zoom));
  display: flex;
  justify-content: center;
  color: var(--tg-muted);
}
.new-tab-row .title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.new-tab-row .shortcut,
.new-tab-row .folder {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: calc(12px * var(--tg-zoom));
  color: var(--tg-muted);
}
.new-tab .recent-title {
  font-size: calc(12px * var(--tg-zoom));
  font-weight: 500;
  color: var(--tg-muted);
  padding: 0 0 4px calc(10px * var(--tg-zoom));
}

.pane-message {
  padding: 24px 36px 24px 56px;
  font-size: calc(12px * var(--tg-zoom));
  color: var(--tg-bad);
}

/* MARK: Info column */

.panel-column {
  flex: none;
  width: var(--tg-right);
  display: flex;
  flex-direction: column;
  background: var(--tg-canvas);
  position: relative;
}
/* Quick Open (QuickOpenView): 588 wide, 52 below the top, dimmed window behind. */
.quick-scrim {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.18);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 52px;
  z-index: 40;
}
.quick-open {
  width: calc(588px * var(--tg-zoom));
  background: var(--tg-canvas);
  border: 1px solid var(--tg-line);
  border-radius: 11px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgb(0 0 0 / 0.18);
}
.quick-field {
  height: calc(47px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 15px;
  color: var(--tg-muted);
  border-bottom: 1px solid var(--tg-line);
}
.quick-field input {
  flex: 1;
  border: 0;
  outline: 0;
  background: none;
  font-size: calc(14px * var(--tg-zoom));
  color: var(--tg-ink);
}
.quick-list {
  max-height: calc(350px * var(--tg-zoom));
  overflow-y: auto;
  padding: 5px 0;
}
.quick-section {
  font-size: calc(10px * var(--tg-zoom));
  font-weight: 500;
  color: var(--tg-muted);
  padding: 9px 14px 3px;
}
.quick-row {
  width: calc(100% - 12px);
  margin: 0 6px 2px;
  height: calc(39px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 6px;
  text-align: left;
}
.quick-row.selected {
  background: var(--tg-hover);
}
.quick-row .icon {
  width: calc(15px * var(--tg-zoom));
  display: flex;
  justify-content: center;
  color: var(--tg-muted);
}
.quick-row .text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.quick-row .title {
  font-size: calc(13px * var(--tg-zoom));
  color: var(--tg-ink);
}
.quick-row .detail {
  font-size: calc(10px * var(--tg-zoom));
  color: var(--tg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-empty {
  padding: 16px;
  font-size: calc(12px * var(--tg-zoom));
  color: var(--tg-muted);
}
.quick-hints {
  height: calc(34px * var(--tg-zoom));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--tg-chrome);
  border-top: 1px solid var(--tg-line);
  font-size: calc(11px * var(--tg-zoom));
  color: var(--tg-muted);
}
.quick-hints .grow {
  flex: 1;
}
.quick-hints b {
  font-weight: 600;
  color: var(--tg-ink2);
}

.panel-column .band {
  flex: none;
  height: var(--tg-tab-bar);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-right: 10px;
  background: var(--tg-chrome);
  position: relative;
}
.panel-column .info-host {
  flex: 1;
  min-height: 0;
  display: flex;
}
.floating-panel {
  position: absolute;
  top: var(--tg-tab-bar);
  right: 0;
  bottom: 0;
  width: var(--tg-right);
  display: flex;
  z-index: 4;
}

/* MARK: Settings */

.settings-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--tg-canvas);
  position: relative;
}
.settings-area > .band {
  flex: none;
  height: var(--tg-tab-bar);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  background: var(--tg-chrome);
  position: relative;
}
.settings-area > .settings-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* MARK: Menus */

.menu {
  position: fixed;
  z-index: 50;
  min-width: 200px;
  padding: 5px;
  background: color-mix(in srgb, var(--tg-block) 96%, transparent);
  border: 0.5px solid var(--tg-line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18), 0 0 0 0.5px rgb(0 0 0 / 0.08);
  backdrop-filter: blur(20px);
  font-size: calc(13px * var(--tg-zoom));
}
.menu button {
  width: 100%;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 5px;
  color: var(--tg-ink);
  text-align: left;
}
.menu button:hover:not(:disabled) {
  background: var(--tg-accent);
  color: #fff;
}
.menu button:disabled {
  color: var(--tg-faint);
}
.menu button.destructive {
  color: var(--tg-bad);
}
.menu hr {
  border: 0;
  height: 1px;
  margin: 5px 10px;
  background: var(--tg-line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--tg-ink);
  color: var(--tg-canvas);
  font-size: calc(13px * var(--tg-zoom));
  z-index: 60;
}

/* Narrow windows: below 860 the list folds to the rail (handled in JS); below 600 the rail stays and tabs scroll. */
@media (max-width: 600px) {
  .tab {
    min-width: 96px;
  }
}
