:root {
  color-scheme: dark;
  --bg: #111312;
  --surface: #1b1e1c;
  --surface-hover: #232825;
  --line: #303632;
  --text: #f0f3f0;
  --muted: #9ba69e;
  --accent: #b6e7ca;
  --red: #f1a2a7;
  --radius: 8px;
  font-family:
    "Segoe UI",
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}
button {
  cursor: pointer;
}
button,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
::selection {
  background: #b6e7ca;
  color: #111312;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h2 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
h3 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.site-header {
  width: min(1200px, calc(100% - 80px));
  min-height: 88px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 650;
}
.brand-symbol {
  font-size: 27px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}
.version-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.version-label > span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d5b879;
}
.app-shell {
  width: min(1200px, calc(100% - 80px));
  min-height: calc(100svh - 88px);
  margin: auto;
  display: grid;
  place-items: center;
  padding: 48px 0 64px;
}
.login-view {
  width: min(352px, 100%);
  text-align: center;
  animation: enter 350ms ease both;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 24px;
  border: 1px solid #3d4b42;
  border-radius: 8px;
  background: #1c2821;
  color: var(--accent);
}
.brand-mark .tool-icon {
  width: 25px;
  height: 25px;
}
h1 {
  font-size: 40px;
  font-weight: 650;
  line-height: 1.15;
}
.login-subtitle {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}
.login-panel {
  display: grid;
  gap: 12px;
  margin-top: 36px;
  text-align: left;
}
.input-label,
.field-label {
  display: block;
  color: #c0c9c2;
  font-size: 12px;
  font-weight: 500;
}
.key-field {
  position: relative;
}
.key-field > .tool-icon {
  position: absolute;
  top: 18px;
  left: 16px;
  color: var(--muted);
}
.key-field input,
.admin-field,
.upload-control {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 150ms ease,
    background 150ms ease;
}
.key-field input {
  height: 56px;
  padding: 12px 16px 12px 48px;
  font-size: 18px;
  font-weight: 500;
}
.key-field input::placeholder {
  color: #77847c;
  font-size: 14px;
  font-weight: 400;
}
.key-field input:hover,
.admin-field:hover,
.upload-control:hover {
  border-color: #48554c;
}
.key-field input:focus,
.admin-field:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px #b6e7ca12;
}
.primary-button,
.ghost-button,
.icon-button,
.danger-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}
.primary-button {
  background: #e2ece5;
  color: #18221b;
}
.primary-button:hover:not(:disabled) {
  background: #c4e7d1;
}
.login-panel .primary-button {
  min-height: 50px;
  margin-top: 4px;
  justify-content: space-between;
  padding-inline: 18px;
}
#openShareButton {
  justify-content: center;
}
.ghost-button {
  border-color: var(--line);
  background: transparent;
  color: #bec9c1;
}
.icon-button {
  background: transparent;
  color: var(--muted);
}
.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
  border-color: #3c4840;
}
.danger-button {
  color: #b69598;
  background: transparent;
}
.danger-button:hover:not(:disabled) {
  background: #342326;
  color: #ffbdc1;
  border-color: #674147;
}

.workspace {
  width: 100%;
  min-width: 0;
  align-self: start;
  animation: enter 250ms ease both;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 44px;
}
.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}
.space-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  align-items: start;
  gap: 40px;
}
.single-space {
  grid-template-columns: 1fr;
}
.section {
  min-width: 0;
}
.section-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.count-badge {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-hover);
  color: #bec9c1;
  text-align: center;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.file-list,
