/* ===== 极简拾影随笔 · 全局样式（响应式）===== */

:root {
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --text-muted: #8a8a8a;
  --border: #e5e5e0;
  --primary: #2e7d32;
  --primary-hover: #1b5e20;
  --primary-light: #e8f5e9;
  --warn: #f9a825;
  --warn-bg: #fff8e1;
  --error: #c62828;
  --error-bg: #ffebee;
  --danger: #c62828;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

img, video { max-width: 100%; height: auto; }

.container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== 头部 ===== */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.logo {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .5px;
  white-space: nowrap;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  font-size: .9rem;
  border-radius: 4px;
  transition: all .15s;
  white-space: nowrap;
}
.nav a:hover { color: var(--primary); background: var(--primary-light); }

/* ===== 主内容 ===== */
.main-content {
  flex: 1;
  padding-top: 24px;
  padding-bottom: 32px;
  width: 100%;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.card-narrow {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.card-highlight { border-left: 3px solid var(--primary); }
.card h1 { font-size: 1.4rem; margin-bottom: 10px; }
.card h2 { font-size: 1.1rem; margin-bottom: 8px; }
.card h3 { font-size: 1rem; margin-bottom: 8px; margin-top: 16px; }

.text-center { text-align: center; }

/* ===== Flash ===== */
.flash-list { margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 8px;
  word-wrap: break-word;
}
.flash-success { background: var(--primary-light); color: var(--primary); }
.flash-error   { background: var(--error-bg); color: var(--error); }
.flash-warn    { background: var(--warn-bg); color: #e65100; }

/* ===== 表单 ===== */
.form { margin-top: 14px; }
.form label {
  display: block;
  margin-bottom: 14px;
}
.form label > span {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text);
}
/* 记住我 checkbox（登录页）*/
.form .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.form .checkbox-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}
.form .checkbox-row span {
  margin: 0;
  font-size: .88rem;
  font-weight: 400;
}
.form input[type="email"],
.form input[type="password"],
.form input[type="text"],
.form input[type="date"],
.form input[type="datetime-local"],
.form input[type="file"],
.form textarea {
  width: 100%;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
}
.form input:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form textarea { resize: vertical; min-height: 80px; }
.form input[type="file"] { padding: 7px; font-size: .88rem; }
.form .required { color: var(--error); font-style: normal; }

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.form-row .flex-1 { flex: 1; min-width: 0; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  flex-wrap: wrap;
}
.form-footer {
  margin-top: 14px;
  font-size: .88rem;
  color: var(--text-muted);
  text-align: center;
}
.form-footer a { color: var(--primary); }
.form-links {
  margin-top: 14px;
  text-align: center;
  font-size: .88rem;
}
.form-links a { color: var(--primary); text-decoration: none; }
.form-links a:hover { text-decoration: underline; }
.form-links .sep { color: var(--text-muted); margin: 0 6px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b71c1c; }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ===== 仪表盘网格 ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.dashboard-grid .card { margin-bottom: 0; }

/* ===== 横幅（顶部提示）===== */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .88rem;
  margin-bottom: 14px;
}
.banner-warn { background: var(--warn-bg); color: #e65100; }
.banner-link {
  color: #e65100;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.banner-link:hover { text-decoration: underline; }

/* ===== 信息列表 ===== */
.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  margin: 10px 0;
}
.info-list dt {
  font-size: .82rem;
  color: var(--text-muted);
  align-self: center;
  white-space: nowrap;
}
.info-list dd {
  font-size: .92rem;
  word-break: break-all;
  min-width: 0;
}
.link-edit {
  font-size: .8rem;
  color: var(--primary);
  margin-left: 6px;
  text-decoration: none;
}

/* ===== 上传状态 ===== */
.upload-status {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: .88rem;
  margin-bottom: 14px;
}
.upload-status.loading { background: var(--warn-bg); color: #e65100; }
.upload-status.success { background: var(--primary-light); color: var(--primary); }
.upload-status.error { background: var(--error-bg); color: var(--error); }

/* ===== 文件列表 ===== */
.file-list { margin-bottom: 16px; }
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== 元数据表格 ===== */
.meta-table, .user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  min-width: 480px;
}
.meta-table th, .meta-table td,
.user-table th, .user-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.meta-table th, .user-table th {
  background: #fafaf8;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.meta-table .file-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-table .reason-cell {
  max-width: 200px;
  word-break: break-all;
}
.user-table .action-cell {
  white-space: nowrap;
}
.inline-form { display: inline; }

/* ===== 地点选择器（朋友圈样式）===== */
.loc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s;
}
.loc-row:hover { border-color: var(--primary); }
.loc-pin { flex: none; }
.loc-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: .95rem;
}
.loc-row.has-loc .loc-name {
  color: #07c160; /* 朋友圈地点绿 */
  font-weight: 500;
}
.loc-clear {
  flex: none;
  display: none;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .8rem;
  padding: 2px 4px;
}
.loc-clear:hover { color: var(--text); }

