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

:root {
  --win-blue: #0078d4;
  --win-blue-dark: #005a9e;
  --win-bg: #f3f3f3;
  --win-border: #d1d1d1;
  --win-hover: #e5f3ff;
  --win-selected: #cce8ff;
  --win-text: #1a1a1a;
  --win-text-muted: #616161;
  --title-bar-bg: #f9f9f9;
  --sidebar-bg: #f9f9f9;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: linear-gradient(135deg, #1e3a5f 0%, #0d2137 50%, #1a4a6e 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--win-text);
}

.hidden {
  display: none !important;
}

/* ── Login screen ── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 90%;
}

.login-logo {
  margin-bottom: 16px;
}

.login-logo img {
  display: block;
  margin: 0 auto;
}

.window-logo {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 3px;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-brand {
  font-size: 0.9rem;
  color: var(--win-text-muted);
  margin-bottom: 12px;
}

.login-about {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--win-text-muted);
  line-height: 1.5;
}

.login-about a {
  color: var(--win-blue);
  text-decoration: none;
}

.login-about a:hover {
  text-decoration: underline;
}

.login-card p {
  color: var(--win-text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
  line-height: 1.5;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--win-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 12px 28px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--win-blue-dark);
}

.login-error {
  margin-top: 16px;
  padding: 10px 12px;
  background: #fde7e9;
  color: #a80000;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: left;
}

.login-hint {
  margin-top: 20px !important;
  font-size: 0.78rem !important;
}

.login-verify-notice {
  margin-top: 16px;
  padding: 12px 14px;
  background: #f5f9ff;
  border: 1px solid #cce4f7;
  border-radius: 8px;
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--win-text-muted);
}

.login-verify-notice summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--win-blue-dark);
  list-style: none;
}

.login-verify-notice summary::-webkit-details-marker {
  display: none;
}

.login-verify-notice summary::before {
  content: '▸ ';
}

.login-verify-notice[open] summary::before {
  content: '▾ ';
}

.login-verify-notice ol {
  margin: 10px 0 0 18px;
  padding: 0;
}

.login-verify-notice li + li {
  margin-top: 6px;
}

/* ── Explorer window ── */

.explorer {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.window {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 1100px;
  height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--win-border);
}

/* Title bar */
.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--title-bar-bg);
  border-bottom: 1px solid var(--win-border);
  padding: 0 8px 0 12px;
  height: 36px;
  flex-shrink: 0;
  user-select: none;
}

.title-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.window-icon {
  font-size: 0.9rem;
}

.title-bar-controls {
  display: flex;
  gap: 2px;
}

.title-btn {
  width: 36px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  color: var(--win-text);
}

.title-btn:hover {
  background: #e0e0e0;
}

.title-btn.close:hover {
  background: #e81123;
  color: #fff;
}

/* Ribbon */
.ribbon {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--win-border);
  background: #fff;
  flex-shrink: 0;
}

.nav-buttons,
.view-toggle {
  display: flex;
  gap: 2px;
}

.tool-btn {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--win-text);
}

.tool-btn:hover:not(:disabled) {
  background: var(--win-hover);
  border-color: var(--win-border);
}

.tool-btn.active {
  background: var(--win-selected);
  border-color: #99d1ff;
}

.tool-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.address-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--win-border);
  border-radius: 4px;
  padding: 4px 6px 4px 10px;
  min-height: 30px;
  overflow: hidden;
}

.address-copy-btn {
  flex-shrink: 0;
  width: 28px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0.7;
}

.address-copy-btn:hover {
  background: var(--win-hover);
  opacity: 1;
}

.address-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.82rem;
}

.breadcrumb-item {
  color: var(--win-blue);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
}

.breadcrumb-item:hover {
  background: var(--win-hover);
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--win-text-muted);
  font-size: 0.7rem;
  user-select: none;
}

.breadcrumb-current {
  color: var(--win-text);
  font-weight: 500;
  padding: 2px 4px;
}

/* Main area */
.main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--win-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-section {
  padding: 12px 0;
  flex: 1;
}

.sidebar-tree-section {
  overflow-y: auto;
  min-height: 0;
  padding: 8px 0;
}

.sidebar-tree {
  list-style: none;
}

.tree-children {
  list-style: none;
}

.tree-level-1 {
  margin: 2px 0 4px 12px;
  padding-left: 8px;
  border-left: 1px solid var(--win-border);
}

