:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dde3ea;
  --line-soft: #edf1f5;
  --blue: #1a73e8;
  --blue-dark: #1558b0;
  --blue-soft: #e8f0fe;
  --green: #188038;
  --danger: #b3261e;
  --yellow: #fbbc04;
  --shadow: 0 12px 28px rgba(60, 64, 67, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button,
.button-link {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  padding: 0 18px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: var(--blue-dark);
}

button.secondary {
  background: #f1f3f4;
  color: var(--ink);
}

button.secondary:hover {
  background: #e8eaed;
}

button.danger {
  background: #fce8e6;
  color: var(--danger);
}

button.danger:hover {
  background: #fad2cf;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 13px;
  background: #fff;
  color: var(--ink);
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.13);
  outline: 0;
}

label {
  display: grid;
  gap: 6px;
}

.shell {
  width: 100%;
  min-height: 100vh;
}

.auth-panel {
  width: min(1120px, calc(100vw - 40px));
  min-height: 620px;
  margin: 28px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: center;
  gap: 56px;
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 5.2rem);
  line-height: 1;
  letter-spacing: 0;
}

.form {
  display: grid;
  gap: 16px;
}

.form label {
  color: var(--muted);
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  gap: 10px;
}

.app-panel {
  min-height: 100vh;
  background: var(--bg);
}

.drive-topbar {
  height: 72px;
  display: grid;
  grid-template-columns: 260px minmax(240px, 680px) minmax(220px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), #34a853);
  color: #fff;
  font-weight: 850;
}

.brand strong,
.brand span,
.account-box span {
  display: block;
}

.brand strong {
  font-size: 1.15rem;
}

.brand span {
  color: var(--muted);
  font-size: 0.82rem;
}

.search-box {
  position: relative;
  color: transparent;
}

.search-box span {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-box input {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  background: #edf2fa;
  padding-left: 76px;
}

.account-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.account-box span {
  max-width: 260px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 18px;
  background: #fff;
  border-right: 1px solid var(--line-soft);
}

.new-folder-form {
  display: grid;
  gap: 10px;
}

.new-folder-form button {
  justify-content: flex-start;
  min-height: 48px;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(60, 64, 67, 0.18);
}

.new-folder-form button::before {
  content: "+";
  color: var(--blue);
  font-size: 1.4rem;
  line-height: 1;
}

.side-nav {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.side-nav-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  border-radius: 999px;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 600;
}

.side-nav-item.active {
  background: var(--blue-soft);
  color: #174ea6;
}

.folder-list-wrap {
  margin-top: 18px;
}

.section-label,
.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.folder-list {
  display: grid;
  gap: 4px;
}

.folder-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
  text-align: left;
}

.folder-item:hover {
  background: #f1f3f4;
}

.folder-item.active {
  background: var(--blue-soft);
  color: #174ea6;
}

.folder-item::before {
  content: "";
  width: 20px;
  height: 15px;
  margin-right: 12px;
  border-radius: 4px 4px 2px 2px;
  background: var(--yellow);
  box-shadow: 5px -4px 0 -1px #fdd663;
  flex: 0 0 auto;
}

.folder-item span:first-child {
  min-width: 0;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-item span:last-child {
  min-width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
}

.gallery-area {
  min-width: 0;
  padding: 24px 28px 44px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 22px;
  padding-bottom: 18px;
}

.content-header h2 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.subtle,
.empty-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.quick-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-stats span {
  min-width: 96px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 0.82rem;
}

.quick-stats strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.action-strip {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(420px, 1.22fr);
  gap: 16px;
}

.upload-card,
.share-card {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 16px;
}

.drop-zone {
  min-height: 156px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1.5px dashed #a8c7fa;
  border-radius: 16px;
  background: #f8fbff;
  color: #174ea6;
  cursor: pointer;
  text-align: center;
  padding: 18px;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.drop-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
}

.card-heading {
  display: grid;
  gap: 2px;
}

.card-heading span {
  color: var(--muted);
  font-size: 0.88rem;
}

.share-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.share-form button {
  min-width: 148px;
}

.new-share {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid #c4d7ff;
  border-radius: 14px;
  background: var(--blue-soft);
}

.new-share code,
.share-row code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.email-status {
  margin: 0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.email-status.sent {
  background: #e6f4ea;
  color: #137333;
}

.email-status.blocked {
  background: #fef7e0;
  color: #8c4b00;
}

.share-actions,
.shares {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.shares {
  display: grid;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 10px 12px;
}

.file-toolbar {
  min-height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
  border-bottom: 1px solid var(--line);
}

.file-toolbar span {
  color: var(--muted);
  font-size: 0.9rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.photo-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  transition: box-shadow 0.16s ease, transform 0.16s ease;
}

.photo-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #edf1f7;
  cursor: pointer;
}

.photo-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.photo-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-gallery {
  grid-column: 1 / -1;
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.empty-gallery strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.toast,
.error {
  color: #fff;
  background: var(--danger);
  border-radius: 12px;
  padding: 12px 14px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(32, 33, 36, 0.72);
  padding: 22px;
}

.preview-shell {
  width: min(1100px, 96vw);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.28);
}

.preview-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.preview-bar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-bar div {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

#previewImage {
  width: 100%;
  height: 100%;
  max-height: calc(94vh - 64px);
  object-fit: contain;
  background: #111;
}

.viewer .drive-topbar,
.viewer .topbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
}

@media (max-width: 1040px) {
  .drive-topbar {
    grid-template-columns: 1fr;
    height: auto;
    position: static;
  }

  .account-box {
    justify-content: space-between;
  }

  .workspace,
  .action-strip,
  .share-form,
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

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

@media (max-width: 640px) {
  .gallery-area,
  .sidebar,
  .drive-topbar {
    padding: 16px;
  }

  .auth-panel {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: 24px;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }
}
