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

:root {
  --tg-theme-bg-color: #ffffff;
  --tg-theme-text-color: #000000;
  --tg-theme-hint-color: #999999;
  --tg-theme-link-color: #2481cc;
  --tg-theme-button-color: #2481cc;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-secondary-bg-color: #f0f0f0;
  --tg-theme-header-bg-color: #ffffff;
  --tg-theme-accent-text-color: #2481cc;
  --tg-theme-section-bg-color: #ffffff;
  --tg-theme-section-header-text-color: #2481cc;
  --tg-theme-subtitle-text-color: #999999;
  --tg-theme-destructive-text-color: #ff3b30;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.header {
  padding: 16px 0;
  margin-bottom: 20px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background-color: var(--tg-theme-section-bg-color);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.user-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--tg-theme-button-color), var(--tg-theme-link-color));
  color: var(--tg-theme-button-text-color);
  border-radius: 50%;
  font-size: 20px;
  font-weight: 600;
}

.premium-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 16px;
  line-height: 1;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--tg-theme-text-color);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-username {
  font-size: 14px;
  color: var(--tg-theme-hint-color);
  margin: 2px 0 0 0;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.upload-section {
  display: flex;
  justify-content: center;
}

.upload-area {
  width: 100%;
  max-width: 400px;
  padding: 40px 20px;
  border: 2px dashed var(--tg-theme-hint-color);
  border-radius: 16px;
  background-color: var(--tg-theme-secondary-bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-area:active {
  transform: scale(0.98);
  border-color: var(--tg-theme-button-color);
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--tg-theme-button-color);
}

.upload-text {
  font-size: 16px;
  color: var(--tg-theme-hint-color);
  text-align: center;
}

.files-section {
  flex: 1;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--tg-theme-section-header-text-color);
  margin-bottom: 12px;
  padding-left: 4px;
}

.files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--tg-theme-hint-color);
  font-size: 14px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background-color: var(--tg-theme-section-bg-color);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tg-theme-secondary-bg-color);
  border-radius: 8px;
  flex-shrink: 0;
}

.file-icon svg {
  width: 24px;
  height: 24px;
  color: var(--tg-theme-button-color);
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--tg-theme-text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 12px;
  color: var(--tg-theme-hint-color);
  margin-top: 2px;
}

.file-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.file-action:active {
  background-color: var(--tg-theme-secondary-bg-color);
}

.file-action svg {
  width: 20px;
  height: 20px;
  color: var(--tg-theme-hint-color);
}

button {
  font-family: inherit;
}

/* Loading Screen */
.loading-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--tg-theme-secondary-bg-color);
  border-top-color: var(--tg-theme-button-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 16px;
  color: var(--tg-theme-hint-color);
}

/* Error Screen */
.error-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.error-icon {
  width: 64px;
  height: 64px;
  color: var(--tg-theme-destructive-text-color);
}

.error-icon svg {
  width: 100%;
  height: 100%;
}

.error-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--tg-theme-text-color);
  margin: 0;
}

.error-message {
  font-size: 14px;
  color: var(--tg-theme-hint-color);
  margin: 0;
  max-width: 280px;
}

.retry-button {
  margin-top: 8px;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 500;
  color: var(--tg-theme-button-text-color);
  background-color: var(--tg-theme-button-color);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.retry-button:active {
  opacity: 0.8;
}

/* Login Screen */
.login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.login-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--tg-theme-text-color);
  margin: 0;
}

.login-subtitle {
  font-size: 16px;
  color: var(--tg-theme-hint-color);
  margin: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tg-theme-bg-color: #212121;
    --tg-theme-text-color: #ffffff;
    --tg-theme-hint-color: #aaaaaa;
    --tg-theme-link-color: #8cc4ff;
    --tg-theme-button-color: #8cc4ff;
    --tg-theme-button-text-color: #000000;
    --tg-theme-secondary-bg-color: #181818;
    --tg-theme-header-bg-color: #212121;
    --tg-theme-accent-text-color: #8cc4ff;
    --tg-theme-section-bg-color: #2c2c2c;
    --tg-theme-section-header-text-color: #8cc4ff;
    --tg-theme-subtitle-text-color: #aaaaaa;
    --tg-theme-destructive-text-color: #ff6b6b;
  }
}