.tree-level-2 {
  margin: 0 0 4px 10px;
  padding-left: 6px;
  border-left: 1px solid #ebebeb;
}

.tree-root-node,
.tree-user-node,
.tree-section-node,
.tree-folder-node {
  margin-bottom: 2px;
}

.tree-root-node.collapsed > .tree-level-1,
.tree-user-node.collapsed > .tree-level-2,
.tree-section-node.collapsed > .tree-level-3,
.tree-folder-node.collapsed > .tree-children {
  display: none;
}

.tree-row {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border-radius: 4px;
  margin: 0 6px;
}

.tree-row:hover > .tree-toggle {
  color: var(--win-text);
}

.tree-row:hover > .sidebar-item:not(.active) {
  background: var(--win-hover);
}

.tree-row:focus-within {
  outline: 1px solid #c2e0f7;
  outline-offset: -1px;
}

.tree-row > .sidebar-item {
  flex: 1;
  min-width: 0;
  padding: 6px 10px 6px 4px !important;
  border-left-width: 3px;
}

.tree-toggle {
  width: 26px;
  min-height: 30px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--win-text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.12s ease, color 0.12s ease;
}

.tree-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--win-text);
}

.tree-toggle:focus-visible {
  outline: 2px solid var(--win-blue);
  outline-offset: -2px;
}

.tree-chevron {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  margin-top: -2px;
}

.tree-toggle[aria-expanded="false"] .tree-chevron {
  transform: rotate(-45deg);
  margin-top: 0;
  margin-left: 2px;
}

.tree-toggle-spacer {
  width: 26px;
  flex-shrink: 0;
}

.tree-level-3,
.tree-level-folder {
  margin: 0 0 2px 10px;
  padding-left: 6px;
  border-left: 1px solid #ebebeb;
}

.tree-folder-item {
  padding-left: 4px !important;
  font-size: 0.78rem !important;
  gap: 6px !important;
}

.tree-folder-label,
.tree-file-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-file-item {
  padding-left: 4px !important;
  font-size: 0.76rem !important;
  gap: 6px !important;
  opacity: 0.9;
}

.tree-more-item {
  padding-left: 4px !important;
  font-size: 0.85rem !important;
  color: var(--win-blue) !important;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.tree-more-item:hover {
  text-decoration: underline;
}

.tree-user-btn {
  align-items: flex-start !important;
}

.tree-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 2px;
}

.tree-user-quota {
  font-size: 0.68rem;
  color: var(--win-text-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-user-quota-reauth {
  color: var(--win-blue);
  cursor: pointer;
  text-decoration: underline;
}

.tree-child-item {
  font-size: 0.8rem !important;
  gap: 8px !important;
}

.tree-add-btn {
  margin-left: 32px;
  width: calc(100% - 44px);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  color: var(--win-text);
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: var(--win-hover);
}

.sidebar-item.active {
  background: var(--win-selected);
  border-left-color: var(--win-blue);
  font-weight: 500;
}

.sidebar-icon {
  font-size: 1rem;
}

.sidebar-add-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 24px);
  margin: 4px 12px 8px;
  padding: 8px 12px;
  border: 1px dashed var(--win-border);
  border-radius: 4px;
  background: transparent;
  font-size: 0.82rem;
  color: var(--win-blue);
  cursor: pointer;
  text-align: left;
}

.sidebar-add-btn:hover {
  background: var(--win-hover);
  border-color: var(--win-blue);
}

.user-drive-item {
  gap: 8px;
}

.sidebar-user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
}

