/* Cloud – plain, utilitarian file manager styles. Dark by default. */
:root,
:root[data-theme='dark'] {
  --bg: #1b1b1b;
  --side: #202020;
  --surface: #242424;
  --surface-2: #2b2b2b;
  --hover: #262626;
  --active: #2f2f2f;
  --border: #333;
  --border-soft: #2a2a2a;
  --border-strong: #454545;
  --text: #e6e6e6;
  --text-2: #a8a8a8;
  --text-3: #7d7d7d;
  --accent: #4a8fd9;
  --accent-strong: #3b7cc4;
  --accent-text: #fff;
  --accent-soft: rgba(74, 143, 217, 0.16);
  --sel: rgba(74, 143, 217, 0.17);
  --danger: #e2675f;
  --danger-soft: rgba(226, 103, 95, 0.14);
  --warn: #d6a23a;
  --ok: #5fae74;
  --folder: #d4a94f;
  --k-image: #5fae74;
  --k-video: #d27a5a;
  --k-audio: #c99a44;
  --k-pdf: #d65f5f;
  --k-text: #6f9fd6;
  --k-archive: #a89a7c;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --input: #1f1f1f;
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #ffffff;
  --side: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #f3f3f3;
  --hover: #f3f5f8;
  --active: #e9ecf0;
  --border: #e0e0e0;
  --border-soft: #ececec;
  --border-strong: #c9c9c9;
  --text: #1d1d1d;
  --text-2: #5c5c5c;
  --text-3: #8a8a8a;
  --accent: #1f6fc5;
  --accent-strong: #195ca6;
  --accent-text: #fff;
  --accent-soft: rgba(31, 111, 197, 0.1);
  --sel: rgba(31, 111, 197, 0.1);
  --danger: #c6362e;
  --danger-soft: rgba(198, 54, 46, 0.08);
  --warn: #b7800f;
  --ok: #2f8a49;
  --folder: #c99a2e;
  --k-image: #2f8a49;
  --k-video: #c2582f;
  --k-audio: #a87414;
  --k-pdf: #c53b3b;
  --k-text: #2f6db3;
  --k-archive: #7d6d4c;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  --input: #fff;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
[hidden] {
  display: none !important;
}
a {
  color: var(--accent);
  text-decoration: none;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.muted {
  color: var(--text-2);
}
.small {
  font-size: 12.5px;
}
.mono {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
  font-size: 12.5px;
}
.grow {
  flex: 1;
}
.warn-text {
  color: var(--warn);
}

/* ---- Icons ---------------------------------------------------------- */
.ic {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic.flip {
  transform: rotate(180deg);
}
.k-folder {
  color: var(--folder);
}
.k-image {
  color: var(--k-image);
}
.k-video {
  color: var(--k-video);
}
.k-audio {
  color: var(--k-audio);
}
.k-pdf {
  color: var(--k-pdf);
}
.k-text {
  color: var(--k-text);
}
.k-archive {
  color: var(--k-archive);
}
.k-file {
  color: var(--text-2);
}

/* ---- Buttons & fields ------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
  font-size: 13.5px;
}
.btn:hover:not(:disabled) {
  background: var(--active);
}
.btn .ic {
  width: 18px;
  height: 18px;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover:not(:disabled) {
  background: var(--hover);
}
.btn.ghost.danger {
  color: var(--danger);
}
.btn.ghost.on {
  color: var(--accent);
}
.btn.danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--border-strong);
}
.btn.danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
}
.btn.block {
  width: 100%;
  height: 40px;
}
.btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}
.ib {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  flex: none;
}
.ib:hover:not(:disabled) {
  background: var(--active);
  color: var(--text);
}
.ib.danger:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}
.ib-space {
  display: inline-block;
  width: 34px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
}
.field > span {
  font-size: 12.5px;
  color: var(--text-2);
}
input[type='text'],
input[type='password'],
input[type='search'],
textarea {
  background: var(--input);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 0 10px;
  height: 36px;
  outline: none;
  min-width: 0;
}
input[type='text']:focus,
input[type='password']:focus,
input[type='search']:focus {
  border-color: var(--accent);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  overflow: hidden;
  flex: none;
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
}
.seg button + button {
  border-left: 1px solid var(--border-strong);
}
.seg button.on {
  background: var(--accent-soft);
  color: var(--text);
}
.seg .ic {
  width: 16px;
  height: 16px;
}
.bar {
  height: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.bar.thin {
  height: 4px;
  border: 0;
  background: var(--active);
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s linear;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 0 6px;
  font-size: 11.5px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--text-2);
}

/* ---- Login ------------------------------------------------------------ */
.boot {
  position: fixed;
  inset: 0;
  background: var(--bg);
}
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 340px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 28px;
}
.login-card input {
  height: 40px;
  font-size: 15px;
}
.form-msg {
  min-height: 20px;
  margin: -6px 0 12px;
  font-size: 13px;
  color: var(--danger);
}
.form-msg.locked,
.form-msg.info {
  color: var(--warn);
}
.login-foot {
  margin-top: 18px;
  font-size: 12.5px;
}

/* ---- App layout --------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--border);
  padding: 14px 10px 12px;
  min-height: 0;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 16px;
  font-size: 17px;
  font-weight: 600;
}
.new-btn {
  justify-content: flex-start;
  height: 38px;
  margin: 0 2px 12px;
  padding: 0 14px;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav a,
.side-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 36px;
  padding: 0 12px;
  border-radius: 5px;
  color: var(--text-2);
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  font-size: 13.5px;
}
.nav a:hover,
.side-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.nav a.active {
  background: var(--active);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav a.active .ic {
  color: var(--accent);
}
.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.storage {
  padding: 10px 12px 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.storage-label {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 7px;
}
.storage-text {
  font-size: 12.5px;
  margin-top: 7px;
}
.storage.warn .bar-fill {
  background: var(--warn);
}
.storage.full .bar-fill {
  background: var(--danger);
}
.scrim {
  display: none;
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.menu-btn,
.topbar-brand,
.search-btn {
  display: none;
}
.search {
  position: relative;
  flex: 1;
  max-width: 560px;
}
.search-ic {
  position: absolute;
  left: 10px;
  top: 8px;
  color: var(--text-3);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 36px;
  padding-left: 38px;
  background: var(--surface-2);
  border-color: transparent;
}
.search input:focus {
  background: var(--input);
}
.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px 96px;
}
.view-inner {
  min-height: 100%;
}
.fab {
  display: none;
}

/* ---- View header / toolbar --------------------------------------------- */
.view-head {
  display: flex;
  align-items: center;
  min-height: 60px;
  padding-top: 6px;
}
.view-title {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
}
.view-title .muted {
  font-weight: 400;
}
.view-note {
  margin: -6px 0 10px;
  font-size: 13px;
}
.crumbs {
  display: flex;
  align-items: center;
  font-size: 19px;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.crumbs::-webkit-scrollbar {
  display: none;
}
.crumb {
  color: var(--text-2);
  padding: 2px 6px;
  border-radius: 4px;
}
.crumb:first-child {
  margin-left: -6px;
}
a.crumb:hover {
  color: var(--text);
  background: var(--hover);
}
.crumb.current {
  color: var(--text);
  font-weight: 600;
}
.crumb-sep {
  color: var(--text-3);
  display: inline-flex;
}
.crumb-sep .ic {
  width: 16px;
  height: 16px;
}
.crumb.drop-target {
  background: var(--sel);
  outline: 1px solid var(--accent);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px 0 8px;
}
.toolbar.selection {
  background: var(--sel);
  border-radius: 6px;
  padding: 4px 6px;
  margin-bottom: 4px;
}
.sel-count {
  font-weight: 600;
  padding-left: 2px;
}
.trash-info {
  padding-right: 12px;
}

/* ---- File list ---------------------------------------------------------- */
.list {
  border-top: 1px solid var(--border);
}
.list.plain {
  border-top: 1px solid var(--border);
}
.list-head,
.row {
  display: grid;
  grid-template-columns: 34px 34px minmax(0, 1fr) 150px 96px 116px;
  align-items: center;
}
.list-head {
  height: 36px;
  font-size: 12.5px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.list.is-empty .list-head {
  display: none;
}
.th {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  height: 100%;
  font-size: inherit;
  white-space: nowrap;
}
.th:hover {
  color: var(--text);
}
.list-head .c-name {
  flex-direction: row;
  padding: 0 12px 0 4px;
  grid-column: 3;
}
.sort-arrow {
  color: var(--text);
  margin-left: 3px;
}
.row {
  min-height: 46px;
  border-bottom: 1px solid var(--border-soft);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}
.row:hover {
  background: var(--hover);
}
.row.selected {
  background: var(--sel);
}
.row.drop-target {
  background: var(--sel);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.c-check {
  display: flex;
  justify-content: center;
}
.cb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--text-3);
  border-radius: 3px;
  cursor: pointer;
  opacity: 0;
}
.cb .ic {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
  color: var(--accent-text);
  visibility: hidden;
}
.cb.on {
  background: var(--accent);
  border-color: var(--accent);
}
.cb.on .ic {
  visibility: visible;
}
.row:hover .cb,
.list-head:hover .cb,
.cb.on,
.cb:focus-visible,
.selecting .cb {
  opacity: 1;
}
.c-icon {
  display: flex;
  align-items: center;
}
.c-icon .ic {
  width: 22px;
  height: 22px;
}
.c-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 6px 12px 6px 4px;
}
.nm-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}
.nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-link,
.badge-star {
  display: inline-flex;
  color: var(--text-3);
  flex: none;
}
.badge-link .ic,
.badge-star .ic {
  width: 14px;
  height: 14px;
}
.badge-star {
  color: var(--warn);
  display: none;
}
.sub {
  display: none;
  font-size: 12.5px;
  color: var(--text-2);
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sub > span + span::before {
  content: '·';
  margin: 0 6px;
  color: var(--text-3);
}
.where {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.where .ic {
  width: 13px;
  height: 13px;
}
.c-date,
.c-size {
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
}
.c-act {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  padding-right: 4px;
}
.c-act .ib {
  width: 32px;
  height: 32px;
}
.c-act .ib .ic {
  width: 18px;
  height: 18px;
}
.star-btn {
  opacity: 0;
}
.row:hover .star-btn,
.star-btn.on,
.star-btn:focus-visible {
  opacity: 1;
}
.star-btn.on {
  color: var(--warn);
}
/* Search & favorites show where an item lives */
.files-view:not(.droppable) .sub {
  display: flex;
}
.files-view .sub .s-meta {
  display: none;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 16px;
  color: var(--text);
}
.empty p {
  margin: 4px 0;
}
.empty .muted {
  max-width: 360px;
}
.empty-ic {
  width: 40px !important;
  height: 40px !important;
  color: var(--text-3);
  margin-bottom: 10px;
  stroke-width: 1.3;
}
.empty-title {
  font-size: 15px;
  font-weight: 600;
}
.empty-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.files-view {
  position: relative;
  min-height: 100%;
}
.drop-hint {
  position: absolute;
  inset: 0;
  min-height: 300px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}
.drop-hint > div {
  position: sticky;
  top: 40%;
  margin-top: 120px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.simple-view .row {
  grid-template-columns: 34px 34px minmax(0, 1fr) auto;
}
.simple-view .share-row {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  padding-left: 8px;
}
.simple-view .sub {
  display: flex;
}
.c-act.wide {
  gap: 4px;
}
.c-act.wide .btn {
  height: 32px;
}

/* ---- Modals --------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}
.modal {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.modal.wide {
  max-width: 640px;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 6px 20px;
}
.modal-head h2 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-body {
  padding: 8px 20px 6px;
  overflow-y: auto;
}
.modal-text {
  margin: 0 0 10px;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
}
.form .field {
  margin: 4px 0 6px;
}
.form input {
  height: 38px;
}
.move-modal .modal-body {
  padding: 4px 8px 4px;
}
.tree {
  min-height: 200px;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 0;
}
.tree-row {
  display: flex;
  align-items: center;
  height: 34px;
  padding-left: calc(4px + var(--depth) * 18px);
  padding-right: 8px;
  cursor: pointer;
}
.tree-row:hover {
  background: var(--hover);
}
.tree-row.active {
  background: var(--sel);
}
.tree-row.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tree-toggle {
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.tree-toggle.none {
  visibility: hidden;
}
.tree-toggle .ic {
  width: 16px;
  height: 16px;
}
.tree-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tree-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-label .ic {
  width: 18px;
  height: 18px;
}

/* Share dialog */
.share-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
}
.share-file .ic {
  width: 26px;
  height: 26px;
}
.share-name {
  font-weight: 600;
  word-break: break-word;
}
.share .field {
  margin: 14px 0 16px;
}
.share-expiry {
  align-self: flex-start;
  flex-wrap: wrap;
}
.share-new {
  margin-top: 12px;
}
.copy-row {
  display: flex;
  gap: 8px;
}
.copy-row input {
  flex: 1;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
}
.share-list-title {
  margin: 18px 0 6px;
  font-size: 12.5px;
  color: var(--text-2);
}
.share-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0 4px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 6px;
}
.share-item-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ZIP progress */
.zip-progress {
  padding: 4px 0 6px;
}
.zp-file {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  margin-bottom: 8px;
}
.zp-stats {
  margin-top: 8px;
  font-size: 12.5px;
}

/* ---- Menus -------------------------------------------------------------- */
.menu-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}
.menu {
  position: fixed;
  min-width: 210px;
  max-width: 300px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  font-size: 13.5px;
  white-space: nowrap;
}
.menu-item .ic {
  width: 18px;
  height: 18px;
  color: var(--text-2);
}
.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
  background: var(--active);
  outline: none;
}
.menu-item.danger,
.menu-item.danger .ic {
  color: var(--danger);
}
.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.menu-title {
  padding: 6px 14px 10px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.menu-layer.sheet {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.5);
}
.menu-layer.sheet .menu {
  left: 0;
  right: 0;
  bottom: 0;
  max-width: none;
  border-radius: 12px 12px 0 0;
  border-width: 1px 0 0;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
}
.menu-layer.sheet .menu-item {
  height: 48px;
  font-size: 15px;
}

