:root {
  --brand: #8a5a34;
  --bg: #faf7f2;
}

body {
  background: var(--bg);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.kkm-auth-shell {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kkm-auth-card {
  width: 100%;
  max-width: 360px;
}

.kkm-gallery-header {
  background: var(--kkm-sidebar-bg, #141613);
  border-bottom: 1px solid var(--kkm-border, #383b38);
}

.kkm-gallery-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--kkm-text, #f3f4f1) !important;
  letter-spacing: 0.02em;
}

.kkm-photo-caption {
  font-size: 0.8rem;
  color: var(--kkm-text-muted, #98a19a);
  margin-top: 4px;
  word-break: break-word;
}

.kkm-editor-canvas-wrap {
  max-width: 100%;
  max-height: 60vh;
  overflow: hidden;
  background: #222;
}

.kkm-editor-canvas-wrap img {
  display: block;
  max-width: 100%;
}

.kkm-links-table td {
  vertical-align: middle;
}

.kkm-empty {
  color: #888;
  padding: 2rem 0;
  text-align: center;
}

/* ===== Dark app shell (public feed + upload/links pages) ===== */

body.kkm-dark {
  --kkm-bg: #1b1e1c;
  --kkm-sidebar-bg: #141613;
  --kkm-card-bg: #2a2d2a;
  --kkm-accent: #3ecf8e;
  --kkm-text: #f3f4f1;
  --kkm-text-muted: #98a19a;
  --kkm-border: #383b38;

  background: var(--kkm-bg);
  color: var(--kkm-text);
}

body.kkm-dark a {
  color: var(--kkm-text);
}

.kkm-shell {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.kkm-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--kkm-sidebar-bg);
  height: 100vh;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  transition: width 0.15s ease;
  overflow: hidden;
}

.kkm-sidebar.kkm-collapsed {
  width: 76px;
}

.kkm-sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--kkm-text-muted);
  cursor: pointer;
  padding: 8px;
  margin-bottom: 20px;
  align-self: flex-start;
  border-radius: 8px;
}

.kkm-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--kkm-text);
}

.kkm-sidebar.kkm-collapsed .kkm-sidebar-toggle {
  align-self: center;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kkm-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.25;
  color: var(--kkm-text) !important;
  margin-bottom: 24px;
  letter-spacing: 0.01em;
  text-decoration: none;
  padding: 0 12px;
  white-space: normal;
  word-break: break-word;
}

.kkm-sidebar-brand span[uk-icon] {
  flex-shrink: 0;
}

.kkm-sidebar.kkm-collapsed .kkm-sidebar-brand {
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  padding: 0;
  text-align: center;
}

.kkm-sidebar.kkm-collapsed .kkm-sidebar-brand svg {
  width: 18px;
  height: 18px;
}

.kkm-sidebar.kkm-collapsed .kkm-sidebar-brand .kkm-sidebar-label {
  display: block;
  font-size: 0.5rem;
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
}

.kkm-sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kkm-sidebar-nav li + li {
  margin-top: 4px;
}

.kkm-sidebar-nav a,
.kkm-sidebar-footer a,
.kkm-sidebar-footer button {
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--kkm-text-muted) !important;
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
}

.kkm-sidebar.kkm-collapsed .kkm-sidebar-nav a,
.kkm-sidebar.kkm-collapsed .kkm-sidebar-footer a,
.kkm-sidebar.kkm-collapsed .kkm-sidebar-footer button {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  padding: 0;
  justify-content: center;
}

.kkm-sidebar-nav a:hover,
.kkm-sidebar-footer a:hover,
.kkm-sidebar-footer button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--kkm-text) !important;
}

.kkm-sidebar-nav a.kkm-active,
.kkm-sidebar-footer a.kkm-active {
  background: rgba(62, 207, 142, 0.15);
  color: var(--kkm-accent) !important;
  font-weight: 600;
}

.kkm-sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.kkm-sidebar.kkm-collapsed .kkm-sidebar-label {
  display: none;
}

.kkm-sidebar-tags {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 8px 0;
}

.kkm-sidebar.kkm-collapsed .kkm-sidebar-tags {
  display: none;
}

.kkm-sidebar-tags-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--kkm-text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.kkm-sidebar-tags-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px;
  min-height: 0;
}

.kkm-sidebar-tags-scroll .kkm-pill {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.kkm-sidebar-tags-scroll .kkm-pill:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--kkm-text);
}

.kkm-sidebar-tags-scroll .kkm-pill.kkm-pill-active {
  background: rgba(62, 207, 142, 0.15);
  color: var(--kkm-accent);
  font-weight: 600;
}

.kkm-sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--kkm-border);
  flex-shrink: 0;
}

.kkm-main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

.kkm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.kkm-topbar h2 {
  margin: 0;
}

body.kkm-dark .uk-input,
body.kkm-dark .uk-textarea,
body.kkm-dark .uk-select {
  background: var(--kkm-card-bg);
  border: 1px solid var(--kkm-border);
  color: var(--kkm-text);
}

body.kkm-dark .uk-input::placeholder {
  color: var(--kkm-text-muted);
}

body.kkm-dark .uk-button-default {
  background: var(--kkm-card-bg);
  border: 1px solid var(--kkm-border);
  color: var(--kkm-text);
}

body.kkm-dark .uk-button-primary {
  background: var(--kkm-accent);
  border-color: var(--kkm-accent);
  color: #0e1410;
}

body.kkm-dark .uk-card-default {
  background: var(--kkm-card-bg);
  color: var(--kkm-text);
  border: 1px solid var(--kkm-border);
}

.kkm-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.kkm-pill {
  background: var(--kkm-card-bg);
  border: 1px solid var(--kkm-border);
  color: var(--kkm-text-muted);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  cursor: pointer;
}