.local-drive-icon,
.local-storage-icon-wrap {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.local-storage-icon {
  flex-shrink: 0;
  color: var(--win-blue);
}

.file-icon .local-storage-icon {
  width: 40px;
  height: 40px;
}

.file-icon-wrap--small .local-storage-icon {
  width: 20px;
  height: 20px;
}

.file-icon-wrap--tiny .local-storage-icon {
  width: 18px;
  height: 18px;
}

.sidebar-user-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-drive-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.list-icon .user-drive-avatar {
  width: 20px;
  height: 20px;
}

/* Content */
.content {
  flex: 1;
  overflow: auto;
  position: relative;
  background: #fff;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.85);
  z-index: 10;
  font-size: 0.9rem;
  color: var(--win-text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--win-border);
  border-top-color: var(--win-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.error-banner {
  background: #fde7e9;
  color: #a80000;
  padding: 10px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid #f1aeb5;
}

/* Grid view */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 4px;
  padding: 12px;
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  border: 1px solid transparent;
  position: relative;
  -webkit-touch-callout: none;
}

.file-item:hover {
  background: var(--win-hover);
  border-color: #c2e0f7;
}

.file-item.selected {
  background: var(--win-selected);
  border-color: #99d1ff;
}

.file-item--pending {
  opacity: 0.82;
}

.file-item--pending-syncing,
.file-item--pending-saving,
.file-item--pending-moving,
.file-item--pending-kind-delete.file-item--pending-syncing {
  border-color: #f5d66b;
  background: #fffbe6;
}

.file-item--pending-kind-delete.file-item--pending-syncing {
  border-color: #f4a4a4;
  background: #fff5f5;
}

.file-item--pending-pending {
  border-color: #99c2ff;
  background: #eef5ff;
}

.file-item--pending-kind-delete.file-item--pending-pending {
  border-color: #f4a4a4;
  background: #fff5f5;
}

.file-item--pending-error {
  border-color: #f5a8a8;
  background: #fff1f1;
}

.file-pending-badge {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--win-text-muted);
}

.file-pending-badge--syncing,
.file-pending-badge--saving,
.file-pending-badge--moving {
  color: #9a6700;
}

.file-item--pending-kind-delete .file-pending-badge--syncing,
.file-item--pending-kind-delete .file-pending-badge--pending {
  color: #b42318;
}

.file-pending-badge--pending {
  color: #175cd3;
}

.file-pending-badge--error {
  color: #b42318;
}

.list-row.file-item--pending-syncing,
.list-row.file-item--pending-saving,
.list-row.file-item--pending-moving {
  background: #fffbe6;
}

.list-row.file-item--pending-kind-delete.file-item--pending-syncing,
.list-row.file-item--pending-kind-delete.file-item--pending-pending {
  background: #fff5f5;
}

.list-row.file-item--pending-pending {
  background: #eef5ff;
}

.list-row.file-item--pending-error {
  background: #fff1f1;
}

.file-item.drag-source,
.list-row.drag-source {
  opacity: 0.55;
}

.file-item.drop-target-active,
.list-row.drop-target-active,
.sidebar-item.drop-target-active {
  background: var(--win-selected);
  outline: 2px dashed var(--win-blue);
  outline-offset: -2px;
}

.file-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.file-icon .file-icon-shell {
  width: 100%;
  height: 100%;
}

.file-icon-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.file-icon-shell__content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-icon-progress {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 0;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
  pointer-events: none;
}

.file-icon-shell.file-icon-wrap--small .file-icon-progress,
.file-icon-shell.file-icon-wrap--tiny .file-icon-progress {
  height: 3px;
  left: 0;
  right: 0;
}

.file-icon-progress__bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #0078d4, #00a2ed);
  transition: width 0.2s linear;
}