/* ---- Toasts --------------------------------------------------------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 4px 4px 4px 16px;
  background: #303030;
  color: #f0f0f0;
  border: 1px solid #404040;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
}
.toast.error {
  border-left: 3px solid var(--danger);
}
.toast-msg {
  flex: 1;
}
.toast-action {
  border: 0;
  background: transparent;
  color: #8fbdf0;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 4px;
}
.toast-action:hover {
  background: #3a3a3a;
}
.toast-close {
  display: inline-flex;
  border: 0;
  background: transparent;
  color: #aaa;
  padding: 6px;
  border-radius: 4px;
}
.toast-close .ic {
  width: 16px;
  height: 16px;
}

/* ---- Upload panel -------------------------------------------------------- */
.uploads {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 380px;
  max-width: calc(100vw - 16px);
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.up-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 6px 6px 14px;
  border-bottom: 1px solid var(--border);
}
.up-title {
  flex: 1;
  font-weight: 600;
  font-size: 13.5px;
}
.uploads.collapsed .up-list {
  display: none;
}
.uploads.collapsed .up-head {
  border-bottom: 0;
}
.up-list {
  overflow-y: auto;
  padding: 4px 0;
}
.up-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
}
.up-icon {
  display: flex;
}
.up-icon .ok {
  color: var(--ok);
}
.up-icon .err {
  color: var(--danger);
}
.up-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.up-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.up-meta {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.s-error .up-meta {
  color: var(--danger);
  white-space: normal;
}
.s-paused .bar-fill {
  background: var(--text-3);
}
.up-acts {
  display: flex;
  align-items: center;
  gap: 2px;
}
.up-acts .ib {
  width: 30px;
  height: 30px;
}
.up-acts .ib .ic {
  width: 17px;
  height: 17px;
}
.up-section {
  padding: 10px 14px 4px;
  font-size: 12px;
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.up-section .muted {
  font-weight: 400;
}
.up-section.first {
  border-top: 0;
  margin-top: 0;
}

/* ---- Preview ---------------------------------------------------------- */
.pv {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #111;
  color: #e8e8e8;
  display: flex;
  flex-direction: column;
}
.pv .ib {
  color: #cfcfcf;
}
.pv .ib:hover {
  background: #2a2a2a;
  color: #fff;
}
.pv-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 10px;
  background: #181818;
  border-bottom: 1px solid #2a2a2a;
  flex: none;
}
.pv-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.pv-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pv-meta {
  font-size: 12px;
  color: #9a9a9a;
}
.pv-actions {
  display: flex;
  gap: 2px;
}
.pv-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.pv-stage .spinner {
  border-color: #444;
  border-top-color: #bbb;
}
.pv-img-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.pv-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}
.pv-img-wrap.zoomed {
  overflow: auto;
  display: block;
}
.pv-img-wrap.zoomed .pv-img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
.pv-video {
  max-width: 100%;
  max-height: 100%;
  background: #000;
}
.pv-audio-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(520px, 92vw);
}
.pv-audio {
  width: 100%;
}
.pv-big-icon .ic {
  width: 64px;
  height: 64px;
  stroke-width: 1.1;
}
.pv-none {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 24px;
  color: #ddd;
}
.pv-none .muted {
  color: #9a9a9a;
}
.pv-none .btn {
  margin-top: 12px;
}
.pv-none-name {
  font-weight: 600;
  word-break: break-word;
  margin: 6px 0 0;
}
.pv-pdf {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.pv-pdfjs {
  background: #2a2a2a;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.pdf-page {
  background: #fff;
  flex: none;
}
.pdf-page canvas {
  display: block;
}
.pv-text {
  width: min(980px, 100%);
  height: 100%;
  overflow: auto;
  background: #1a1a1a;
  border-left: 1px solid #2a2a2a;
  border-right: 1px solid #2a2a2a;
}
.pv-pre {
  margin: 0;
  padding: 18px 22px;
  font: 13px/1.55 ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: #ddd;
}
.pv-note {
  padding: 8px 22px;
  background: #2a2416;
  color: #e6c77a;
  font-size: 12.5px;
}
.pv-seg {
  margin: 14px 22px 0;
  border-color: #444;
}
.pv-seg button {
  color: #aaa;
}
.pv-seg button + button {
  border-color: #444;
}
.pv-seg button.on {
  background: #2e2e2e;
  color: #fff;
}
.pv-md {
  padding: 8px 22px 30px;
  color: #ddd;
}
.pv-nav {
  position: absolute;
  top: 50%;
  margin-top: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #3a3a3a;
  background: #222;
  color: #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.pv-nav:hover {
  background: #2e2e2e;
}
.pv-nav.prev {
  left: 14px;
}
.pv-nav.next {
  right: 14px;
}

/* ---- Notes ---------------------------------------------------------- */
body[data-section='notes'] .view {
  padding: 0;
  overflow: hidden;
}
body[data-section='notes'] .view-inner {
  height: 100%;
}
.notes {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: 100%;
}
.notes-side {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-height: 0;
}
.notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px 18px;
}
.notes-search {
  position: relative;
  margin: 0 14px 10px;
}
.notes-search .ic {
  position: absolute;
  left: 9px;
  top: 8px;
  color: var(--text-3);
  width: 18px;
  height: 18px;
}
.notes-search input {
  width: 100%;
  padding-left: 34px;
  height: 34px;
}
.notes-list {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.note-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
}
.note-item:hover {
  background: var(--hover);
}
.note-item.active {
  background: var(--sel);
  box-shadow: inset 3px 0 0 var(--accent);
}
.note-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  min-width: 0;
}
.note-item-title > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pin-mark {
  display: inline-flex;
  color: var(--accent);
}
.pin-mark .ic {
  width: 14px;
  height: 14px;
}
.note-item-snip {
  grid-column: 1 / -1;
  color: var(--text-2);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-item-date {
  grid-row: 1;
  grid-column: 2;
  font-size: 12px;
  color: var(--text-3);
}
.small-empty {
  padding: 40px 16px;
}
.notes-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px 4px;
}
.back-btn {
  display: none;
}
.note-title:focus-visible,
.note-body:focus-visible {
  outline: none;
}
.note-title {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  background: transparent !important;
  font-size: 21px !important;
  font-weight: 600;
  height: 40px !important;
  padding: 0 !important;
}
.save-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.save-state .ic {
  width: 15px;
  height: 15px;
}
.save-state.saved .ic {
  color: var(--ok);
}
.save-state.error {
  color: var(--danger);
}
.editor-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px 10px 24px;
  border-bottom: 1px solid var(--border);
}
.note-body {
  flex: 1;
  width: 100%;
  border: 0 !important;
  border-radius: 0 !important;
  resize: none;
  padding: 18px 24px 40px !important;
  background: transparent !important;
  font-size: 15px;
  line-height: 1.65;
  height: auto !important;
  tab-size: 2;
}
.note-preview {
  flex: 1;
  overflow-y: auto;
  padding: 10px 24px 40px;
}

