:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f8faf8;
  --line: #d9dfdb;
  --line-strong: #c7cec9;
  --text: #202124;
  --muted: #5f6368;
  --accent: #1a73e8;
  --warning: #b06000;
  --shadow: 0 12px 26px rgba(32, 33, 36, 0.08);
  --radius: 14px;
  --gallery-gap: 4px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

html.viewer-open,
body.viewer-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1435px;
  margin: 0 auto;
  gap: 16px;
  padding: 22px 0 18px;
}

.topbar-main,
.topbar-actions,
.panel-header,
.media-toolbar,
.toolbar-actions,
.settings-actions,
.selection-bar,
.viewer-footer,
.viewer-actions,
.settings-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-main {
  position: relative;
  display: block;
}

.topbar-main .icon-button {
  position: absolute;
  top: 2px;
  left: -52px;
  transform: none;
}

.topbar-main h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 400;
}

.topbar-main p,
.host-summary,
.upload-status,
.status-text,
.settings-panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.main-content {
  padding: 28px 30px 34px;
}

#albums-view,
#media-view {
  max-width: 1435px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view-visible {
  display: block;
}

.ghost-button,
.secondary-button,
.primary-button,
.browse-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--text);
  cursor: pointer;
  background: #fff;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.ghost-button:hover,
.secondary-button:hover,
.icon-button:hover {
  background: #f7f9f8;
}

.primary-button,
.browse-button {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.primary-button:hover,
.browse-button:hover {
  background: #1765cc;
}

.browse-button input {
  display: none;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none !important;
}

#mobile-menu-button {
  display: none;
  border: 0;
  background: transparent;
  padding: 4px 6px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}

.mobile-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 200;
  min-width: 170px;
  padding: 6px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.mobile-menu-dropdown.is-open {
  display: block;
}

.mobile-menu-item {
  display: block;
  width: 100%;
  padding: 11px 18px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
}

.mobile-menu-item:hover {
  background: var(--panel);
}

.mobile-menu-item:disabled {
  color: var(--muted);
  cursor: default;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
}

.album-grid-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  position: relative;
}

.album-grid-card:has(.album-grid-menu.is-open) {
  z-index: 30;
}

