/* Blog Portal — 浅色 iOS 风格（对齐原站后台截图）
   白底 + 白色圆角卡片 + 深色文字 + 蓝色强调 + 红色删除 */
:root {
  --p-bg: #f5f5f7;
  --p-card: #ffffff;
  --p-text: #1c1c1e;
  --p-text-2: #6e6e73;
  --p-text-3: #aeaeb2;
  --p-accent: #0a84ff;
  --p-danger: #ff3b30;
  --p-border: #e5e5ea;
  --p-btn-bg: #f2f2f7;
  --p-radius: 12px;
}

/* 关键：确保 hidden 属性始终生效（防止 .img-picker/.portal-tabs 等 display 规则覆盖） */
[hidden] { display: none !important; }


.portal-body {
  background: var(--p-bg);
  color: var(--p-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.portal-shell { max-width: 560px; margin: 0 auto; padding: 0 16px 48px; }

/* Portal 页顶部留白收紧（覆盖主题 .container 的 40px） */
body.page-portal .container { padding-top: 10px; }

/* --- 顶部：标题 + Sign Out 蓝色链接 --- */
.portal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px 8px;
}
.portal-title { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; color: var(--p-text); }
.portal-header-actions { display: flex; align-items: center; gap: 10px; }
.portal-account { font-size: 13px; color: var(--p-text-2); }
#portal-signout {
  background: none; border: 0; padding: 4px 6px;
  color: var(--p-accent); font-size: 15px; cursor: pointer;
}
#portal-signout:hover { text-decoration: underline; }

/* --- Tab：文字 + 当前项黑色下划线 --- */
.portal-tabs {
  display: flex; gap: 0; padding: 0 4px;
  border-bottom: 1px solid var(--p-border);
  margin-bottom: 18px;
}
.portal-tab {
  flex: 0 1 auto; padding: 9px 14px;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--p-text-2); font-size: 15px; cursor: pointer;
  margin-bottom: -1px; transition: color .15s;
}
.portal-tab:hover { color: var(--p-text); }
.portal-tab.is-active { color: var(--p-text); font-weight: 600; border-bottom-color: var(--p-text); }

