:root {
  --bg: #f5f6f8; --card: #fff; --text: #1b1f27; --muted: #6b7280; --line: #e3e6eb;
  --danger: #d33a3a;
  color-scheme: light;
}
/* One base color drives the accent. The Colors dialog changes it; .accent-scope lets that dialog preview a
   color inside its own box without touching the page. Light and dark keep their own backgrounds. */
:root, .accent-scope {
  --accent-base: #2f6fed;
  --accent: var(--accent-base);
  --accent-text: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #14161a; --card: #1d2026; --text: #e8eaee; --muted: #8b93a1; --line: #2c3037; --danger: #ff6b6b; color-scheme: dark; }
  :root:not([data-theme="light"]), :root:not([data-theme="light"]) .accent-scope { --accent: color-mix(in srgb, var(--accent-base) 88%, #fff); }
}
:root[data-theme="dark"] { --bg: #14161a; --card: #1d2026; --text: #e8eaee; --muted: #8b93a1; --line: #2c3037; --danger: #ff6b6b; color-scheme: dark; }
:root[data-theme="dark"], :root[data-theme="dark"] .accent-scope { --accent: color-mix(in srgb, var(--accent-base) 88%, #fff); }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 9px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
/* Drawn fully inside the box: folded sections clip anything that sticks out, which cut off one side. */
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
button { cursor: pointer; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px; }
button:disabled { opacity: .6; cursor: wait; }

.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.auth h1 { font-size: 24px; margin: 0 0 4px; }
.auth form { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-top: 16px; }
.auth .primary { width: 100%; margin-top: 18px; padding: 10px; }
.auth .switch { text-align: center; margin-top: 12px; }
.msg { margin-top: 12px; font-size: 13px; color: var(--muted); }
.msg.error { color: var(--danger); }

.top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; margin: 0 8px 0 0; flex: none; }
.top .sp { flex: 1; }
.top .tabs { margin: 0; }
.wrap { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs { display: inline-flex; gap: 4px; padding: 3px; background: color-mix(in srgb, var(--muted) 12%, var(--bg)); border-radius: 10px; }
.toolbar .tabs { margin-right: auto; }
.tabs button { border: 0; border-radius: 8px; background: transparent; padding: 6px 14px; color: var(--muted); font-weight: 500; }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--card); color: var(--accent); box-shadow: 0 0 0 1px var(--line); }
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.bar > input { flex: 1; min-width: 160px; }
.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row .actions button { padding: 5px 10px; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); width: min(480px, calc(100vw - 32px)); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
.field-row { display: flex; gap: 6px; }
.field-row button { white-space: nowrap; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .2s; }
#toast.show { opacity: 1; transform: translateX(-50%); }

.floating { position: fixed; right: 14px; bottom: 14px; display: flex; gap: 2px; padding: 3px; z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.floating button { border: 0; background: transparent; border-radius: 999px; padding: 6px 10px; font-size: 13px; color: var(--muted); }
.floating button:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.floating .xi { font-weight: 600; letter-spacing: .03em; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.preview { max-height: 160px; overflow: auto; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }

dialog h3 { margin: 18px 0 2px; font-size: 15px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0 0; }
dialog { max-height: calc(100vh - 32px); overflow: auto; }

.custom-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 6px; align-items: center; margin-top: 8px; }
.custom-row .check { display: flex; align-items: center; gap: 4px; margin: 0; white-space: nowrap; }
.custom-row .check input { width: auto; }
.kind { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px 16px; margin-bottom: 14px; }
.field-item { display: grid; grid-template-columns: minmax(0, 1fr) 170px 38px 38px 38px; gap: 6px; margin-top: 8px; align-items: stretch; }
/* Same columns as the rows above, so the type box lines up and Add spans the three small-button columns. */
.field-item.add { grid-template-columns: minmax(0, 1fr) 170px 38px 38px 38px; }
.field-item.add > button { grid-column: span 3; }
.field-item.add-type { grid-template-columns: minmax(0, 1fr) 260px auto; }
.field-item button { padding: 0; display: flex; align-items: center; justify-content: center; }
.field-item button.primary { padding: 8px 16px; }
@media (max-width: 560px) {
  .custom-row { grid-template-columns: 1fr 1fr; }
  /* name on its own line; type and the three small buttons below it */
  .field-item { grid-template-columns: minmax(0, 1fr) 38px 38px 38px; }
  .field-item > input { grid-column: 1 / -1; }
  .field-item.add, .field-item.add-type { grid-template-columns: minmax(0, 1fr) auto; }
  .field-item.add > button { grid-column: auto; }
}

select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  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='%238b93a1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 12px 8px;
}
.filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.filters .tags { margin: 0; }
.chip { padding: 3px 11px; font-size: 13px; border-radius: 999px; }
.chip.small { padding: 1px 8px; font-size: 12px; color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: auto; }
.groups { display: grid; gap: 18px; }
.group-head { display: flex; align-items: center; gap: 6px; font-weight: 600; margin: 0 0 8px; padding: 4px 6px; border-radius: 8px; cursor: grab; }
.group-head .count { color: var(--muted); font-weight: 400; }
.handle { color: var(--muted); cursor: grab; user-select: none; letter-spacing: -2px; padding: 0 2px; }
.row.dragging, .group-head.dragging { opacity: .4; }
.over-before { box-shadow: 0 -3px 0 var(--accent); }
.over-after { box-shadow: 0 3px 0 var(--accent); }

.divider { width: 1px; background: var(--line); margin: 2px 4px; }

.move { display: flex; gap: 2px; margin-left: 4px; }
.group-head .move { margin-left: auto; }
.mv { padding: 2px 7px; font-size: 12px; color: var(--muted); border-radius: 6px; line-height: 1.4; }
.mv:disabled { opacity: .3; cursor: default; }
.mv:disabled:hover { border-color: var(--line); }


.check.both { margin: 8px 0 0; }
.check[hidden] { display: none; }

/* The footer of every modal stays visible while the form scrolls. Section buttons inside the
   Profile dialog (not the last child) are left alone. */
dialog .dialog-actions:last-child {
  position: sticky; bottom: -20px; z-index: 1;
  margin: 18px -20px -20px; padding: 12px 20px 20px;
  background: var(--card); border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
}

.group-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-top: 8px; padding-bottom: 8px; margin-top: -4px; }
.group-name.clickable { cursor: pointer; }
.chev { border: 0; background: none; padding: 0 6px 0 2px; font-size: 14px; color: var(--muted); line-height: 1; }
.chev:hover { color: var(--accent); }
.filters .link { margin-left: auto; }

.thumb { display: block; max-width: 100%; max-height: 200px; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; }
.thumb[hidden] { display: none; }
.notice { margin-top: 10px; padding: 10px 12px; font-size: 13px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid var(--line); }

.affected { display: grid; gap: 6px; margin-top: 12px; max-height: 240px; overflow: auto; }
.aff { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.aff .main { flex: 1; min-width: 0; }
.aff.conflict { border-color: var(--danger); }
.aff.conflict .sub { color: var(--danger); white-space: normal; }
.row.focused { outline: 2px solid var(--accent); }
.focus-banner { margin: 0 0 14px; }

.type-head { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.type-name { font-weight: 600; font-size: 16px; }

.type-head h3 { margin: 0; }
.type-head h3.clickable { cursor: pointer; }
.type-head .count { color: var(--muted); font-weight: 400; font-size: 14px; }

.chev { font-size: 16px; width: 24px; height: 24px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.wrap > .link { padding: 4px 0; margin-bottom: 6px; }

.chev::before { content: ''; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .15s; }
.chev[aria-expanded="true"]::before { transform: rotate(45deg) translate(-1px, -1px); }

/* Page header used by management pages: title and description on the left, actions on the right. */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 2px 0 18px; }
.page-title { margin: 0; font-size: 18px; }
.page-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.page-actions .link { margin: 0; padding: 0; }
.notice.warn { margin: 0 0 16px; }
@media (max-width: 640px) { .page-head { flex-direction: column; } .page-actions { align-self: stretch; justify-content: space-between; } }

@media (max-width: 560px) {
  .top { flex-wrap: wrap; row-gap: 8px; padding: 10px 14px; }
  .top h1 { margin-right: auto; }
  .top .tabs { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .top .sp { display: none; }
  .acct-name { display: none; }
}

/* ---------- motion: short and quiet ---------- */
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
dialog[open] { animation: dialog-in .16s ease-out; }
dialog[open]::backdrop { animation: fade-in .16s ease-out; }
dialog.closing { animation: dialog-out .12s ease-in forwards; pointer-events: none; }
dialog.closing::backdrop { animation: fade-out .12s ease-in forwards; }

/* Folds: the grid row eases between 0fr and 1fr, so no height has to be measured. */
.collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease, margin-top .2s ease; }
.collapse.open { grid-template-rows: 1fr; }
.collapse > .inner { min-height: 0; overflow: hidden; display: grid; gap: 8px; }
.group > .collapse.open { margin-top: 8px; }
.kind > .collapse > .inner { display: block; }

.chev::before { transition: transform .2s ease; }
.row, .chip, button, .over-before, .over-after { transition: box-shadow .12s ease, background-color .12s ease, border-color .12s ease, opacity .12s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 22px 16px; text-align: center; cursor: pointer; margin-bottom: 14px; transition: border-color .12s ease, background-color .12s ease; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dz-title { font-weight: 600; }
.dz-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.dropzone .status { margin-top: 8px; font-size: 13px; color: var(--accent); }
.dropzone .status:empty, .dropzone .problems:empty { display: none; }

.progress { height: 4px; margin-top: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress[hidden] { display: none; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s ease; }
.dl-status { color: var(--accent); }

/* ---------- file preview modal ---------- */
dialog.preview-dialog { width: min(1040px, 96vw); height: min(88vh, 940px); max-height: none; padding: 0; overflow: hidden; }
dialog.preview-dialog[open] { display: flex; flex-direction: column; }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.preview-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.preview-loading { padding: 40px 24px; max-width: 420px; margin: 0 auto; text-align: center; }
.preview-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.sheet-wrap { padding: 12px 16px; }
.sheet-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.sheet-table { border-collapse: collapse; font-size: 13px; }
.sheet-table th, .sheet-table td { border: 1px solid var(--line); padding: 4px 8px; white-space: pre-wrap; vertical-align: top; max-width: 320px; }
.sheet-table th { background: var(--bg); color: var(--muted); font-weight: 500; position: sticky; left: 0; }
.slides { padding: 0 16px 16px; display: grid; gap: 10px; }
.slide { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.slide h4 { margin: 0 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.slide p { margin: 4px 0; }
.preview-body > .hint { padding: 0 16px; }

.dropzone .progress { max-width: 360px; margin: 8px auto 0; }
.media-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; background: #0e0f12; padding: 8px; }
.media-wrap .msg { color: #ff8b8b; padding: 24px; text-align: center; }
.preview-media { max-width: 100%; max-height: calc(88vh - 70px); display: block; }

/* ---------- selecting files ---------- */
.pick, .pick-all, .check .pick-all { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.row.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; padding: 8px 4px 8px 15px; } /* 15px = row padding + border, so the box lines up with the row boxes */
.bulkbar .check { gap: 8px; color: var(--text); font-size: 14px; }
.bulkbar .bulk-status { font-size: 13px; color: var(--accent); }
.bulkbar .progress { flex: 1 1 100%; margin-top: 2px; }
.bulkbar .link { padding: 4px; }

/* ---------- file filters and sorting ---------- */
.file-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.sort { position: relative; }
.sort-btn { font-size: 13px; padding: 5px 12px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(330px, 90vw); padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); animation: fade-in .12s ease-out; }
.sort-row { display: grid; grid-template-columns: 18px 14px 1fr auto; align-items: center; gap: 8px; padding: 5px 0; }
.sort-row input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.sort-n { color: var(--accent); font-weight: 600; font-size: 12px; text-align: center; }
.sort-dir { font-size: 12px; padding: 3px 10px; }
.sort-panel .hint { margin: 6px 0 0; }

/* ---------- in-app confirmation ---------- */
dialog.confirm-dialog { width: min(420px, calc(100vw - 32px)); }
.confirm-text { margin: 6px 0 0; color: var(--muted); white-space: pre-line; }
.primary.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }

/* The part of the upload note people must not miss. */
.dz-warn { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; padding: 1px 6px; border-radius: 6px; }

/* ---------- actions menu for selected files ---------- */
.actions-btn.kebab { width: 32px; height: 32px; padding: 0; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); background: transparent; border-color: transparent; }
.actions-btn.kebab:hover, .actions:has(.actions-menu:not([hidden])) .kebab { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: transparent; }
/* three dots drawn in CSS, so they are crisp at any size and follow the theme */
.actions-btn.kebab::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: currentColor; box-shadow: -7px 0 currentColor, 7px 0 currentColor; }
.actions-btn[hidden] { display: none; }
.actions .actions-menu { left: 0; right: auto; }
.actions-menu { width: 190px; padding: 6px; }
.actions-menu[hidden] { display: none; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; }
.menu-item:hover { background: var(--bg); }
.menu-item.danger { color: var(--danger); }
.menu-item:disabled { opacity: .5; }
.bulkbar { flex-wrap: wrap; }

/* ---------- icon view ---------- */
.view-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.seg { display: inline-flex; border: 0.5px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 4px 12px; font-size: 13px; background: var(--card); }
.seg button + button { border-left: 0.5px solid var(--border-strong); }
.seg button.on { background: var(--accent); color: var(--accent-text); }

.icon-grid { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 18px 6px; justify-items: center; padding: 6px 0 24px; }
.icon-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 84px; padding: 6px 2px; border-radius: 12px; cursor: pointer; outline: none; user-select: none; }
.icon-cell:hover, .icon-cell:focus-visible, .icon-cell.open { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.icon-cell.dragging { opacity: .4; }
.icon-cell.over-before { box-shadow: -3px 0 0 var(--accent); }
.icon-cell.over-after { box-shadow: 3px 0 0 var(--accent); }
.icon-name { font-size: 12px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.icon-tile { border-radius: 23%; overflow: hidden; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; flex: none; background: var(--line); }
.icon-tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.icon-card { position: absolute; z-index: 15; width: 280px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.14); animation: fade-in .12s ease-out; }
.icon-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.icon-card-head .main { min-width: 0; }
.icon-card-head .title, .icon-card-head .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-card-actions .mini { padding: 4px 10px; font-size: 13px; }
.icon-card-actions .mini.danger { color: var(--danger); }

.icon-pick { display: flex; align-items: center; gap: 12px; margin: 4px 0 4px; }
.icon-pick-preview { width: 56px; height: 56px; font-size: 22px; cursor: pointer; border: 1px dashed var(--line); }
.icon-pick-preview.over { border-color: var(--accent); }
.icon-pick-text .hint { margin: 4px 0 0; }
.icon-card .title { font-weight: 600; }
.icon-card .sub { font-size: 13px; color: var(--muted); }

/* ---------- icon groups, arranging, built-in icons ---------- */
.icon-tile.stack { box-shadow: 4px 4px 0 -1px color-mix(in srgb, var(--text) 16%, var(--bg)), 8px 8px 0 -2px color-mix(in srgb, var(--text) 9%, var(--bg)); margin: 0 8px 8px 0; }
.icon-btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { color: var(--accent); }
.mini { padding: 3px 10px; font-size: 13px; }
.arrange-note { margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
@keyframes wiggle { from { transform: rotate(-1.2deg); } to { transform: rotate(1.2deg); } }
.icon-grid.arranging .icon-cell { cursor: grab; animation: wiggle .28s ease-in-out infinite alternate; }
.icon-grid.arranging .icon-cell:nth-child(2n) { animation-direction: alternate-reverse; }
.icon-grid.arranging .icon-cell:hover { background: transparent; }

dialog.group-dialog { width: min(560px, calc(100vw - 32px)); }
.group-title { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.group-title h2 { margin: 0; }
.acct-list { display: grid; gap: 8px; }
.acct { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.acct .main { flex: 1 1 140px; min-width: 0; }
.acct .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tile-btn { padding: 0; border: 0; background: none; border-radius: 23%; cursor: pointer; line-height: 0; flex: none; }
.tile-btn:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-cell.img-over { outline: 2px dashed var(--accent); outline-offset: -2px; }

/* ---------- fields that open on hover ---------- */
.fields-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease; flex: 1 1 100%; }
.f-inner { min-height: 0; overflow: hidden; }
.acct:hover .fields-panel, .acct:has(:focus-visible) .fields-panel, .acct.expanded .fields-panel,
.row.expandable:hover .fields-panel, .row.expandable:has(:focus-visible) .fields-panel, .row.expandable.expanded .fields-panel,
.icon-card:hover .fields-panel, .icon-card:has(:focus-visible) .fields-panel, .icon-card.expanded .fields-panel { grid-template-rows: 1fr; }
.f-row { display: grid; grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); font-size: 13px; }
.f-row:first-child { margin-top: 8px; }
.f-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-btn { padding: 2px 9px; font-size: 12px; }
.acct .main, .icon-card-head { cursor: pointer; }
.acct-list { padding: 1px; } /* the dialog scrolls as a whole; a second scroll area inside it cut the cards off */

.usage-panel { width: 280px; right: 0; }
.usage-panel[hidden] { display: none; }
.usage-title { font-weight: 600; margin-bottom: 6px; }
.usage-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.usage-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-n { color: var(--muted); font-variant-numeric: tabular-nums; }
.usage-panel .hint { margin: 6px 0 0; }
.acct:focus, .icon-card:focus { outline: none; }
.acct:hover, .acct:has(:focus-visible), .acct.expanded { border-color: var(--accent); }
.icon-card { width: 340px; }
.icon-card .f-row { grid-template-columns: minmax(64px, 96px) minmax(0, 1fr) auto; }

/* copyable fields are rows you click; edit and delete are real buttons underneath */
.f-row { cursor: pointer; border-radius: 6px; padding-left: 4px; padding-right: 4px; margin: 0 -4px; }
.f-row:hover, .f-row:focus-visible { background: color-mix(in srgb, var(--accent) 9%, transparent); outline: none; }
.f-row:hover .f-copy { border-color: var(--accent); color: var(--accent); }
.f-copy.done { border-color: var(--success, #3B6D11); color: var(--success, #3B6D11); }
.f-actions { display: flex; gap: 8px; margin: 10px 0 2px; padding-top: 10px; border-top: 1px solid var(--line); }
.f-actions .mini.danger { color: var(--danger); }

.usage-item { border-radius: 8px; outline: none; }
.usage-item:hover, .usage-item:focus-visible { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.usage-detail { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .18s ease; }
.usage-item:hover .usage-detail, .usage-item:focus-visible .usage-detail { grid-template-rows: 1fr; }
.u-inner { min-height: 0; overflow: hidden; padding-left: 32px; }
.u-line { display: flex; gap: 8px; font-size: 12px; padding: 1px 0; }
.u-label { color: var(--muted); flex: none; }
.u-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-row { padding: 4px 4px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px 8px; font-size: 0.9rem; cursor: pointer; }
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 20px; padding: 0; margin: 0; border-radius: 999px; background: var(--muted); position: relative; cursor: pointer; transition: background .15s; }
input.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(16px); }
input.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.f-open { display: inline-flex; align-items: center; padding: 3px 5px; }

.f-tools { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.f-slot { width: 26px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.f-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 24px; padding: 0; }
.f-open { padding: 0; }
.row.expandable { flex-wrap: wrap; }
.row.expandable > .main { cursor: pointer; }
.row.expandable .fields-panel { padding: 0 2px; }
.row.expandable:hover, .row.expandable:has(:focus-visible), .row.expandable.expanded { border-color: var(--accent); }

.tile-box { position: relative; display: flex; }
.tile-count { position: absolute; right: -2px; top: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: 12px; line-height: 20px; text-align: center; font-weight: 600; box-sizing: border-box; }
.tile-tag { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); max-width: 80px; padding: 0 6px; border-radius: 9px; background: var(--card); color: var(--accent); border: 1px solid var(--accent); font-size: 11px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.select-bar { padding-left: 4px; }
.select-bar .bulk-count { font-size: 13px; color: var(--muted); }
.icon-btn.on { border-color: var(--accent); color: var(--accent); }
.tile-check { position: absolute; left: -5px; top: -5px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); border: 2px solid var(--muted); box-sizing: border-box; display: flex; align-items: center; justify-content: center; }
.tile-check.on { background: var(--accent); border-color: var(--accent); }
.tile-check.on::after { content: ''; width: 5px; height: 9px; border: solid var(--accent-text); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.tile-check.some { border-color: var(--accent); }
.tile-check.some::after { content: ''; width: 8px; height: 2px; background: var(--accent); }
.icon-cell.picked { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.group-head .pick { margin-right: 4px; }

.icon-pick { align-items: flex-start; }
.icon-pick-text { min-width: 0; }
.icon-pick-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.icon-pick-buttons .mini { padding: 5px 10px; font-size: 13px; }

/* ---------- colors dialog ---------- */
dialog.colors-dialog { width: min(480px, calc(100vw - 32px)); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 4px; }
.swatch { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.swatches input[type="color"] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.accent-preview { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); display: grid; gap: 12px; }
.accent-preview .pv-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.accent-preview .tabs { margin: 0; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

.ai-btn { display: inline-flex; align-items: center; gap: 6px; }
.ai-badge { font-size: 10px; font-weight: 600; letter-spacing: .04em; padding: 0 5px; line-height: 15px; border-radius: 5px; background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent)); color: var(--accent); }
.primary .ai-badge { background: color-mix(in srgb, var(--accent-text) 22%, transparent); color: var(--accent-text); }
dialog .dropzone { margin: 14px 0 0; }
dialog .dropzone .thumb { display: block; max-height: 160px; max-width: 100%; margin: 10px auto 0; border-radius: 8px; }
dialog .dropzone .thumb[hidden] { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; }
button.loading { cursor: progress; }

/* ---------- icon buttons that open up to show their name on hover ---------- */
.xbtn { display: inline-flex; align-items: center; gap: 0; padding: 7px 10px; font-size: 13px; white-space: nowrap; }
.xbtn svg { flex: none; }
.xbtn .xl { display: grid; grid-template-columns: 0fr; opacity: 0; transition: grid-template-columns .16s ease-out, opacity .16s ease-out, margin-left .16s ease-out; margin-left: 0; }
.xbtn .xli { min-width: 0; overflow: hidden; white-space: nowrap; }
.xbtn:hover .xl, .xbtn:focus-visible .xl { grid-template-columns: 1fr; opacity: 1; margin-left: 6px; }
.xbtn .ai-badge { margin-left: 6px; }
.seg .xbtn { border-radius: 0; padding: 6px 10px; }
.sel-btn { display: inline-flex; align-items: center; gap: 0; font-size: 13px; padding: 7px 10px; white-space: nowrap; }
.sel-btn.on { border-color: var(--accent); color: var(--accent); }
.sel-btn svg { margin-left: 4px; color: var(--muted); }
.drop-panel { left: 0; right: auto; width: 240px; max-height: 50vh; overflow: auto; padding: 6px; }
.more-menu { width: 210px; padding: 6px; }
.more-menu[hidden], .drop-panel[hidden] { display: none; }
.menu-item.on { color: var(--accent); font-weight: 600; }
.menu-item.check-item { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; color: var(--text); cursor: pointer; }
.check-item input { width: 18px; flex: none; }
.sel-btn .colon { margin-right: 4px; }
.type-row { margin: -4px 0 14px; }

/* ---------- import dialog ---------- */
dialog.import-dialog { width: min(520px, calc(100vw - 32px)); }
.import-dialog .dropzone { margin: 14px 0 0; }
.import-summary { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 6px; }
.import-summary[hidden] { display: none; }
.import-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 2px; }
.import-format { font-weight: 600; margin-right: 4px; }
.import-count { font-size: 12px; padding: 1px 9px; border-radius: 999px; background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent)); color: var(--accent); }
.import-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.import-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.import-user { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 0; }
.import-more { color: var(--muted); font-size: 13px; padding-left: 36px; }
.import-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.import-sources .hint { margin: 0 4px 0 0; }
.import-dialog .notice { margin-top: 12px; }
.accent-preview .sp { flex: 1; }

/* Fixed whole-pixel heights for text boxes and dropdowns. Their natural height was 42.5px, so in a stack of
   rows every second border landed between pixels and looked blurry; now every border is drawn the same. */
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):not([type="range"]), select { height: 42px; }
.field-item > button { height: 42px; }
.type-head { height: 42px; } /* whole pixels, so the rows below start on a pixel edge in every card */
.type-head h3 { line-height: 24px; }

/* ---------- header: account menu ---------- */
.acct-chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 4px; border-radius: 999px; font-size: 13px; }
.acct-av { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; background: color-mix(in srgb, var(--accent) 16%, var(--card)); color: var(--accent); }
.acct-chip svg { color: var(--muted); }
.account-menu { width: 230px; padding: 6px; }
.account-menu[hidden] { display: none; }
.menu-item.mi { display: flex; align-items: center; gap: 10px; }
.menu-item.mi svg { color: var(--muted); flex: none; }
.mi-value { margin-left: auto; font-size: 12px; color: var(--muted); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.in-app .floating { display: none; }
button.spinning svg { animation: spin .8s linear infinite; }

/* ---------- new / edit entry window: sections and the type search ---------- */
.form-sec { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 14px; margin-top: 12px; }
.form-sec-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.form-sec > label:first-of-type { margin-top: 8px; }
.basics-row { display: flex; align-items: flex-end; gap: 12px; margin-top: 8px; }
.basics-row .grow { flex: 1; min-width: 0; }
.basics-row .grow > label:first-child { margin-top: 0; }
.basics-row .icon-pick-preview { flex: none; margin-bottom: 0; }
.form-sec .icon-pick-text { margin-top: 10px; }
.combo { position: relative; }
.combo-input { padding-right: 36px; cursor: pointer; }
.combo > svg { position: absolute; right: 13px; top: 14px; color: var(--muted); pointer-events: none; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; max-height: 240px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 4px; }
.combo-list[hidden] { display: none; }
.combo-group { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 2px; }
.combo-item { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.combo-item.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.combo-item.on { color: var(--accent); font-weight: 600; }
.combo-n { color: var(--muted); font-size: 12px; font-weight: 400; }
.combo-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ---------- passkeys ---------- */
.passkey-block { margin-top: 16px; }
.passkey-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px; font-weight: 600; border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.passkey-btn:hover { background: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin-top: 14px; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.passkey-list { display: grid; gap: 8px; margin-top: 10px; }
.passkey-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.passkey-row svg { color: var(--accent); flex: none; }
.passkey-row .main { flex: 1; min-width: 0; }
.passkey-row .pk-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.passkey-row .hint { margin: 0; font-size: 12px; }