.file-item--pending-syncing .file-icon-progress__bar,
.file-item--pending-saving .file-icon-progress__bar,
.file-item--pending-moving .file-icon-progress__bar {
  background: linear-gradient(90deg, #b78103, #f5d66b);
}

.file-item--pending-pending .file-icon-progress__bar {
  background: linear-gradient(90deg, #175cd3, #84caff);
}

.file-item--pending-kind-delete .file-icon-progress {
  height: 5px;
  background: rgba(180, 35, 24, 0.16);
}

.file-item--pending-kind-delete .file-icon-progress__bar {
  min-width: 14%;
  background: linear-gradient(90deg, #b42318, #f97066);
}

.file-item--pending-kind-delete.file-item--pending-pending .file-icon-progress__bar {
  background: linear-gradient(90deg, #912018, #fda29b);
}

.list-icon .file-icon-shell {
  width: 20px;
  height: 20px;
}

.sidebar-icon .file-icon-shell {
  width: 18px;
  height: 18px;
}

.file-icon-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-icon-wrap--small {
  width: 20px;
  height: 20px;
}

.file-icon-wrap--tiny {
  width: 18px;
  height: 18px;
}

.file-type-fallback {
  font-size: 2.2rem;
  line-height: 1;
}

.file-icon-wrap--small .file-type-fallback,
.file-icon-wrap--tiny .file-type-fallback {
  font-size: 1rem;
}

.file-icon-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.file-icon-wrap img.loaded {
  opacity: 1;
}

.file-name {
  font-size: 0.78rem;
  line-height: 1.3;
  word-break: break-word;
  max-width: 90px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.file-quota {
  font-size: 0.65rem;
  color: var(--win-text-muted);
  margin-top: 3px;
  max-width: 90px;
  line-height: 1.2;
  word-break: break-word;
}

/* List view */
.file-list {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.list-header {
  display: grid;
  grid-template-columns: 1fr 140px 90px 120px;
  padding: 6px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--win-text-muted);
  border-bottom: 1px solid var(--win-border);
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
  z-index: 2;
}

.list-body {
  flex: 1;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr 140px 90px 120px auto;
  padding: 4px 16px;
  font-size: 0.82rem;
  cursor: pointer;
  align-items: center;
  border: 1px solid transparent;
  -webkit-touch-callout: none;
}

.list-row:hover {
  background: var(--win-hover);
}

.list-row.selected {
  background: var(--win-selected);
  border-color: #99d1ff;
}

.list-row .col-name {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.list-row .col-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-name-text {
  min-width: 0;
}

.list-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.list-icon .file-icon-wrap,
.list-icon .file-type-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--win-text-muted);
  gap: 8px;
}

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

/* Status bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  font-size: 0.75rem;
  color: var(--win-text-muted);
  border-top: 1px solid var(--win-border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}

/* Context menu */
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--win-border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  padding: 4px 0;
  font-size: 0.82rem;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--win-text);
}

.ctx-item:hover:not(:disabled) {
  background: var(--win-hover);
}

.ctx-item:disabled {
  opacity: 0.4;
  cursor: default;
}

.ctx-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.ctx-label {
  flex: 1;
}

.ctx-shortcut {
  color: var(--win-text-muted);
  font-size: 0.72rem;
}

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

.ctx-header {
  padding: 6px 14px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--win-text-muted);
}

.context-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.45);
}

.context-menu--sheet {
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  bottom: 0;
  min-width: 0;
  max-width: none;
  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 0;
  border: none;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.22);
  animation: ctx-sheet-in 0.22s ease-out;
}

@keyframes ctx-sheet-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.ctx-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--win-border);
  background: var(--sidebar-bg);
}

.ctx-sheet-title {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ctx-sheet-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #e8e8e8;
  cursor: pointer;
  font-size: 0.9rem;
}

.ctx-sheet-body {
  max-height: min(60dvh, 420px);
  overflow-y: auto;
  padding: 4px 0 calc(8px + env(safe-area-inset-bottom, 0));
  -webkit-overflow-scrolling: touch;
}

body.ctx-open {
  overflow: hidden;
}

.item-more-btn {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--win-text-muted);
  cursor: pointer;
}

.item-more-btn:active,
.item-more-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--win-blue);
}

.tree-item-more {
  margin-left: auto;
  width: 36px;
  height: 36px;
}

.empty-hint {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--win-text-muted);
  text-align: center;
  max-width: 240px;
}

/* Notepad */
body.notepad-page {
  display: block;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f0f0f0;
  overflow: hidden;
  font-family: var(--font);
  color: var(--win-text);
}

.notepad-page .notepad-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
}

.notepad-page .notepad-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  background: #fff;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}

.notepad-page .notepad-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: env(safe-area-inset-top, 0) 4px 0 12px;
  background: var(--title-bar-bg);
  border-bottom: 1px solid var(--win-border);
  flex-shrink: 0;
  user-select: none;
}

.notepad-page .title-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.notepad-page .notepad-app-icon {
  flex-shrink: 0;
  color: var(--win-blue);
}

.notepad-page .title-bar-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.notepad-page .title-btn {
  width: 36px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  color: var(--win-text);
  transition: background 0.12s ease;
}

.notepad-page .title-btn:hover:not(:disabled) {
  background: #e0e0e0;
}

.notepad-page .title-btn.close:hover:not(:disabled) {
  background: #e81123;
  color: #fff;
}

.notepad-page .title-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.notepad-page .notepad-title {
  font-size: 0.82rem;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notepad-page .notepad-menubar {
  display: flex;
  gap: 2px;
  background: #fff;
  border-bottom: 1px solid #ebebeb;
  padding: 2px 6px;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.notepad-page .notepad-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #fafafa;
  border-bottom: 1px solid var(--win-border);
  flex-shrink: 0;
}

.notepad-page .notepad-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--win-border);
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--win-text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.notepad-page .notepad-tool-btn:hover {
  background: var(--win-hover);
  border-color: #99d1ff;
}

