/* ============================================================
   华子轨交服务器存档备份下载 · Material Design 3 风格样式
   颜色令牌参考 M3 baseline（主色取自 Material You 蓝）
   ============================================================ */

:root {
  --primary: #0B57D0;
  --on-primary: #FFFFFF;
  --primary-container: #D3E3FD;
  --on-primary-container: #041E49;
  --secondary-container: #E1E2EC;
  --on-secondary-container: #1B1B1F;

  --surface: #F8F9FC;
  --surface-1: #FFFFFF;
  --surface-2: #FFFFFF;
  --scrim-soft: rgba(11, 87, 208, 0.08);
  --hover: rgba(11, 87, 208, 0.08);
  --on-surface: #1A1C1E;
  --on-surface-variant: #44474E;
  --outline: #74777E;
  --outline-variant: #D7DAE0;
  --field-bg: #E7EBF4;
  --error: #B3261E;
  --error-container: #F9DEDC;

  --snack-bg: #323232;
  --snack-fg: #F3F3F3;

  --elev-1: 0 1px 2px rgba(0, 0, 0, .10), 0 1px 3px 1px rgba(0, 0, 0, .06);
  --elev-2: 0 1px 2px rgba(0, 0, 0, .12), 0 2px 6px 2px rgba(0, 0, 0, .08);
  --shape-card: 16px;
  --shape-field: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #A8C7FA;
    --on-primary: #062E6F;
    --primary-container: #0842A0;
    --on-primary-container: #D3E3FD;
    --secondary-container: #44474E;
    --on-secondary-container: #E2E2E9;

    --surface: #131314;
    --surface-1: #1C1E22;
    --surface-2: #1E2126;
    --scrim-soft: rgba(168, 199, 250, 0.10);
    --hover: rgba(168, 199, 250, 0.10);
    --on-surface: #E3E2E6;
    --on-surface-variant: #C4C6D0;
    --outline: #8E9199;
    --outline-variant: #3D4045;
    --field-bg: #282B31;
    --error: #F2B8B5;
    --error-container: #5C1611;

    --snack-bg: #E3E2E6;
    --snack-fg: #1B1B1F;

    --elev-1: 0 1px 2px rgba(0, 0, 0, .5);
    --elev-2: 0 2px 6px 2px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Roboto, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--surface);
  color: var(--on-surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶部应用栏 ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-1);
  box-shadow: var(--elev-1);
}

.appbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.appbar-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary-container);
  display: grid;
  place-items: center;
  flex: none;
}

.appbar-titles { min-width: 0; }

.appbar-titles h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-sub {
  font-size: 12px;
  color: var(--on-surface-variant);
}

.appbar-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

/* 线性进度条（不确定模式） */
.progress {
  height: 3px;
  overflow: hidden;
  background: transparent;
}

.progress-bar {
  width: 35%;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  animation: indeterminate 1.4s infinite ease-in-out;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ---------------- 布局 ---------------- */
.container {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.page-foot {
  text-align: center;
  font-size: 12px;
  color: var(--on-surface-variant);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface-1);
  border-radius: var(--shape-card);
  box-shadow: var(--elev-1);
}

/* ---------------- 登录视图 ---------------- */
.login-card {
  max-width: 420px;
  margin: 40px auto 0;
  padding: 32px 28px 24px;
  text-align: center;
  animation: card-in .25s ease-out;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.login-card.shake { animation: shake .4s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.avatar {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary-container);
  display: grid;
  place-items: center;
}

.login-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: .3px;
}

.hint {
  color: var(--on-surface-variant);
  font-size: 13px;
}

.login-card form { text-align: left; margin-top: 20px; }

.foot-note {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--on-surface-variant);
}

/* ---------------- Material 填充式输入框 ---------------- */
.md-field {
  position: relative;
  margin-top: 16px;
}

.md-field input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--on-surface);
  background: var(--field-bg);
  border: none;
  border-bottom: 1px solid var(--outline);
  border-radius: var(--shape-field) var(--shape-field) 0 0;
  padding: 24px 16px 8px;
  outline: none;
  transition: box-shadow .12s;
}

.md-field input:focus {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 7px;
}

.md-field label {
  position: absolute;
  left: 16px;
  top: 17px;
  font-size: 16px;
  color: var(--on-surface-variant);
  pointer-events: none;
  transition: all .15s ease-out;
}

.md-field.filled label,
.md-field.focus label {
  top: 6px;
  font-size: 12px;
  color: var(--primary);
}

.md-field .icon-btn.trailing {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  color: var(--on-surface-variant);
}

/* ---------------- 按钮 ---------------- */
.btn {
  position: relative;
  overflow: hidden;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .4px;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn.contained {
  height: 44px;
  padding: 0 28px;
  border-radius: 22px;
  background: var(--primary);
  color: var(--on-primary);
  width: 100%;
  margin-top: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: box-shadow .15s, filter .15s;
}

.btn.contained:hover { box-shadow: var(--elev-2); filter: brightness(1.04); }
.btn.contained:active { filter: brightness(.96); box-shadow: var(--elev-1); }
.btn.contained:disabled { opacity: .5; cursor: default; box-shadow: none; }

.btn.text {
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
}

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

.icon-btn {
  position: relative;
  overflow: hidden;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface-variant);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover { background: var(--hover); color: var(--on-surface); }

/* 涟漪 */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: currentColor;
  opacity: .22;
  pointer-events: none;
  animation: ripple .45s ease-out forwards;
}

@keyframes ripple {
  to { transform: scale(2.4); opacity: 0; }
}

/* 圆形加载指示器 */
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-top-color: transparent;
  animation: spin .8s linear infinite;
}

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

/* ---------------- 下载视图 ---------------- */
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 4px 14px;
}

.toolbar-row h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 500;
}

.chip {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

.list-card { overflow: hidden; }

.file-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  position: relative;
  transition: background .12s;
}

.file-item:hover { background: var(--scrim-soft); }

.file-item + .file-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--outline-variant);
}

.file-icon {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary-container);
  display: grid;
  place-items: center;
}

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

.file-name {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-all;
}

.file-meta {
  font-size: 12.5px;
  color: var(--on-surface-variant);
  margin-top: 2px;
}

.file-item .icon-btn.download {
  flex: none;
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.file-item .icon-btn.download:hover { filter: brightness(1.05); }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--on-surface-variant);
}

.empty-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--on-surface);
  margin: 12px 0 4px;
}

.empty .hint { font-size: 13px; }

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 4px 0;
}

/* ---------------- Snackbar ---------------- */
.snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  min-width: 280px;
  max-width: min(92vw, 560px);
  background: var(--snack-bg);
  color: var(--snack-fg);
  border-radius: 8px;
  padding: 14px 20px;
  font-size: 14px;
  box-shadow: var(--elev-2);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 20;
}

.snackbar.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 480px) {
  .appbar-titles h1 { font-size: 15px; }
  .login-card { margin-top: 24px; padding: 26px 20px 20px; }
  .login-title { font-size: 23px; }
  .container { padding: 16px 10px 32px; }
  .snackbar { min-width: auto; width: calc(100vw - 24px); }
}
