:root {
  --blue: #1a73e8;
  --blue-hover: #1557b0;
  --red: #d93025;
  --red-hover: #b3261e;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #202124;
  --text2: #5f6368;
  --border: #dadce0;
  --hover: #f1f3f4;
  --radius: 8px;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---- Login ---- */

.screen { height: 100vh; }

#login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  padding: 48px 40px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  text-align: center;
  width: 360px;
  max-width: 90vw;
}

.login-icon { margin-bottom: 16px; }

.login-card h1 {
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 28px;
  color: var(--text);
}

.login-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color .15s;
}

.login-card input:focus { border-color: var(--blue); }

.error-text {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}

/* ---- Buttons ---- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--blue-hover); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--hover); }

.btn-danger {
  background: none;
  color: var(--red);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
}
.btn-danger:hover { background: #fce8e6; }
.btn-danger:disabled { opacity: .4; cursor: default; }
.btn-danger:disabled:hover { background: none; }

.btn-text {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  text-decoration: none;
}
.btn-text:hover { background: rgba(26,115,232,.08); }

.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--hover); }

.btn-action {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}
.btn-action:hover { background: var(--hover); color: var(--text); }

/* ---- Header ---- */

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

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.storage-info {
  font-size: 13px;
  color: var(--text2);
}

/* ---- Toolbar ---- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-right {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: flex-end;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text2);
  overflow-x: auto;
  white-space: nowrap;
}

.breadcrumb a {
  color: var(--blue);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 4px;
}
.breadcrumb a:hover { background: rgba(26,115,232,.08); }
.breadcrumb .sep { color: var(--border); margin: 0 2px; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ---- File Area ---- */

.file-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  min-height: 0;
}

#app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
}

.file-table thead {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}

.file-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.file-table td {
  padding: 6px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.file-table tbody tr {
  transition: background .1s;
}
.file-table tbody tr:hover { background: var(--hover); }
.file-table tbody tr.selected { background: #e8f0fe; }

.col-check { width: 40px; text-align: center !important; }
.col-check input { cursor: pointer; }
.col-name { min-width: 200px; }
.col-size { width: 100px; }
.col-date { width: 160px; }
.col-actions { width: 120px; }

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 0;
}
.file-name:hover .file-label { color: var(--blue); }

.file-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
  transition: color .1s;
}

.file-size, .file-date {
  color: var(--text2);
  font-size: 13px;
}

.file-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .1s;
}
tr:hover .file-actions { opacity: 1; }

/* ---- Empty / Loading ---- */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text2);
}
.empty-state p { margin-top: 12px; }
.empty-state .sub { font-size: 13px; }

.loading {
  display: flex;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Drop overlay ---- */

.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,115,232,.06);
  border: 2px dashed var(--blue);
  border-radius: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-content {
  text-align: center;
  color: var(--blue);
  font-size: 16px;
}
.drop-content p { margin-top: 8px; }

/* ---- Upload Panel ---- */

.upload-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 360px;
  max-height: 300px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.upload-list {
  overflow-y: auto;
  flex: 1;
}

.upload-item {
  padding: 10px 16px;
  border-bottom: 1px solid #f0f0f0;
}

.upload-item-name {
  font-size: 13px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item-bar {
  height: 4px;
  background: var(--hover);
  border-radius: 2px;
  overflow: hidden;
}

.upload-item-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width .2s;
}

.upload-item-fill.done { background: #188038; }
.upload-item-fill.error { background: var(--red); }

.upload-item-status {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

/* ---- Modals ---- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  width: 90vw;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}

.modal-small { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  flex-shrink: 0;
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.modal-body video,
.modal-body audio {
  max-width: 100%;
  max-height: 70vh;
}

.modal-body iframe {
  width: 100%;
  height: 70vh;
  border: none;
}

.modal-body pre {
  width: 100%;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.5;
  max-height: 70vh;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Share modal form */

#share-modal label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 12px;
}

#share-modal input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  margin-top: 4px;
  outline: none;
}
#share-modal input:focus { border-color: var(--blue); }

/* ---- Responsive ---- */

@media (max-width: 640px) {
  header { padding: 0 12px; }
  .toolbar { padding: 8px 12px; }
  .file-table td, .file-table th { padding: 6px 8px; }
  .col-date { display: none; }
  .col-size { width: 70px; }
  .file-label { max-width: 180px; }
  .upload-panel { width: calc(100vw - 32px); }
  .modal-content { width: 95vw; }
}