.notepad-page .notepad-tool-btn--primary {
  background: var(--win-blue);
  border-color: var(--win-blue-dark);
  color: #fff;
}

.notepad-page .notepad-tool-btn--primary:hover {
  background: var(--win-blue-dark);
  border-color: var(--win-blue-dark);
}

.notepad-page .notepad-tool-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.notepad-page .notepad-tool-btn:disabled:hover {
  background: #fff;
  border-color: var(--win-border);
}

.notepad-page .notepad-tool-btn--toggle.active {
  background: var(--win-selected);
  border-color: #99d1ff;
  font-weight: 600;
}

.notepad-page .notepad-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--win-border);
  margin: 0 4px;
}

.notepad-page .notepad-find-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px;
  background: #f9f9f9;
  border-bottom: 1px solid var(--win-border);
  flex-shrink: 0;
}

.notepad-page .notepad-find-bar.hidden {
  display: none !important;
}

.notepad-page .notepad-find-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  flex: 1;
  min-width: 200px;
}

.notepad-page .notepad-find-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.notepad-page .notepad-find-label {
  font-size: 0.78rem;
  color: var(--win-text-muted);
  flex-shrink: 0;
}

.notepad-page .notepad-find-input {
  width: min(220px, 36vw);
  padding: 5px 8px;
  border: 1px solid var(--win-border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.82rem;
  background: #fff;
}

.notepad-page .notepad-find-input:focus {
  outline: none;
  border-color: var(--win-blue);
  box-shadow: 0 0 0 1px var(--win-blue);
}

.notepad-page .notepad-find-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.notepad-page .notepad-find-btn {
  padding: 4px 10px;
  border: 1px solid var(--win-border);
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--win-text);
}

.notepad-page .notepad-find-btn:hover {
  background: var(--win-hover);
  border-color: #99d1ff;
}

.notepad-page .notepad-find-btn--close {
  min-width: 28px;
  padding: 4px 6px;
}

.notepad-page .notepad-find-status {
  font-size: 0.75rem;
  color: var(--win-text-muted);
  margin-left: auto;
  min-width: 72px;
  text-align: right;
}

.notepad-page .notepad-find-bar:not(.notepad-find-bar--replace) .notepad-find-field--replace,
.notepad-page .notepad-find-bar:not(.notepad-find-bar--replace) .notepad-find-btn--replace {
  display: none;
}

.notepad-page .notepad-banner {
  padding: 8px 14px;
  font-size: 0.78rem;
  background: #fff4ce;
  border-bottom: 1px solid #f5e6a8;
  color: #7a5c00;
  flex-shrink: 0;
}

.notepad-page .notepad-banner--error {
  background: #fde7e9;
  border-bottom-color: #f1aeb5;
  color: #a80000;
}

.notepad-page .notepad-menu {
  position: relative;
}

.notepad-page .notepad-menu-label {
  display: block;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: default;
  user-select: none;
  transition: background 0.1s ease;
}

.notepad-page .notepad-menu:hover .notepad-menu-label,
.notepad-page .notepad-menu.open .notepad-menu-label {
  background: var(--win-hover);
}

.notepad-page .notepad-menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--win-border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  padding: 4px 0;
  z-index: 10;
}

.notepad-page .notepad-menu.open .notepad-menu-dropdown {
  display: block;
}

.notepad-page .notepad-menu-dropdown button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--win-text);
  transition: background 0.1s ease;
}

.notepad-page .notepad-menu-dropdown button:hover,
.notepad-page .notepad-menu-dropdown button:focus-visible {
  background: var(--win-hover);
  outline: none;
}

.notepad-page .notepad-menu-dropdown button.active {
  font-weight: 600;
}

.notepad-page .notepad-menu-dropdown button.active::before {
  content: '✓ ';
}

.notepad-page .notepad-menu-sep {
  height: 1px;
  background: var(--win-border);
  margin: 4px 8px;
}

.notepad-page .notepad-kbd {
  color: var(--win-text-muted);
  font-size: 0.72rem;
  margin-left: 24px;
  font-family: var(--font);
}

.notepad-page .notepad-editor-area {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.notepad-page .notepad-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.85rem;
  color: var(--win-text-muted);
}

.notepad-page .notepad-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e8e8e8;
  border-top-color: var(--win-blue);
  border-radius: 50%;
  animation: notepad-spin 0.7s linear infinite;
}