/* --- 卡片 --- */
.portal-card {
  background: var(--p-card); border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  padding: 18px 16px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.portal-card-title { font-size: 17px; font-weight: 600; margin-bottom: 14px; color: var(--p-text); }

/* --- 表单 --- */
.portal-field { display: block; margin-bottom: 16px; }
.portal-field span { display: block; font-size: 12px; color: var(--p-text-2); margin-bottom: 5px; font-weight: 500; }
.portal-field input,
.portal-field select,
.portal-field textarea {
  width: 100%; padding: 10px 12px;
  background: var(--p-bg); color: var(--p-text);
  border: 1px solid var(--p-border); border-radius: 10px;
  font-size: 15px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.portal-field textarea { resize: vertical; line-height: 1.6; }
.portal-field input:focus, .portal-field textarea:focus, .portal-field select:focus { border-color: var(--p-accent); }

.portal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .portal-grid { grid-template-columns: 1fr; } }

.portal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* --- 按钮 --- */
.portal-btn {
  padding: 8px 16px; border-radius: 9px; border: 1px solid var(--p-border);
  background: var(--p-btn-bg); color: var(--p-text); font-size: 14px; cursor: pointer;
  transition: opacity .15s;
}
.portal-btn:hover { opacity: 0.85; }
.portal-btn-primary { background: var(--p-accent); border-color: var(--p-accent); color: #fff; font-weight: 500; }
.portal-btn-outline { background: transparent; border-color: var(--p-accent); color: var(--p-accent); font-weight: 500; }
.portal-btn-danger-text { background: transparent; border: 0; color: var(--p-danger); padding: 4px 6px; font-size: 13px; }
.portal-btn:disabled { opacity: 0.45; cursor: default; }

.portal-hint { font-size: 13px; color: var(--p-text-2); margin: 0 0 12px; line-height: 1.5; }

.portal-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.portal-toolbar .portal-hint { margin: 0; }

/* --- Posts 卡片 --- */
.post-item {
  background: var(--p-card); border: 1px solid var(--p-border); border-radius: var(--p-radius);
  padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.post-item-title { font-size: 16px; font-weight: 600; color: var(--p-text); }
.post-item-meta {
  font-size: 11px; color: var(--p-text-2); margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.post-item-meta .post-item-type { color: var(--p-text-3); }
.post-item-meta .post-item-status { color: var(--p-text-3); }
.post-item-actions { display: flex; gap: 8px; margin-top: 12px; }
.post-item-actions .portal-btn { flex: 1; padding: 7px 10px; font-size: 13px; border-radius: 999px; }

/* --- Images 网格（2 列） --- */
.images-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
.img-cell { background: var(--p-card); border: 1px solid var(--p-border); border-radius: 10px; overflow: hidden; }
.img-cell img { width: 100%; height: 110px; object-fit: cover; display: block; background: var(--p-bg); }
.img-cell-name {
  font-size: 11px; color: var(--p-text-2); padding: 6px 8px 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-cell-actions { display: flex; gap: 2px; padding: 0 8px 8px; }
.img-cell-actions .portal-btn { background: none; border: 0; padding: 4px 6px; font-size: 12px; }
.img-cell-actions [data-act="copymd"] { color: var(--p-accent); }
.img-cell-actions [data-act="delimg"] { color: var(--p-danger); }

/* --- Status --- */
.portal-stat-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--p-border); gap: 10px; }
.portal-stat-row:last-of-type { border-bottom: 0; }
.portal-stat-label { font-size: 13px; color: var(--p-text-2); flex-shrink: 0; }
.portal-stat-value { font-size: 13px; font-weight: 500; text-align: right; word-break: break-all; }
.portal-commit {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; font-weight: 400; max-width: 70%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.portal-stat-sub { font-size: 12px; color: var(--p-text-3); text-align: right; margin-top: 2px; }
.portal-ok { color: #34c759; }

/* --- Toast --- */
.portal-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100;
  max-width: 90vw; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.portal-toast.is-error { background: rgba(255, 59, 48, 0.95); }

.portal-progress { margin-top: 10px; font-size: 13px; color: var(--p-text-2); }

/* --- 上传行（Browse + 文件名 + Upload） --- */
.upload-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.upload-row .upload-file-name { flex: 1; font-size: 13px; color: var(--p-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ========== Posts 搜索 ========== */
.portal-search {
  flex: 1; padding: 9px 12px;
  background: var(--p-bg); color: var(--p-text);
  border: 1px solid var(--p-border); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none;
}
.portal-search:focus { border-color: var(--p-accent); }

/* ========== 双栏编辑器 ========== */
/* 编辑页放宽容器（仅 Edit 页签时 body 加 .is-editing 类切换） */
.portal-shell.is-editing { max-width: 960px; }

.editor-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.editor-toolbar-spacer { flex: 1; }
.editor-status { font-size: 13px; color: var(--p-text-2); }

/* 默认单栏（防拥挤）；容器 ≥900px 时才双栏（容器查询，与视口无关） */
.portal-shell { container-type: inline-size; }
.editor-split {
  display: grid; grid-template-columns: 1fr; gap: 14px;
  align-items: start;
}
@container (min-width: 900px) {
  .editor-split { grid-template-columns: 1fr 1fr; }
}

.editor-left { min-width: 0; }
.editor-body-field textarea { min-height: 320px; }

.editor-right {
  position: sticky; top: 12px;
  background: var(--p-card); border: 1px solid var(--p-border);
  border-radius: var(--p-radius); padding: 16px 18px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* 预览排版 */
.editor-preview { font-size: 15px; line-height: 1.7; color: var(--p-text); word-break: break-word; }
.editor-preview h1, .editor-preview h2, .editor-preview h3, .editor-preview h4 {
  font-weight: 700; line-height: 1.3; margin: 1.2em 0 0.5em;
}
.editor-preview h1 { font-size: 24px; }
.editor-preview h2 { font-size: 20px; }
.editor-preview h3 { font-size: 17px; }
.editor-preview h4 { font-size: 15px; }
.editor-preview p { margin: 0.7em 0; }
.editor-preview a { color: var(--p-accent); text-decoration: underline; }
.editor-preview img { max-width: 100%; border-radius: 8px; margin: 0.6em 0; }
.editor-preview pre {
  background: var(--p-bg); border: 1px solid var(--p-border);
  border-radius: 8px; padding: 12px; overflow-x: auto; margin: 0.8em 0;
}
.editor-preview code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; background: var(--p-bg); padding: 2px 5px; border-radius: 4px;
}
.editor-preview pre code { background: none; padding: 0; }
.editor-preview blockquote {
  border-left: 3px solid var(--p-accent); margin: 0.8em 0;
  padding: 4px 14px; color: var(--p-text-2); background: var(--p-bg);
  border-radius: 0 8px 8px 0;
}
.editor-preview ul, .editor-preview ol { margin: 0.7em 0; padding-left: 1.6em; }
.editor-preview li { margin: 0.25em 0; }
.editor-preview hr { border: 0; border-top: 1px solid var(--p-border); margin: 1.2em 0; }
.editor-preview table { border-collapse: collapse; margin: 0.8em 0; width: 100%; }
.editor-preview th, .editor-preview td { border: 1px solid var(--p-border); padding: 6px 10px; }
.editor-preview th { background: var(--p-bg); }
.editor-preview del { color: var(--p-text-3); }

/* ========== 图片选择面板 ========== */
.img-picker {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(760px, 92vw); max-height: 80vh;
  background: var(--p-card); border: 1px solid var(--p-border);
  border-radius: 14px; z-index: 120; display: flex; flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.img-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--p-border);
  font-size: 15px; font-weight: 600;
}
.img-picker-close { background: none; border: 0; font-size: 16px; cursor: pointer; color: var(--p-text-2); }
.img-picker-body { padding: 14px 16px; overflow-y: auto; }
.picker-hint { font-size: 13px; color: var(--p-text-2); margin: 12px 0 8px; }
.picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .picker-grid { grid-template-columns: repeat(3, 1fr); } }
.picker-item { cursor: pointer; border: 2px solid transparent; border-radius: 8px; overflow: hidden; transition: border-color .15s; }
.picker-item:hover { border-color: var(--p-accent); }
.picker-item img { width: 100%; height: 80px; object-fit: cover; display: block; background: var(--p-bg); }
.picker-item-name { font-size: 10px; color: var(--p-text-2); padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.img-picker-scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 110;
}

/* ========== 图片库总数 ========== */
.img-total { font-size: 13px; color: var(--p-text-2); font-weight: 400; }
/* Status 页手机端：标签在上、内容在下，长内容可换行（不再挤压截断） */
@media (max-width: 560px) {
  .portal-stat-row { display: block; padding: 9px 0; }
  .portal-stat-value { display: block; margin-top: 3px; text-align: left; }
  .portal-commit { max-width: 100%; white-space: normal; }
}
