:root {
  --bg-shell: #f8fafd;
  --bg-surface: #ffffff;
  --bg-search: #e9eef6;
  --bg-hover: #f0f4f9;
  --bg-active-pill: #c2e7ff;
  --text-active-pill: #001d35;
  --primary: #0b57d0;
  --text: #1f1f1f;
  --text-muted: #444746;
  --text-subtle: #747775;
  --border: #e0e3e7;
  --danger: #b3261e;
  --success: #146c2e;
  --shadow-fab: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
  --shadow-menu: 0 2px 6px 2px rgba(60, 64, 67, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-shell);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Google Drive Header */
.topbar {
  height: 64px;
  background: var(--bg-shell);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 21px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.2px;
}

.search-pill {
  flex: 1;
  max-width: 680px;
  height: 46px;
  background: var(--bg-search);
  border-radius: 999px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 12px;
  transition: background 0.15s, box-shadow 0.15s;
}

.search-pill:focus-within {
  background: var(--bg-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.search-pill input {
  border: none;
  background: transparent;
  width: 100%;
  font-size: 15px;
  color: var(--text);
  outline: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-badge {
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  background: #e6f4ea;
  color: var(--success);
}

.sync-badge.offline {
  background: #fce8e6;
  color: var(--danger);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.row-del-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.row-del-btn:hover {
  background: #fce8e6;
  border-color: #f9dedc;
  color: var(--danger);
}

.menu-icon {
  font-size: 18px;
  color: var(--text-muted);
}

.nav-icon {
  font-size: 19px;
}

.row-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.row-icon.folder {
  color: #444746;
}

.row-icon.code {
  color: #0b57d0;
}

.row-icon.image {
  color: #b3261e;
}

.row-icon.file {
  color: #5f6368;
}

.user-chip {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Main Workspace Layout */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 0 16px 16px 0;
}

/* Google Drive Left Sidebar */
.sidebar {
  width: 256px;
  background: var(--bg-shell);
  padding: 4px 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.new-btn-wrapper {
  position: relative;
}

.new-fab-btn {
  height: 56px;
  padding: 0 22px 0 18px;
  background: var(--bg-surface);
  color: var(--text);
  border: none;
  border-radius: 16px;
  box-shadow: var(--shadow-fab);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s, box-shadow 0.15s;
}

.new-fab-btn:hover {
  background: #f3f6fc;
  box-shadow: 0 2px 6px 0 rgba(60, 64, 67, 0.3), 0 6px 12px 4px rgba(60, 64, 67, 0.15);
}

.new-menu {
  position: absolute;
  top: 62px;
  left: 0;
  width: 230px;
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-menu);
  border: 1px solid var(--border);
  padding: 6px 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.menu-item {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-hover);
}

.nav-item.active {
  background: var(--bg-active-pill);
  color: var(--text-active-pill);
  font-weight: 600;
}

.storage-summary {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Google Drive Rounded White Surface Container */
.main-surface {
  flex: 1;
  background: var(--bg-surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.surface-header {
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
}

.crumb {
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 400;
  color: var(--text-muted);
}

.crumb:hover {
  background: var(--bg-hover);
}

.crumb.current {
  color: var(--text);
  font-weight: 500;
}

.crumb-sep {
  color: var(--text-subtle);
  font-size: 15px;
}

/* Google Drive File Table */
.drive-list-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.drive-table-header {
  display: grid;
  grid-template-columns: 1fr 140px 120px 100px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.drive-row {
  display: grid;
  grid-template-columns: 1fr 140px 120px 100px;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid #f1f3f4;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

.drive-row:hover {
  background: var(--bg-hover);
}

.drive-row-name {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-row-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.drive-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

/* Buttons */
button, .btn-label {
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}

button:hover, .btn-label:hover {
  background: var(--bg-hover);
}

button.primary, .btn-label.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

button.primary:hover, .btn-label.primary:hover {
  background: #0842a0;
}

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

input[type="text"], input[type="search"] {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  width: 100%;
}

/* Integrated Editor View */
.editor-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lang-select {
  font-family: inherit;
  background: var(--bg-shell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.lang-select:hover {
  background: var(--bg-hover);
}

.editor-statusbar {
  height: 30px;
  padding: 0 18px;
  background: var(--bg-shell);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#monaco-container {
  flex: 1;
  width: 100%;
  height: 100%;
}

#fallback-editor {
  flex: 1;
  width: 100%;
  height: 100%;
  background: var(--bg-surface);
  color: var(--text);
  border: none;
  padding: 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
  resize: none;
  outline: none;
  display: none;
}

#binary-view, #empty-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

#binary-view img {
  max-width: 80%;
  max-height: 55vh;
  border-radius: 12px;
  border: 1px solid var(--border);
}

#drop-overlay {
  position: fixed;
  inset: 16px;
  background: rgba(232, 240, 254, 0.94);
  border: 2px dashed var(--primary);
  border-radius: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 500;
  color: var(--primary);
  pointer-events: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: 24px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-menu);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-section {
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Google Drive Floating Sync / Upload Progress Card */
.upload-progress-card {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-fab);
  padding: 14px 16px;
  z-index: 85;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.upload-progress-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.upload-progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-search);
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.15s ease, background 0.2s ease;
}

.upload-progress-bar-fill.done {
  background: var(--success);
}

.upload-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.upload-progress-file {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.upload-progress-bytes {
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .brand {
    min-width: auto;
  }
  .workspace {
    padding: 0 8px 8px 8px;
  }
  .sidebar {
    position: absolute;
    left: 0;
    top: 64px;
    bottom: 0;
    z-index: 30;
    box-shadow: var(--shadow-menu);
    transform: translateX(0);
    transition: transform 0.2s ease;
  }
  .sidebar.collapsed {
    transform: translateX(-105%);
  }
  .drive-table-header, .drive-row {
    grid-template-columns: 1fr 80px 70px;
  }
  .hide-mobile {
    display: none;
  }
}