@keyframes notepad-spin {
  to { transform: rotate(360deg); }
}

.notepad-page .notepad-editor {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 12px 16px;
  font: 14px/1.5 'Cascadia Mono', 'Consolas', 'Lucida Console', 'Courier New', monospace;
  color: #1a1a1a;
  background: #fff;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  -moz-tab-size: 4;
  caret-color: var(--win-blue);
}

.notepad-page .notepad-editor::selection {
  background: #cce8ff;
}

.notepad-page .notepad-editor:disabled {
  color: var(--win-text-muted);
  cursor: wait;
}

.notepad-page .notepad-editor--wrap {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.notepad-page .notepad-editor::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.notepad-page .notepad-editor::-webkit-scrollbar-thumb {
  background: #c4c4c4;
  border-radius: 5px;
  border: 2px solid #fff;
}

.notepad-page .notepad-editor::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.notepad-page .notepad-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  padding: 3px 12px;
  padding-bottom: calc(3px + env(safe-area-inset-bottom, 0));
  font-size: 0.72rem;
  background: #f0f0f0;
  border-top: 1px solid #d9d9d9;
  flex-shrink: 0;
  color: var(--win-text-muted);
  user-select: none;
}

.notepad-page #notepad-modified {
  min-width: 12px;
  font-weight: 700;
  color: #c42b1c;
}

.notepad-page #notepad-status {
  flex: 1;
  text-align: center;
  color: var(--win-blue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notepad-page #notepad-position {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

#notepad-status {
  flex: 1;
  text-align: center;
  color: var(--win-blue);
}

.notepad-dialog {
  position: fixed;
  inset: 0;
  z-index: 1002;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.notepad-window {
  background: #fff;
  border: 1px solid var(--win-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: min(900px, 96vw);
  height: min(640px, 90vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notepad-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--title-bar-bg);
  border-bottom: 1px solid var(--win-border);
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

.notepad-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notepad-close {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.notepad-close:hover {
  background: #e0e0e0;
}

.notepad-menubar {
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--win-border);
  background: #fafafa;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.notepad-menu {
  position: relative;
}

.notepad-menu-label {
  display: block;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: default;
  user-select: none;
}

.notepad-menu:hover .notepad-menu-label,
.notepad-menu.open .notepad-menu-label {
  background: var(--win-hover);
}

.notepad-menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--win-border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  padding: 4px 0;
  z-index: 10;
}

.notepad-menu.open .notepad-menu-dropdown {
  display: block;
}

.notepad-menu-dropdown button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 0.8rem;
}

.notepad-menu-dropdown button:hover,
.notepad-menu-dropdown button:focus-visible {
  background: var(--win-hover);
  outline: none;
}

.notepad-menu-dropdown button.active {
  font-weight: 600;
}

.notepad-menu-dropdown button.active::before {
  content: '✓ ';
}

.notepad-menu-sep {
  height: 1px;
  background: var(--win-border);
  margin: 4px 8px;
}

.notepad-kbd {
  color: var(--win-text-muted);
  font-size: 0.72rem;
  margin-left: 24px;
}

.notepad-editor-area {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.notepad-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.85rem;
  color: var(--win-text-muted);
}

.notepad-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e8e8e8;
  border-top-color: var(--win-blue);
  border-radius: 50%;
  animation: notepad-spin 0.7s linear infinite;
}

.notepad-editor {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  resize: none;
  padding: 12px 16px;
  font: 14px/1.5 'Cascadia Mono', 'Consolas', 'Courier New', monospace;
  color: #1a1a1a;
  background: #fff;
  outline: none;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  caret-color: var(--win-blue);
}

.notepad-editor:disabled {
  color: var(--win-text-muted);
  cursor: wait;
}

.notepad-editor--wrap {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.notepad-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 12px;
  border-top: 1px solid var(--win-border);
  background: #f0f0f0;
  font-size: 0.72rem;
  color: var(--win-text-muted);
  flex-shrink: 0;
}

#notepad-modified {
  min-width: 12px;
  font-weight: 700;
  color: #c42b1c;
}

/* Properties dialog */
.props-dialog {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.props-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.props-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--win-border);
  background: var(--sidebar-bg);
}

.props-title {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.props-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 4px;
}

.props-close:hover {
  background: #e0e0e0;
}

.props-body {
  padding: 8px 0 12px;
  overflow-y: auto;
  flex: 1;
}