.kkm-pill:hover {
  color: var(--kkm-text);
}

.kkm-pill.kkm-pill-active {
  background: var(--kkm-accent);
  border-color: var(--kkm-accent);
  color: #0e1410;
  font-weight: 600;
}

.kkm-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
  color: var(--kkm-text-muted);
  font-size: 0.9rem;
}

.kkm-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--kkm-card-bg);
}

.kkm-card img {
  width: 100%;
  display: block;
  aspect-ratio: auto;
}

.kkm-card-checkbox {
  position: absolute;
  top: 10px;
  left: 10px;
  transform: scale(1.3);
  z-index: 2;
}

.kkm-card-badges {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  max-width: 65%;
}

.kkm-card-badge {
  background: rgba(20, 22, 19, 0.75);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kkm-card-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 10px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.kkm-card-overlay-text {
  min-width: 0;
}

.kkm-card-overlay-title {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kkm-card-overlay-sub {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kkm-card-download {
  flex-shrink: 0;
  color: #fff !important;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Filter row */
.kkm-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.kkm-filter-row .uk-input,
.kkm-filter-row .uk-select {
  width: auto;
  flex: 1 1 160px;
}

.kkm-filter-row #query {
  flex: 2 1 220px;
}

/* Round icon buttons */
.kkm-icon-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--kkm-border);
  background: var(--kkm-card-bg);
  color: var(--kkm-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.kkm-icon-btn:hover {
  color: var(--kkm-text);
}

.kkm-fab {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--kkm-accent);
  color: #0e1410;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.kkm-fab:disabled {
  background: var(--kkm-card-bg);
  color: var(--kkm-text-muted);
  cursor: not-allowed;
}

/* Tick-select toggle on cards */
.kkm-select-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.35);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.kkm-select-toggle.kkm-selected {
  background: var(--kkm-accent);
  border-color: var(--kkm-accent);
  color: #0e1410;
}

.kkm-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.kkm-card-action {
  flex-shrink: 0;
  color: #fff !important;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.kkm-card-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Upload hero + multi-image editor nav */
.kkm-upload-hero {
  padding: 60px 0;
  display: flex;
  justify-content: center;
}

.kkm-editor-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--kkm-text-muted);
  font-size: 0.9rem;
}

body.kkm-dark .uk-modal-dialog {
  background: var(--kkm-card-bg);
  color: var(--kkm-text);
}

body.kkm-dark .uk-modal-header,
body.kkm-dark .uk-modal-footer {
  border-color: var(--kkm-border);
}

body.kkm-dark .uk-table {
  color: var(--kkm-text);
}

body.kkm-dark .uk-table-divider > tr > td,
body.kkm-dark .uk-table-divider > :not(:first-child) > tr > td,
body.kkm-dark .uk-table th {
  border-top: 1px solid var(--kkm-border);
  color: var(--kkm-text);
}

.kkm-mobile-menu-btn {
  display: none;
}

.kkm-sidebar-backdrop {
  display: none;
}

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

@media (max-width: 767px) {
  .kkm-mobile-menu-btn {
    display: flex;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: var(--kkm-sidebar-bg);
    color: var(--kkm-text);
    border: 1px solid var(--kkm-border);
  }

  .kkm-sidebar-backdrop.kkm-visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .kkm-shell {
    flex-direction: column;
  }

  .kkm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .kkm-sidebar:not(.kkm-collapsed) {
    transform: translateX(0);
  }

  .kkm-sidebar.kkm-collapsed .kkm-sidebar-label {
    display: inline;
  }

  .kkm-sidebar.kkm-collapsed .kkm-sidebar-tags {
    display: flex;
  }

  .kkm-sidebar.kkm-collapsed .kkm-sidebar-brand,
  .kkm-sidebar.kkm-collapsed .kkm-sidebar-nav a,
  .kkm-sidebar.kkm-collapsed .kkm-sidebar-footer a,
  .kkm-sidebar.kkm-collapsed .kkm-sidebar-footer button {
    justify-content: flex-start;
  }

  .kkm-main {
    padding: 16px;
    padding-top: 68px;
  }

  .kkm-filter-row {
    gap: 8px;
  }

  .kkm-filter-row .uk-input,
  .kkm-filter-row .uk-select {
    flex: 1 1 100%;
  }

  .kkm-filter-row #query {
    flex: 1 1 100%;
  }

  /* Bottom-sheet modals */
  .uk-modal {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  .uk-modal-dialog,
  .uk-modal-container .uk-modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 88vh;
    overflow-y: auto;
    animation: kkm-sheet-up 0.25s ease-out;
  }
}

/* Custom fullscreen lightbox (zoom + pan + arrow nav) */
.kkm-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  display: none;
  z-index: 2000;
  touch-action: none;
}

.kkm-lightbox.kkm-open {
  display: block;
}

.kkm-lightbox-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.kkm-lightbox-img {
  max-width: 92vw;
  max-height: 85vh;
  object-fit: contain;
  user-select: none;
  transition: transform 0.05s linear;
}

.kkm-lightbox-close,
.kkm-lightbox-prev,
.kkm-lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2001;
}

.kkm-lightbox-close:hover,
.kkm-lightbox-prev:hover,
.kkm-lightbox-next:hover {
  background: rgba(255, 255, 255, 0.25);
}

.kkm-lightbox-close {
  top: 16px;
  right: 16px;
}

.kkm-lightbox-prev {
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
}

.kkm-lightbox-next {
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
}

.kkm-lightbox-caption {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  padding: 0 60px;
}

@media (max-width: 600px) {
  .kkm-lightbox-prev,
  .kkm-lightbox-next {
    width: 36px;
    height: 36px;
  }
}