.loc-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 12px 12px;
}
.loc-modal-card {
  background: #fff;
  border-radius: 12px;
  width: 480px; /* 宽度固定，不随输入内容变化 */
  max-width: 100%;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.loc-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.loc-close {
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
}
.loc-search {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.loc-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
}
.loc-search input:focus {
  outline: none;
  border-color: var(--primary);
}
.loc-list {
  flex: 1;
  overflow-y: auto;
  min-height: 160px;
  -webkit-overflow-scrolling: touch;
}
.loc-item {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.loc-item:hover { background: var(--primary-light); }
.loc-item .pin { flex: none; }
.loc-item .loc-title { font-size: .92rem; }
.loc-item .loc-addr { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.loc-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
}
/* 手动输入兜底（搜索服务不可用时）*/
.loc-manual {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #fafaf8;
}
.loc-manual input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
}
.loc-manual input:focus {
  outline: none;
  border-color: var(--primary);
}
.loc-manual-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.loc-modal-foot {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.loc-modal-foot .btn { flex: 1; }

/* ===== Markdown 预览弹出框 ===== */
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1001;
  display: flex;
  align-items: center; /* 垂直居中（手机端底部弹出见 media query 覆盖） */
  justify-content: center;
  padding: 12px;
}
.preview-modal-card {
  background: #fff;
  border-radius: 12px;
  width: 720px;
  max-width: 100%;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
.preview-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.preview-close {
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
}
.preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
}
.preview-body .muted { margin-top: 0; }
.preview-body .script-output { margin: 10px 0 0; }
.preview-body pre { max-height: 46vh; overflow-y: auto; }
.preview-modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.preview-modal-foot .btn { flex: 1; max-width: 160px; }

/* ===== 元数据提示 ===== */
.meta-hint {
  font-size: .85rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 14px;
}
.warn-text { color: #e65100; font-size: .88rem; }

/* ===== 脚本输出 ===== */
.script-output {
  background: #1e1e1e;
  border-radius: 6px;
  padding: 14px;
  margin: 10px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.script-output pre {
  color: #d4d4d4;
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: .82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* ===== 底部 ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: .8rem;
}

/* ===== 工具 ===== */
.muted { color: var(--text-muted); }
code {
  background: #f0f0ec;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .85rem;
  word-break: break-all;
}

/* ===== 响应式：平板及以下 ===== */
@media (max-width: 768px) {
  .container { padding: 0 12px; }
  .card { padding: 18px; }
  .card h1 { font-size: 1.25rem; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .info-list { grid-template-columns: 1fr; gap: 2px; }

  /* iOS Safari：输入框字号 ≥16px，防止聚焦时自动放大页面
     （需与基础选择器同特异性，否则 datetime-local 规则优先）*/
  .form input[type="email"],
  .form input[type="password"],
  .form input[type="text"],
  .form input[type="date"],
  .form input[type="datetime-local"],
  .form input[type="file"],
  .form textarea,
  .loc-search input,
  .loc-manual input {
    font-size: 16px;
  }
  /* iOS Safari：datetime-local 原生控件不继承字号且 padding 被撑高，统一为普通文本框样式 */
  .form input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    height: 40px;
    padding: 0 12px;
  }

  /* 地点面板手机端：底部居中弹出（预览弹窗保持垂直居中，见基础规则）*/
  .loc-modal {
    align-items: flex-end;
    padding: 0;
  }
  .preview-modal {
    align-items: center; /* 手机端同样垂直居中 */
    padding: 12px;
  }
  .preview-modal-card {
    width: calc(100% - 32px);
    min-width: calc(100% - 32px);
    max-width: calc(100% - 32px);
    max-height: 75vh;
    border-radius: 14px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .loc-modal-card {
    width: calc(100% - 32px);
    min-width: calc(100% - 32px);
    max-width: calc(100% - 32px);
    max-height: 70vh;
    border-radius: 14px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .info-list dt { margin-top: 6px; }
}

/* ===== 响应式：手机 ===== */
@media (max-width: 480px) {
  html { font-size: 15px; }
  .container { padding: 0 10px; }
  .card { padding: 16px; border-radius: 6px; }
  .card-narrow { max-width: 100%; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
  .nav { width: 100%; justify-content: flex-start; }
  .nav a { padding: 6px 12px; font-size: .85rem; }
  .btn { padding: 10px 16px; font-size: .9rem; }
  .btn-sm { padding: 6px 10px; font-size: .78rem; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; text-align: center; }
  .main-content { padding-top: 16px; padding-bottom: 24px; }
  .meta-table, .user-table { font-size: .8rem; min-width: 400px; }
  .meta-table th, .meta-table td,
  .user-table th, .user-table td { padding: 6px 8px; }

  .banner { font-size: .84rem; }
}