.props-section {
  padding: 10px 16px 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--win-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--win-border);
  border-bottom: 1px solid var(--win-border);
  margin-top: 4px;
}

.props-section:first-child {
  margin-top: 0;
}

.props-loading,
.props-error {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--win-text-muted);
}

.props-error {
  color: #a80000;
}

.props-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  padding: 7px 16px;
  font-size: 0.82rem;
  border-bottom: 1px solid #f5f5f5;
}

.props-row:last-child {
  border-bottom: none;
}

.props-key {
  color: var(--win-text-muted);
}

/* App dialog (replaces alert / confirm / prompt) */
.app-dialog {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.app-dialog-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-dialog-card--wide {
  max-width: min(560px, 96vw);
}

.app-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--win-border);
  background: var(--sidebar-bg);
}

.app-dialog-title {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-dialog-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

.app-dialog-close:hover {
  background: #e0e0e0;
}

.app-dialog-body {
  padding: 16px;
}

.app-dialog-message {
  margin: 0 0 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--win-text);
  white-space: pre-wrap;
  user-select: text;
  cursor: text;
}

.app-dialog-message--html {
  white-space: normal;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  padding-right: 4px;
}

.app-dialog-message--html p {
  margin: 0 0 8px;
}

.app-dialog-lead {
  font-weight: 600;
}

.app-dialog-section {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--win-border, rgba(0, 0, 0, 0.12));
}

.app-dialog-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.app-dialog-section-title {
  margin: 0 0 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.app-dialog-section-label {
  margin: 8px 0 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--win-text-muted);
}

.app-dialog-section-link {
  margin: 0 0 4px;
}

.app-dialog-section-note {
  margin: 0 0 8px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--win-text-muted);
}

.app-dialog-message a {
  color: var(--win-accent, #0078d4);
  text-decoration: underline;
  cursor: pointer;
}

.app-dialog-perms,
.app-dialog-steps {
  margin: 4px 0 8px;
  padding-left: 1.25rem;
}

.app-dialog-perms li,
.app-dialog-steps li {
  margin: 4px 0;
}

.app-dialog-message code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

.app-dialog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-dialog-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-dialog-label {
  font-size: 0.82rem;
  color: var(--win-text-muted);
}

.app-dialog-hint {
  font-size: 0.76rem;
  color: var(--win-text-muted);
  line-height: 1.4;
}

.app-dialog-range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-dialog-range {
  flex: 1;
  accent-color: var(--win-blue);
}

.app-dialog-range-value {
  min-width: 72px;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: right;
  color: var(--win-text);
}

.app-dialog-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--win-border);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
}

.app-dialog-input:focus {
  outline: none;
  border-color: var(--win-blue);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15);
}

.app-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--win-border);
  background: #fafafa;
}