.keys-list {
  display: grid;
  align-content: start;
}
.file-row,
.key-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 18px 0;
  border-bottom: 1px solid #272e29;
}
.file-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: #a8beb0;
}
.key-icon-family {
  color: #b8d6e3;
  background: #1c272c;
  border-color: #33464e;
}
.key-icon-admin {
  color: #dcc28e;
  background: #29271e;
  border-color: #494333;
}
.file-meta,
.key-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.file-name {
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.key-code {
  font-size: 15px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-weight: 600;
}
.key-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.type-label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.file-details,
.key-details {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.file-actions,
.key-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.empty-state {
  padding: 48px 16px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.upload-box,
.admin-create {
  display: grid;
  gap: 24px;
  border-left: 1px solid var(--line);
  padding-left: 32px;
  min-width: 0;
}
.upload-box {
  gap: 12px;
}
.upload-box h3 {
  margin-bottom: 12px;
}
.upload-box h3,
.admin-create h3 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.upload-box h3 .tool-icon,
.admin-create h3 .tool-icon {
  width: 17px;
  height: 17px;
  color: var(--muted);
}
.admin-create {
  position: sticky;
  top: 32px;
}
.admin-form-grid {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.admin-form-grid > .field-label:not(:first-child) {
  margin-top: 10px;
}
.admin-form-grid .primary-button {
  margin-top: 12px;
}
.single-file-group {
  display: grid;
  gap: 10px;
  margin: 8px 0;
  min-width: 0;
}
.upload-control {
  display: block;
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
  text-overflow: ellipsis;
}
.upload-control::file-selector-button {
  padding: 6px 8px;
  margin-right: 8px;
  border: 0;
  border-radius: 3px;
  background: #303a33;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.compact-upload {
  max-width: 220px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  color: #bec9c1;
  font-size: 13px;
  cursor: pointer;
}
.switch-row input {
  appearance: none;
  position: relative;
  width: 32px;
  height: 19px;
  flex: 0 0 32px;
  margin: 0;
  border: 1px solid #4b574f;
  border-radius: 12px;
  background: #242c27;
  cursor: pointer;
  transition: background 150ms ease;
}
.switch-row input::before {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #aab7af;
  transition: transform 150ms ease;
}
.switch-row input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.switch-row input:checked::before {
  transform: translateX(13px);
  background: #26372d;
}
.permission-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.permission-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.tool-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon-copy {
  --icon: url("/vendor/lucide/copy.svg");
}
.icon-qr-code {
  --icon: url("/vendor/lucide/qr-code.svg");
}
.icon-x {
  --icon: url("/vendor/lucide/x.svg");
}
.icon-download {
  --icon: url("/vendor/lucide/download.svg");
}
.icon-key-round {
  --icon: url("/vendor/lucide/key-round.svg");
}
.icon-file {
  --icon: url("/vendor/lucide/file.svg");
}
.icon-folder {
  --icon: url("/vendor/lucide/folder.svg");
}
.icon-upload {
  --icon: url("/vendor/lucide/upload.svg");
}
.icon-trash-2 {
  --icon: url("/vendor/lucide/trash-2.svg");
}
.icon-arrow-right {
  --icon: url("/vendor/lucide/arrow-right.svg");
}
.icon-log-out {
  --icon: url("/vendor/lucide/log-out.svg");
}
.icon-shield-check {
  --icon: url("/vendor/lucide/shield-check.svg");
}
.icon-plus {
  --icon: url("/vendor/lucide/plus.svg");
}
.share-tool {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0;
}
.share-tool.labeled-tool {
  display: inline-flex;
  width: auto;
  min-width: 110px;
  flex: 0 0 auto;
  padding-inline: 12px;
  border-color: var(--line);
  color: var(--accent);
}
.share-tool.labeled-tool::after {
  display: none;
}
.share-tool::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 3;
  width: max-content;
  max-width: 180px;
  padding: 6px 9px;
  border: 1px solid #445047;
  border-radius: 4px;
  background: #252c27;
  color: var(--text);
  font-size: 11px;
  font-weight: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.share-tool:hover::after,
.share-tool:focus-visible::after {
  opacity: 1;
}
.share-dialog {
  width: min(400px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow: auto;
  border: 1px solid #414c44;
  border-radius: 8px;
  background: #191e1b;
  color: var(--text);
  box-shadow: 0 24px 100px #0008;
}
.share-dialog[open] {
  animation: enter 180ms ease both;
}
.share-dialog::backdrop {
  background: #080b09b8;
  backdrop-filter: blur(5px);
}
.share-heading,
.share-dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.share-heading h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}
.share-dialog-actions {
  justify-content: flex-end;
  padding-top: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
}
.share-dialog-actions .share-tool {
  border-color: var(--line);
}
.share-caption {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.qr-frame {
  display: grid;
  place-items: center;
  width: min(240px, 100%);
  aspect-ratio: 1;
  margin: 24px auto;
  background: white;
  color: #111;
  text-align: center;
}
.qr-image {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.share-url {
  margin-top: 8px;
  font-size: 12px;
}
.share-notice {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.share-error {
  color: var(--red);
  line-height: 1.5;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.share-error:empty {
  display: none;
}
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 1px solid #52675a;
  border-radius: 6px;
  background: #223027;
  box-shadow: 0 8px 32px #0004;
  color: #e0f1e6;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.error {
  background: #302124;
  border-color: #674147;
  color: #ffccd0;
}
.hidden {
  display: none !important;
}
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .space-grid,
  .admin-grid {
    gap: 28px;
    grid-template-columns: minmax(0, 1fr) 264px;
  }
  .single-space {
    grid-template-columns: 1fr;
  }
  .upload-box,
  .admin-create {
    padding-left: 24px;
  }
  .key-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }
  .key-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}
@media (max-width: 760px) {
  .site-header {
    width: calc(100% - 40px);
    min-height: 72px;
  }
  .app-shell {
    width: calc(100% - 40px);
    min-height: calc(100svh - 72px);
    padding: 36px 0 48px;
  }
  .space-grid,
  .admin-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 28px;
    gap: 16px;
  }
  .topbar > div {
    display: contents;
  }
  .topbar .eyebrow {
    margin: 0;
    align-self: center;
  }
  .topbar h2 {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .topbar .ghost-button {
    grid-column: 2;
    grid-row: 1;
  }
  h2 {
    font-size: 23px;
  }
  .admin-create,
  .upload-box {
    position: static;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 24px 0 0;
  }
  .admin-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-form-grid > * {
    grid-column: 1 / -1;
  }
  .switch-row {
    min-height: 44px;
  }
  .file-row {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
  }
  .file-icon {
    width: 36px;
    height: 40px;
  }
  .file-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
  .share-tool {
    width: 42px;
    min-height: 42px;
    height: 42px;
    flex-basis: 42px;
  }
  .share-tool::after {
    left: 0;
    right: auto;
    max-width: 160px;
  }
  .share-heading .share-tool::after {
    right: 0;
    left: auto;
  }
}
@media (max-width: 380px) {
  .site-header,
  .app-shell {
    width: calc(100% - 32px);
  }
  h1 {
    font-size: 36px;
  }
  .share-dialog {
    padding: 18px;
  }
  .permission-toggle {
    flex-basis: 100%;
    min-height: 28px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