/* ---- Markdown -------------------------------------------------------- */
.md {
  line-height: 1.65;
  font-size: 15px;
  max-width: 820px;
  word-wrap: break-word;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  line-height: 1.3;
  margin: 1.2em 0 0.5em;
}
.md h1 {
  font-size: 1.6em;
}
.md h2 {
  font-size: 1.3em;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--border);
}
.md h3 {
  font-size: 1.12em;
}
.md p,
.md ul,
.md ol,
.md blockquote,
.md pre,
.md table {
  margin: 0 0 0.9em;
}
.md code {
  font: 0.88em ui-monospace, 'Cascadia Mono', Consolas, monospace;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.md pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 5px;
  overflow-x: auto;
}
.md pre code {
  background: none;
  padding: 0;
}
.md blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 14px;
  color: var(--text-2);
}
.md table {
  border-collapse: collapse;
}
.md th,
.md td {
  border: 1px solid var(--border);
  padding: 5px 10px;
}
.md img {
  max-width: 100%;
}
.md hr {
  border: 0;
  border-top: 1px solid var(--border);
}
.pv .md code,
.pv .md pre {
  background: #262626;
  border-color: #333;
}

/* ---- Mobile ----------------------------------------------------------- */
@media (max-width: 760px) {
  body {
    font-size: 15px;
  }
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 284px;
    max-width: 86vw;
    z-index: 45;
    transform: translateX(-102%);
    transition: transform 0.18s ease-out;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .nav-open .sidebar {
    transform: none;
    box-shadow: var(--shadow);
  }
  .nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 44;
  }
  .nav a,
  .side-btn {
    height: 44px;
    font-size: 15px;
  }
  .new-btn {
    display: none;
  }
  .topbar {
    height: 54px;
    padding: 0 6px;
    padding-top: env(safe-area-inset-top);
    height: calc(54px + env(safe-area-inset-top));
    gap: 4px;
  }
  .menu-btn,
  .search-btn {
    display: inline-flex;
    width: 42px;
    height: 42px;
  }
  .topbar-brand {
    display: block;
    flex: 1;
    font-weight: 600;
    font-size: 17px;
    padding-left: 4px;
  }
  .search {
    display: none;
  }
  .search-open .search {
    display: block;
    flex: 1;
    max-width: none;
  }
  .search-open .topbar-brand,
  .search-open .search-btn {
    display: none;
  }
  .view {
    padding: 0 12px calc(96px + env(safe-area-inset-bottom));
  }
  .view-head {
    min-height: 52px;
  }
  .crumbs,
  .view-title {
    font-size: 17px;
  }
  .fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    border-radius: 16px;
    border: 0;
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    z-index: 30;
  }
  .fab .ic {
    width: 26px;
    height: 26px;
    stroke-width: 2;
  }
  body:not([data-section='files']):not([data-section='favorites']):not([data-section='search']) .fab,
  body:has(.uploads:not([hidden])) .fab {
    display: none;
  }
  .toolbar .btn:not(.primary) span,
  .toolbar .btn span {
    display: none;
  }
  .toolbar .btn {
    padding: 0 10px;
    height: 38px;
  }
  .toolbar .sort-btn span {
    display: inline;
  }
  .toolbar.selection .btn {
    padding: 0 9px;
  }
  .trash-info {
    font-size: 12px;
  }
  .list-head {
    display: none;
  }
  .row,
  .simple-view .row {
    grid-template-columns: 0 40px minmax(0, 1fr) auto;
    min-height: 58px;
  }
  .selecting .row {
    grid-template-columns: 36px 36px minmax(0, 1fr) auto;
  }
  .simple-view .row {
    grid-template-columns: 36px 36px minmax(0, 1fr) auto;
  }
  .simple-view .share-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    padding-left: 4px;
  }
  .c-check {
    overflow: hidden;
  }
  .cb {
    opacity: 1;
    width: 20px;
    height: 20px;
  }
  .c-date,
  .c-size,
  .star-btn {
    display: none;
  }
  .sub {
    display: flex;
  }
  .files-view .sub .s-meta {
    display: inline;
  }
  .badge-star {
    display: inline-flex;
  }
  .c-act .ib {
    width: 40px;
    height: 40px;
  }
  .ib-space {
    display: none;
  }
  .c-act.wide .btn span {
    display: none;
  }
  .c-act.wide .btn {
    padding: 0 10px;
    height: 38px;
  }
  .empty-actions {
    flex-direction: column;
  }
  .uploads {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
  }
  .toasts {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: none !important;
    border-radius: 12px 12px 0 0;
    border-width: 1px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-foot .btn {
    height: 42px;
    flex: 1;
  }
  .pv-nav {
    display: none;
  }
  .pv-bar {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }
  .notes {
    grid-template-columns: minmax(0, 1fr);
  }
  .notes.has-note .notes-side,
  .notes:not(.has-note) .notes-main {
    display: none;
  }
  .notes-side {
    border-right: 0;
  }
  .back-btn {
    display: inline-flex;
    margin-left: -6px;
  }
  .editor-head {
    padding: 8px 12px 0;
  }
  .editor-tools {
    padding: 4px 12px 8px;
  }
  .editor-tools .btn span {
    display: none;
  }
  .note-body {
    padding: 14px 16px 60px !important;
    font-size: 16px;
  }
  .note-preview {
    padding: 8px 16px 60px;
  }
  .note-title {
    font-size: 19px !important;
  }
  .note-item {
    padding: 12px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation-duration: 0.01ms !important;
  }
}
