:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --text: #151b23;
  --muted: #667085;
  --line: #d8dee6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #0f9f6e;
  --amber: #b7791f;
  --red: #d14343;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.10), transparent 32%),
    linear-gradient(315deg, rgba(15, 159, 110, 0.12), transparent 34%),
    var(--bg);
}

.login-shell {
  width: min(420px, 100%);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 28px;
}

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

.brand-row h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.brand-row.compact h1 {
  font-size: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #151b23;
  color: #fff;
  font-weight: 800;
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 46px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 9px;
  margin-top: 24px;
}

.login-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: #fff;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.login-submit {
  height: 46px;
  margin-top: 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.login-submit:hover {
  background: var(--accent-dark);
}

.login-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.google-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: conic-gradient(#4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
}

.config-warning {
  margin-top: 20px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #f5c2c7;
  color: #842029;
  background: #fff5f5;
  font-weight: 700;
}

.login-alert {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #fed7aa;
  color: #9a3412;
  background: #fff7ed;
  font-weight: 700;
}

.login-meta {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #151b23;
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.sidebar .brand-mark {
  background: #fff;
  color: #151b23;
}

.sidebar .brand-row p,
.sidebar small {
  color: #b8c2cc;
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #dbe4ee;
  background: transparent;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: #6b7280;
  font-size: 12px;
  font-weight: 800;
}

.nav-icon.green {
  background: var(--green);
}

.nav-icon.red {
  background: var(--red);
}

.nav-icon.amber {
  background: var(--amber);
}

.nav-icon.blue {
  background: var(--accent);
}

.storage-summary {
  margin-top: auto;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.storage-summary span {
  font-size: 28px;
  font-weight: 800;
}

.quota-text {
  margin: 8px 0 0;
  color: #b8c2cc;
  font-size: 12px;
}

.meter {
  height: 6px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 18%;
  height: 100%;
  background: var(--green);
}

.meter.wide {
  margin-top: 14px;
  background: #e5eaf0;
}

.settings-button {
  width: 100%;
  height: 36px;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.search-box {
  flex: 1;
  min-width: 180px;
}

.search-box input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-soft);
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.topbar-actions,
.details-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.action-button,
.segmented {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.action-button {
  padding: 0 14px;
}

.action-button.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.action-button.primary:hover {
  background: var(--accent-dark);
}

.action-button.secondary:hover,
.icon-button:hover,
.segmented:hover {
  background: var(--panel-soft);
}

.action-button.danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.pathbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
}

.breadcrumbs {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.crumb {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.crumb:hover {
  color: var(--text);
  background: #e6ebf0;
}

.crumb.current {
  color: var(--text);
  background: #dde5ee;
}

.view-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented {
  min-width: 58px;
  border: 0;
  background: transparent;
}

.segmented.active {
  color: #fff;
  background: #151b23;
}

.content-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  padding: 0 22px 22px;
}

.browser-panel,
.details-panel {
  min-height: 0;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.browser-panel {
  overflow: auto;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  padding: 16px;
}

.items-grid.list {
  display: block;
}

.item {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  text-align: left;
}

.item:hover,
.item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.item-button {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 14px;
}

.item.list {
  min-height: 58px;
  border-width: 0 0 1px;
  border-radius: 0;
}

.item.list .item-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 100px 140px;
  align-items: center;
  gap: 12px;
}

.item-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: #6b7280;
  font-weight: 800;
}

.item-icon.folder {
  background: var(--amber);
}

.item-icon.images {
  background: var(--green);
}

.item-icon.videos {
  background: var(--red);
}

.item-icon.audios {
  background: #7c3aed;
}

.item-icon.files {
  background: var(--accent);
}

.item-name {
  margin-top: 14px;
  font-weight: 800;
  word-break: break-word;
}

.item.list .item-name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.details-panel {
  padding: 16px;
  overflow: auto;
}

.details-empty h2,
.details-content h2,
.empty-state h2 {
  margin: 0;
  font-size: 18px;
}

.details-empty p,
.empty-state p {
  color: var(--muted);
}

.preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview audio {
  width: 92%;
}

dl {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

dl div {
  display: grid;
  gap: 4px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  word-break: break-word;
}

.empty-state {
  padding: 52px 16px;
  text-align: center;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 5;
  pointer-events: none;
  display: none;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.90);
  font-weight: 900;
  font-size: 24px;
}

.drop-overlay.active {
  display: grid;
}

dialog {
  width: min(420px, calc(100% - 32px));
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#settingsDialog {
  width: min(980px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  padding: 18px;
}

.modal-card h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.modal-card label {
  display: block;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}

.modal-card input {
  width: 100%;
  height: 42px;
  margin: 8px 0 16px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.modal-card select {
  width: 100%;
  height: 42px;
  margin: 8px 0 16px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.modal-actions {
  justify-content: flex-end;
}

.share-result {
  padding: 10px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: #eff6ff;
  word-break: break-all;
  font-weight: 700;
}

.context-menu {
  position: fixed;
  z-index: 40;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.context-menu button {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
}

.context-menu button:hover {
  background: var(--panel-soft);
}

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

.settings-card {
  width: 100%;
  height: min(720px, calc(100vh - 32px));
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: #fff;
  overflow: hidden;
}

.settings-header {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-header h2 {
  margin: 0;
  font-size: 20px;
}

.settings-header p {
  margin: 4px 0 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-tabs {
  min-width: 0;
  display: flex;
  gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}

.settings-tab {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.settings-tab.active {
  color: #fff;
  background: #151b23;
  border-color: #151b23;
}

.settings-panel {
  display: none;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px;
  scrollbar-width: thin;
}

.settings-panel.active {
  display: block;
}

.settings-form {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.settings-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-form input,
.settings-form select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-form {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  align-items: end;
  margin-bottom: 16px;
}

.user-form .action-button {
  min-width: 0;
  white-space: nowrap;
}

.quota-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.quota-card strong {
  display: block;
  font-size: 28px;
}

.filesystem-grid {
  margin-bottom: 12px;
}

.filesystem-paths {
  margin-top: 16px;
}

.filesystem-root-form {
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(190px, 0.9fr) auto;
  align-items: end;
  margin-top: 16px;
}

.filesystem-root-form label {
  display: none;
}

.filesystem-path-row {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.filesystem-history {
  margin-top: 16px;
}

.filesystem-history-row {
  grid-template-columns: minmax(240px, 1.4fr) minmax(180px, 0.9fr);
}

.settings-section-title {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.filesystem-path-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  word-break: break-all;
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.quota-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.quota-grid small,
.api-result small,
.settings-note {
  color: var(--muted);
}

.quota-grid strong {
  margin-top: 4px;
  font-size: 18px;
  word-break: break-word;
}

.settings-note {
  margin: 14px 0 0;
  font-size: 13px;
}

.api-form {
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 0.8fr) minmax(150px, 1fr) minmax(120px, 0.7fr) auto;
  align-items: end;
  margin-bottom: 16px;
}

.api-form label {
  display: none;
}

.api-result {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.api-result label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.api-result code,
.api-result pre {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #0f172a;
  background: #fff;
  white-space: pre-wrap;
  word-break: break-all;
}

.api-token-row {
  grid-template-columns: minmax(180px, 1.3fr) minmax(130px, 0.8fr) minmax(90px, 0.6fr) minmax(260px, auto);
}

.api-token-row .topbar-actions {
  flex-wrap: wrap;
}

.table-list {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.table-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(96px, 120px) minmax(92px, 120px) minmax(150px, auto);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-row > * {
  min-width: 0;
}

.table-row input,
.table-row select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
}

.table-row .topbar-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.table-row .action-button {
  min-height: 36px;
  padding: 0 10px;
  white-space: nowrap;
}

.table-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-row small {
  color: var(--muted);
}

.upload-tray {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 18;
  width: min(420px, calc(100vw - 36px));
  max-height: min(460px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upload-tray header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.upload-tray strong,
.upload-tray small {
  display: block;
}

.upload-tray small {
  color: var(--muted);
}

.upload-list {
  min-height: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
}

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

.upload-row .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.upload-row .file-meta,
.upload-row .file-status {
  color: var(--muted);
  font-size: 12px;
}

.upload-progress {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf0;
}

.upload-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.upload-row.done .upload-progress span {
  background: var(--green);
}

.upload-row.failed .upload-progress span,
.upload-row.canceled .upload-progress span {
  background: var(--red);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #151b23;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.upload-tray:not(.hidden) ~ .toast {
  right: 456px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .content-layout {
    grid-template-columns: 1fr;
  }

  .details-panel {
    min-height: 260px;
  }

  #settingsDialog {
    width: calc(100vw - 20px);
  }

  .settings-card {
    height: calc(100vh - 20px);
  }

  .user-form {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .api-form {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .table-row {
    grid-template-columns: minmax(0, 1fr) minmax(96px, 120px);
  }

  .api-token-row {
    grid-template-columns: minmax(0, 1fr) minmax(120px, 150px);
  }

  .table-row .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .upload-tray:not(.hidden) ~ .toast {
    right: 18px;
    bottom: min(500px, calc(100vh - 72px));
  }
}

@media (max-width: 660px) {
  .topbar,
  .pathbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .content-layout {
    padding: 0 12px 12px;
  }

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

  .item.list .item-button {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .item.list .item-meta.extra {
    display: none;
  }

  .user-form,
  .api-form,
  .quota-grid,
  .table-row {
    grid-template-columns: 1fr;
  }

  .settings-header,
  .settings-panel {
    padding: 14px;
  }

  .settings-tabs {
    padding: 10px 14px;
  }

  .table-row .topbar-actions {
    flex-wrap: wrap;
  }
}