.btn-dialog {
  padding: 8px 16px;
  border: 1px solid var(--win-border);
  border-radius: 4px;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-dialog:hover {
  background: var(--win-hover);
}

.app-dialog-footer .btn-primary {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-danger {
  background: #c42b1c;
}

.btn-danger:hover {
  background: #a32315;
}

body.dialog-open {
  overflow: hidden;
}

.props-val {
  word-break: break-word;
}

.props-val a {
  color: var(--win-blue);
  text-decoration: none;
}

.props-val a:hover {
  text-decoration: underline;
}

/* Mobile helpers */
.mobile-only {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .mobile-only {
    display: flex;
  }

  .login-card {
    padding: 32px 20px;
    border-radius: 0;
    max-width: none;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: none;
  }

  .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .explorer {
    padding: 0;
    align-items: stretch;
  }

  .window {
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    border: none;
    box-shadow: none;
  }

  .title-bar {
    height: 40px;
    padding-top: env(safe-area-inset-top, 0);
  }

  .title-btn {
    width: 40px;
    height: 36px;
  }

  .ribbon {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }

  .nav-buttons,
  .view-toggle {
    flex-shrink: 0;
  }

  .tool-btn {
    width: 40px;
    height: 40px;
  }

  .address-bar {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    min-height: 36px;
  }

  .address-copy-btn {
    width: 36px;
    height: 32px;
  }

  .breadcrumbs {
    font-size: 0.78rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .main-area {
    position: relative;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 90;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: min(300px, 88vw);
    max-width: 88vw;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-item,
  .sidebar-add-btn,
  .tree-toggle {
    min-height: 40px;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .file-item {
    min-height: 108px;
    padding: 28px 4px 8px;
    position: relative;
  }

  .file-item .item-more-btn {
    display: flex;
    position: absolute;
    top: 2px;
    right: 2px;
    width: 36px;
    height: 36px;
  }

  .file-icon-wrap {
    width: 40px;
    height: 40px;
  }

  .file-name {
    font-size: 0.72rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .list-header,
  .list-row {
    grid-template-columns: 1fr auto;
    font-size: 0.78rem;
  }

  .list-header .col-modified,
  .list-header .col-size,
  .list-header .col-type {
    display: none;
  }

  .col-size,
  .col-type,
  .col-modified {
    display: none;
  }

  .list-row {
    min-height: 52px;
    padding: 6px 4px 6px 8px;
    gap: 4px;
  }

  .list-row .item-more-btn {
    display: flex;
  }

  .list-row .col-name {
    min-width: 0;
  }

  .tree-row {
    padding-right: 2px;
  }

  .tree-row .tree-item-more {
    display: flex;
  }

  .tree-row > .sidebar-item {
    min-width: 0;
  }

  .context-menu {
    z-index: 1001;
  }

  .context-menu:not(.context-menu--sheet) {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }

  .context-menu button,
  .context-menu .ctx-item {
    min-height: 48px;
    padding: 12px 16px;
  }

  .props-dialog {
    padding: 0;
    align-items: stretch;
  }

  .props-card {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .app-dialog {
    padding: 0;
    align-items: flex-end;
  }

  .app-dialog-card {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
  }

  .app-dialog-footer .btn-dialog,
  .app-dialog-footer .btn-primary {
    min-height: 44px;
    flex: 1;
  }

  .app-dialog-footer {
    flex-wrap: wrap;
  }

  .props-row {
    grid-template-columns: 110px 1fr;
  }

  .status-bar {
    padding-bottom: env(safe-area-inset-bottom, 0);
    font-size: 0.72rem;
  }

  .notepad-page .notepad-titlebar {
    height: 40px;
    padding-top: env(safe-area-inset-top, 0);
  }

  .notepad-page .title-btn {
    width: 40px;
    height: 36px;
  }

  .notepad-page .notepad-toolbar {
    padding: 8px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .notepad-page .notepad-tool-btn {
    min-height: 36px;
    padding: 8px 14px;
  }

  .notepad-page .notepad-menubar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .notepad-page .notepad-menu-label {
    padding: 8px 12px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  .notepad-page .notepad-editor {
    font-size: 16px;
    padding: 12px 14px;
  }

  .notepad-page .notepad-statusbar {
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0));
    font-size: 0.7rem;
    flex-wrap: wrap;
    gap: 4px 10px;
  }
}

@media (max-width: 420px) {
  .window-title {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  }
}

/* Legal pages */
body.legal-page {
  display: block;
  min-height: 100vh;
  padding: 24px 16px 32px;
}

.legal-shell {
  max-width: 760px;
  margin: 0 auto;
}

.legal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.legal-nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.legal-nav a {
  color: #d7ecff;
  text-decoration: none;
  font-size: 0.9rem;
}

.legal-nav a:hover,
.legal-nav a[aria-current="page"] {
  color: #fff;
  text-decoration: underline;
}

.legal-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  color: var(--win-text);
  line-height: 1.65;
}

.legal-card h1 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.legal-meta {
  color: var(--win-text-muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.legal-card h2 {
  font-size: 1.05rem;
  margin: 24px 0 10px;
}

.legal-card p,
.legal-card li {
  font-size: 0.94rem;
  margin-bottom: 10px;
}

.legal-card ul {
  padding-left: 1.25rem;
  margin-bottom: 12px;
}

.legal-card a {
  color: var(--win-blue);
}

.legal-card code {
  background: #f3f3f3;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.86em;
}

.legal-footer {
  margin-top: 20px;
  text-align: center;
  color: #d7ecff;
  font-size: 0.88rem;
}

.legal-footer a {
  color: #d7ecff;
  text-decoration: none;
}

.legal-footer a:hover {
  color: #fff;
  text-decoration: underline;
}

.login-footer {
  margin-top: 20px;
  font-size: 0.78rem;
  color: var(--win-text-muted);
  line-height: 1.6;
}

.login-footer a {
  color: var(--win-blue);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  body.legal-page {
    padding: 16px 12px 24px;
  }

  .legal-card {
    padding: 24px 18px;
    border-radius: 8px;
  }
}
