@font-face {
  font-family: "Insurely Sans";
  src: url("https://assets.insurely.com/fonts/InsurelySans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Insurely Sans";
  src: url("https://assets.insurely.com/fonts/InsurelySans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Insurely Sans";
  src: url("https://assets.insurely.com/fonts/InsurelySans-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1b1b1f;
  --muted: #6b6b74;
  --border: #e2e0da;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok: #067647;
  --folder: #c9a227;
  --selected: #e6ecfd;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1c1c20;
    --surface-2: #26262b;
    --text: #ececef;
    --muted: #9a9aa3;
    --border: #2e2e34;
    --accent: #6d8dff;
    --accent-text: #0b0b0d;
    --danger: #ff6b5e;
    --ok: #4ade80;
    --folder: #e0b93c;
    --selected: #24304f;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Insurely Sans", system-ui, -apple-system, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover {
  background: var(--surface-2);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
button.primary:hover {
  filter: brightness(1.08);
}
button.danger {
  color: var(--danger);
}
button.link,
.as-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.dropzone:focus-within,
.title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="text"],
input[type="search"],
select,
textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  width: 100%;
}
/* The native select arrow hugs the right edge and the text sits low; draw our own chevron. */
select {
  appearance: none;
  padding-right: 32px;
  line-height: 1.5;
  /* Stroke is --muted; SVG backgrounds can't read custom properties, so dark mode repeats it. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b6b74' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-size: 12px 8px;
  background-repeat: no-repeat;
}
@media (prefers-color-scheme: dark) {
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239a9aa3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

.hint {
  color: var(--muted);
  font-size: 13px;
}
.error {
  color: var(--danger);
}

/* Layout */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand {
  font-weight: 600;
  font-size: 17px;
}
.brand span {
  color: var(--muted);
  font-weight: 400;
}

/* Search */

.search {
  position: relative;
  flex: 0 1 480px;
}
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: min(60vh, 480px);
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}
.search-results li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.search-results li[aria-selected="true"] {
  background: var(--surface-2);
}
.search-results li.none {
  color: var(--muted);
  cursor: default;
}
.search-results .thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 30px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.search-results .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.result-text {
  display: grid;
  min-width: 0;
}
.result-name,
.result-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-name {
  font-weight: 500;
}
.result-path {
  color: var(--muted);
  font-size: 12px;
}
.user {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  min-width: 0;
}
.user > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}
[hidden] {
  display: none !important;
}

.signin {
  max-width: 440px;
  margin: 12vh auto 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow);
}
.signin h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
}
.signin p {
  color: var(--muted);
}
.signin .error {
  color: var(--danger);
}
.signin button {
  margin-top: 12px;
  padding: 10px 20px;
}

/* Folders */

.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon-folder {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6.5A2.5 2.5 0 0 1 5.5 4h4.2l2 2.5h6.8A2.5 2.5 0 0 1 21 9v8.5a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 17.5z'/%3E%3C/svg%3E");
  color: var(--folder);
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 8px;
}
.sidebar-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
button.small {
  font-size: 13px;
  padding: 3px 8px;
}

.tree,
.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree ul {
  padding-left: 14px;
}
.tree-row {
  display: flex;
  align-items: center;
  border-radius: 6px;
}
.caret,
.caret-space {
  width: 20px;
  flex: none;
}
.caret {
  border: 0;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 28px;
  transition: transform 0.15s;
}
.caret.open {
  transform: rotate(90deg);
}
.caret:hover {
  background: none;
  color: var(--text);
}
.tree-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 4px 8px 4px 4px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}
.tree-link:hover {
  background: var(--surface-2);
}
.tree-link.current {
  background: var(--selected);
  font-weight: 600;
}
.tree-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.folder-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 20px;
  font-weight: 600;
  min-width: 0;
}
.crumb {
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  padding: 0 4px;
  overflow-wrap: anywhere;
}
a.crumb:hover {
  color: var(--text);
  text-decoration: underline;
}
.crumb.current {
  color: var(--text);
}
.sep {
  color: var(--border);
}
.folder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.folder-actions button {
  font-size: 13px;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.folder-grid:empty {
  display: none;
}
.folder-tile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "icon name" "icon count";
  column-gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.folder-tile:hover {
  border-color: var(--accent);
}
.folder-tile .icon {
  grid-area: icon;
  width: 28px;
  height: 28px;
}
.folder-name {
  grid-area: name;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-tile .count {
  grid-area: count;
}

/* Drag and drop */

.drop-over,
.folder-tile.drop-over,
.tree-row.drop-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: var(--selected);
}
.card .body[draggable="true"] {
  cursor: grab;
}
.dragging .card .body {
  cursor: grabbing;
}

/* More menu */

.menu {
  position: relative;
}
.menu summary {
  list-style: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}
.menu summary::-webkit-details-marker {
  display: none;
}
.menu summary:hover,
.menu[open] summary {
  background: var(--surface-2);
}
.menu-items {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 5;
  display: grid;
  min-width: 170px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}
.menu-items button {
  border: 0;
  text-align: left;
  border-radius: 6px;
}

/* Folder picker */

.picker {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 8px;
}
.pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px calc(8px + var(--depth) * 18px);
  border-radius: 6px;
  cursor: pointer;
}
.pick:hover {
  background: var(--surface-2);
}
.pick:has(input:checked) {
  background: var(--selected);
}
.pick.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Uploading */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 36px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone.over {
  border-color: var(--accent);
}
.dropzone.over {
  background: var(--surface-2);
}

.uploads {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.uploads li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  grid-template-areas: "name bar" "status status";
  gap: 4px 16px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.uploads .name {
  grid-area: name;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.uploads progress {
  grid-area: bar;
  width: 100%;
  accent-color: var(--accent);
}
.uploads .status {
  grid-area: status;
  color: var(--muted);
  font-size: 13px;
}
.uploads .done progress,
.uploads .failed progress {
  display: none;
}
.uploads .done .status {
  color: var(--ok);
}
.uploads .failed .status {
  color: var(--danger);
}
.uploads .note {
  color: var(--muted);
}

/* Library */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0 12px;
}
.toolbar h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.filters select {
  width: auto;
}
.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: outline-color 0.6s;
  outline: 2px solid transparent;
  outline-offset: 2px;
}
/* A file picked from search, briefly marked so it's easy to spot in its folder. */
.card.highlight {
  outline-color: var(--accent);
  transition: none;
}
.preview {
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  display: grid;
  place-items: center;
}
.preview video,
.preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.video .preview {
  background: #000;
}
.file-icon {
  font-weight: 600;
  color: var(--muted);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 14px 12px;
  letter-spacing: 0.04em;
}
.card .body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.card .title {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 600;
  cursor: text;
  overflow-wrap: anywhere;
}
.card .title:hover {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.card .meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
}
.actions button {
  font-size: 13px;
  padding: 5px 10px;
}
.actions .danger {
  margin-left: auto;
}

/* Dialogs */

dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 24px;
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}
dialog h3 {
  margin: 0 0 16px;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.field {
  display: block;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 800px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: static;
    max-height: 40vh;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  .search {
    order: 1;
    flex-basis: 100%;
  }
  .uploads li {
    grid-template-columns: 1fr;
    grid-template-areas: "name" "bar" "status";
  }
}
