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

body {
  background: #000;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* Layout */
.layout { display: flex; height: 100vh; width: 100vw; }
.content { flex: 1; position: relative; overflow: hidden; }

.tab-pane { position: absolute; inset: 0; display: none; }
.tab-pane.visible { display: flex; flex-direction: column; }

.tab-pane iframe { width: 100%; height: 100%; border: none; background: #000; }

.home { height: 100%; display: flex; align-items: center; justify-content: center; }
.home h1 { font-size: 48px; font-weight: 300; color: #333; letter-spacing: 0.1em; }

/* Sidebar */
.sidebar {
  width: 180px; min-width: 180px; height: 100vh;
  background: #0a0a0a; border-right: 1px solid #1a1a1a;
  display: flex; flex-direction: column; user-select: none;
}
.logo {
  padding: 20px 16px 16px; font-size: 20px; font-weight: 600;
  letter-spacing: 0.05em; color: #e0e0e0;
  background: none; border: none; text-align: left; cursor: pointer;
}
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.tab {
  background: none; border: none; color: #808080; font-size: 14px;
  padding: 8px 12px; text-align: left; border-radius: 6px; cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.tab:hover { background: #1a1a1a; color: #c0c0c0; }
.tab.active { background: #1a1a1a; color: #fff; }

/* R2 — general */
.r2 { height: 100%; display: flex; flex-direction: column; background: #0a0a0a; color: #e0e0e0; }

/* Credentials form */
.creds-form { height: 100%; display: flex; align-items: center; justify-content: center; background: #0a0a0a; }
.creds-card {
  width: 400px; padding: 32px; background: #111;
  border: 1px solid #1a1a1a; border-radius: 8px;
}
.creds-card h2 { font-size: 18px; font-weight: 500; color: #e0e0e0; margin-bottom: 4px; }
.creds-card .hint { font-size: 12px; color: #666; margin-bottom: 20px; }
.creds-card label { display: block; margin-bottom: 12px; }
.creds-card label span { display: block; font-size: 12px; color: #888; margin-bottom: 4px; }
.creds-card input {
  width: 100%; padding: 8px 10px; background: #0a0a0a;
  border: 1px solid #333; border-radius: 4px; color: #e0e0e0;
  font-size: 13px; outline: none;
}
.creds-card input:focus { border-color: #555; }
.creds-card .error { color: #e55; font-size: 12px; margin-bottom: 8px; }
.creds-card .connect-btn {
  width: 100%; padding: 10px; background: #1a4a2e; border: 1px solid #2a6a3e;
  border-radius: 6px; color: #e0e0e0; font-size: 14px; cursor: pointer; margin-top: 4px;
}
.creds-card .connect-btn:hover { background: #1e5a34; }

/* Bucket picker */
.bucket-picker { padding: 40px; overflow-y: auto; height: 100%; }
.bucket-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.bucket-header h2 { font-size: 16px; font-weight: 500; color: #888; }
.logout-btn {
  background: none; border: 1px solid #333; color: #888;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.logout-btn:hover { color: #e55; border-color: #e55; }
.bucket-list { display: flex; flex-direction: column; gap: 4px; }
.bucket-btn {
  background: #111; border: 1px solid #1a1a1a; color: #e0e0e0;
  padding: 10px 14px; text-align: left; border-radius: 6px;
  cursor: pointer; font-size: 14px;
}
.bucket-btn:hover { background: #1a1a1a; border-color: #333; }
.bucket-btn.selected { background: #1a2a3a; border-color: #2a4a6a; }

/* Toolbar */
.r2-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid #1a1a1a;
  background: #0f0f0f; min-height: 40px;
}
.back-btn {
  background: none; border: 1px solid #333; color: #aaa;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 14px;
}
.back-btn:hover { background: #1a1a1a; color: #fff; }
.breadcrumbs { display: flex; align-items: center; gap: 2px; overflow-x: auto; font-size: 13px; }
.crumb {
  background: none; border: none; color: #6a9ff5; cursor: pointer;
  padding: 2px 4px; border-radius: 3px; font-size: 13px;
}
.crumb:hover { background: #1a1a1a; }
.crumb.current { color: #e0e0e0; cursor: default; }
.crumb.current:hover { background: none; }
.sep { color: #444; }

.search-input {
  background: #111; border: 1px solid #333; color: #e0e0e0;
  padding: 4px 10px; border-radius: 4px; font-size: 13px; outline: none; width: 180px;
}
.search-input:focus { border-color: #555; }
.search-input::placeholder { color: #555; }
.bucket-search { width: 100%; margin-bottom: 12px; padding: 8px 12px; }

.copy-btn {
  background: none; border: none; color: #555; cursor: pointer;
  font-size: 14px; padding: 2px 4px; margin-right: auto;
  line-height: 1; transition: color 0.1s;
}
.copy-btn:hover { color: #fff; }
.copy-btn.copied { color: #4a9; }

/* File browser */
.browser { flex: 1; display: flex; overflow: hidden; }
.listing { flex: 1; overflow-y: auto; }
.listing.has-preview { flex: 0 0 50%; border-right: 1px solid #1a1a1a; }

.listing table { width: 100%; border-collapse: collapse; }
.listing thead th {
  text-align: left; padding: 6px 12px; font-size: 11px; color: #666;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid #1a1a1a; position: sticky; top: 0; background: #0a0a0a;
}
.row { cursor: pointer; }
.row td { padding: 6px 12px; font-size: 13px; border-bottom: 1px solid #111; }
.row:hover td { background: #141414; }
.row.selected td { background: #1a2a3a; }
.row.selected:hover td { background: #1e3045; }
.icon { margin-right: 6px; }
.size-col { width: 80px; text-align: right; color: #666; }
.empty { padding: 40px; text-align: center; color: #555; }
.error-msg { color: #e55; }

/* Preview */
.preview { flex: 0 0 50%; display: flex; flex-direction: column; overflow: hidden; }
.preview-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid #1a1a1a; background: #0f0f0f;
}
.preview-name { font-size: 13px; color: #aaa; }
.preview-close {
  background: none; border: none; color: #666; cursor: pointer;
  font-size: 16px; padding: 0 4px;
}
.preview-close:hover { color: #fff; }
.preview-content {
  flex: 1; overflow: auto; display: flex; align-items: center;
  justify-content: center; padding: 12px;
}
.preview-content video { max-width: 100%; max-height: 100%; }
.preview-content audio { width: 80%; }
.preview-content img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-content pre {
  width: 100%; height: 100%; overflow: auto; font-size: 12px; color: #ccc;
  white-space: pre-wrap; word-break: break-word; align-self: flex-start;
}

.listing-status {
  padding: 6px 12px; font-size: 11px; color: #666;
  border-bottom: 1px solid #1a1a1a; position: sticky; top: 0;
  background: #0a0a0a; z-index: 1;
}
.scroll-sentinel { height: 1px; }