.album-grid-open {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.album-grid-cover-wrap {
  aspect-ratio: 16 / 10;
  background: #eef2ef;
  overflow: hidden;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.album-grid-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.album-grid-cover-placeholder {
  background: linear-gradient(135deg, #eef2ef, #f8faf8);
}

.album-grid-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 14px;
  position: relative;
}

.album-grid-text {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.album-grid-info strong {
  font-size: 1rem;
  font-weight: 600;
}

.album-grid-info span {
  color: var(--muted);
  font-size: 0.92rem;
}

.album-grid-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.album-grid-menu-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 2px 0 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.album-grid-menu-toggle svg {
  display: block;
}

.album-grid-menu-toggle:hover,
.album-grid-menu-toggle:focus-visible {
  background: var(--panel-soft);
  color: var(--text);
}

.album-grid-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 20;
  min-width: 140px;
  padding: 6px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.album-grid-menu.is-open {
  display: block;
}

.album-grid-menu-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.album-grid-menu-item:hover,
.album-grid-menu-item:focus-visible {
  background: var(--panel-soft);
}

.album-grid-menu-item--danger {
  color: #d93025;
}

.album-grid-menu-item--danger:hover,
.album-grid-menu-item--danger:focus-visible {
  background: #fce8e6;
}

.media-toolbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.media-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f9f8;
}

.media-tab {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.media-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(32, 33, 36, 0.1);
}

.toolbar-actions {
  flex-wrap: wrap;
}

.dropzone {
  border: 1px dashed #cdd5d0;
  background: var(--panel-soft);
  padding: 16px 18px;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dropzone.is-dragging {
  border-color: #8ab4f8;
  background: #f5f9ff;
}

.upload-status.is-warning {
  color: var(--warning);
}

.upload-status-inline {
  margin-bottom: 12px;
  min-height: 1.4em;
}

.selection-bar {
  justify-content: space-between;
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: #f8faf8;
  border: 1px solid var(--line);
}

.media-grid {
  display: flex;
  flex-direction: column;
  width: calc(100% + 60px);
  margin-left: -30px;
  margin-right: -30px;
  gap: var(--gallery-gap);
  background: transparent;
}

.media-spacer {
  flex: 0 0 auto;
  width: 100%;
}

.media-row {
  display: flex;
  width: 100%;
  gap: var(--gallery-gap);
  align-items: stretch;
  justify-content: flex-start;
  background: transparent;
}

.media-card {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  background: transparent;
}

.media-card button,
.media-card input[type="checkbox"] {
  cursor: pointer;
}

.media-thumb {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.media-thumb.fit-cover {
  object-fit: cover;
}

.media-thumb.fit-contain {
  object-fit: contain;
}

.media-thumb.is-video {
  object-fit: contain;
  padding: 18px;
  background: transparent;
}

.media-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 2;
}

.media-card.is-video-card:hover .media-play-badge {
  opacity: 1;
}

.media-topbar {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.media-card:hover .media-topbar,
.media-card.is-selected .media-topbar {
  opacity: 1;
}

.media-open {
  width: 100%;
  height: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 0;
}

.media-select {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #1a73e8;
  background: #fff;
}

.empty-state {
  padding: 40px 0;
  color: var(--muted);
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(32, 33, 36, 0.18);
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: min(420px, 100vw);
  height: 100vh;
  padding: 24px;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(32, 33, 36, 0.1);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  overflow-y: auto;
}

.settings-panel.is-open {
  transform: translateX(0);
}

.settings-panel-header {
  justify-content: space-between;
  margin-bottom: 18px;
}

.settings-panel-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

.settings-form label {
  display: grid;
  gap: 8px;
}

.settings-form select,
.settings-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}

.settings-actions {
  grid-column: 1 / -1;
}

.panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}

.panel-header {
  justify-content: space-between;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.viewer-dialog {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  border: 0;
  margin: 0;
  inset: 0;
  padding: 0;
  background: transparent;
  overflow: hidden;
}

.viewer-dialog::backdrop {
  background: #000;
}

.viewer-frame {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border-radius: 0;
  overflow: hidden;
  background: #000;
  border: 0;
  box-shadow: none;
}

.viewer-stage {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #000;
  overflow: hidden;
}

.viewer-stage img,
.viewer-stage video {
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.viewer-stage .viewer-image {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

.viewer-close,
.viewer-nav {
  position: absolute;
  z-index: 2;
  background: rgba(255, 255, 255, 0.92);
  color: #202124;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

.viewer-close {
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
}

.viewer-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  font-size: 1.5rem;
}

.viewer-prev {
  left: 18px;
}

.viewer-next {
  right: 18px;
}

.viewer-footer {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 2;
  justify-content: space-between;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(6px);
}

.viewer-footer .ghost-button,
.viewer-footer a.ghost-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.viewer-kebab-btn {
  display: none;
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.8));
}

.viewer-unplayable {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  max-width: 100%;
  max-height: 100%;
}

.viewer-unplayable .viewer-image {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 8px;
}

.viewer-unplayable-note {
  max-width: 640px;
  padding: 10px 18px;
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(18, 18, 18, 0.7);
  border-radius: 10px;
}

.viewer-kebab-dropdown {
  display: none;
  position: absolute;
  top: 64px;
  right: 14px;
  z-index: 10;
  min-width: 210px;
  padding: 6px 0;
  background: rgba(18, 18, 18, 0.92);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.viewer-kebab-dropdown.is-open {
  display: block;
}

.viewer-kebab-item {
  display: block;
  width: 100%;
  padding: 13px 18px;
  border: 0;
  background: transparent;
  text-align: left;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.viewer-kebab-item:hover,
.viewer-kebab-item:active {
  background: rgba(255, 255, 255, 0.1);
}

.viewer-kebab-item--danger {
  color: #ff6b6b;
}

@media (max-width: 900px) {
  .topbar,
  .main-content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-main h1 {
    font-size: 1.5rem;
  }

  #create-album-button,
  #settings-toggle-button {
    display: none !important;
  }

  .tab-count {
    display: none;
  }

  .media-tabs {
    display: flex;
    width: 100%;
    gap: 0;
    padding: 0;
    border: 0;
    border-bottom: 2px solid var(--line);
    border-radius: 0;
    background: transparent;
  }

  .media-tab {
    flex: 1;
    border-radius: 0;
    padding: 12px 0;
    text-align: center;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
  }

  .media-tab.is-active {
    background: transparent;
    color: var(--accent);
    border-bottom-color: var(--accent);
    box-shadow: none;
  }

  .toolbar-actions {
    display: none !important;
  }

  .topbar-inner {
    position: relative;
  }

  .topbar-main {
    padding-right: 36px;
  }

  #mobile-menu-button {
    display: block;
    position: absolute;
    top: 22px;
    right: 0;
  }

  .media-grid {
    width: calc(100% + 36px);
    margin-left: -18px;
    margin-right: -18px;
  }

  .album-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .settings-form {
    grid-template-columns: 1fr;
  }

  .dropzone {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-footer {
    display: none !important;
  }

  .viewer-kebab-btn {
    display: block;
  }

  .viewer-close {
    right: 66px;
  }
}
