/* 布局与组件样式 —— 依赖 tokens.css 提供的变量 */

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-grid) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* ------------------------------- 头部 ------------------------------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

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

.brand .logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), #7b5cff);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: var(--shadow-sm);
}

.brand h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.theme-toggle,
.lang-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover,
.lang-toggle:hover {
  border-color: var(--border-strong);
}

.lang-toggle {
  min-width: 72px;
  justify-content: center;
  font-weight: 600;
}

/* ------------------------------- 卡片 ------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}

.card > h2 {
  font-size: 14.5px;
  margin: 0 0 14px;
  font-weight: 620;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card > h2 .idx {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

/* ------------------------------ Tab 切换 ----------------------------- */
.tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
  margin-bottom: 18px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ----------------------------- 拖拽区 ------------------------------ */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dropzone:hover {
  border-color: var(--primary);
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone .dz-icon {
  font-size: 26px;
  margin-bottom: 6px;
}

.dropzone .dz-title {
  font-weight: 600;
  font-size: 14px;
}

.dropzone .dz-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ----------------------------- 文件列表 ----------------------------- */
.filelist {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filelist:empty {
  display: none;
}

.fileitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.fileitem .fi-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fileitem .fi-meta {
  color: var(--text-faint);
  font-size: 11.5px;
  font-family: var(--mono);
}

.fileitem .fi-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.fileitem .fi-badge.enc {
  background: var(--success-soft);
  color: var(--success);
}

.fileitem .fi-remove {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.fileitem .fi-remove:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ------------------------------ 表单 ------------------------------- */
.row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.row:last-child {
  margin-bottom: 0;
}

.row label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-muted);
}

.input,
.textarea,
.select {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.textarea {
  resize: vertical;
  min-height: 60px;
}

.pw-field {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-field .input {
  padding-right: 76px;
}

.pw-field .pw-actions {
  position: absolute;
  right: 6px;
  display: flex;
  gap: 2px;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
}

.icon-btn:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-2 .row {
  margin-bottom: 0;
}

/* 颜色输入 */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-row input[type="color"] {
  width: 40px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}

.color-row .input {
  flex: 1;
  font-family: var(--mono);
}

/* 复选 */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ---------------------------- 强度条 ------------------------------- */
.meter {
  margin-top: 10px;
}

.meter .bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.meter .bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 0.25s ease, background 0.25s ease;
}

.meter .hint {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-muted);
}

.meter .hint .lvl {
  font-weight: 600;
}

/* ------------------------------ 按钮 ------------------------------- */
.btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: var(--shadow-sm);
}

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

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  margin-bottom: 6px;
}

.actions .btn {
  min-width: 110px;
}

.actions .btn-primary {
  padding-left: 24px;
  padding-right: 24px;
}

.download-all {
  margin: 16px 0 6px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.download-all .btn {
  width: 100%;
  justify-content: center;
}

/* ----------------------------- 进度 -------------------------------- */
.progress {
  margin-top: 14px;
  display: none;
}

.progress.show {
  display: block;
}

.progress .bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress .bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.2s ease;
}

.progress .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ----------------------------- 结果 -------------------------------- */
.result-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.result-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface-2);
}

.result-item .ri-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-item .ri-name {
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-item .ri-ok {
  color: var(--success);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.result-item .ri-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.result-item .ri-share {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.result-item .ri-share code {
  display: block;
  margin-top: 4px;
  padding: 7px 9px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  word-break: break-all;
  color: var(--text);
}

.btn-sm {
  font-size: 12.5px;
  padding: 7px 12px;
}

/* ------------------------------ 提示 ------------------------------- */
.notice {
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.notice strong {
  color: var(--text);
}

/* ------------------------------ Toast ------------------------------ */
.toast-host {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 420px;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  animation: toast-in 0.22s ease;
}

.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-actions { width: 100%; justify-content: flex-end; }
  .actions .btn { flex: 1 1 auto; min-width: 0; }
}
