/* ─── 基础重置 ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e8eaed;
  --text: #1a1a2e;
  --text-secondary: #666;
  --primary: #0066cc;
  --primary-hover: #0052a3;
  --accent: #ff6b35;
  --success: #27ae60;
  --error: #e74c3c;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

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

/* ─── 顶部导航 ─── */
.navbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-size: 20px;
  color: var(--primary);
}

.brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
}

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

.navbar-right select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  outline: none;
}

.navbar-right select:focus {
  border-color: var(--primary);
}

.btn-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ─── 主工作区 ─── */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.editor-panel, .preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel {
  border-right: 1px solid var(--border);
}

.panel-header {
  height: 36px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.char-count {
  font-variant-numeric: tabular-nums;
}

.preview-status {
  color: var(--primary);
  font-size: 11px;
}

/* ─── 编辑器 ─── */
#editor {
  flex: 1;
  width: 100%;
  padding: 20px;
  border: none;
  outline: none;
  resize: none;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  tab-size: 2;
}

#editor::placeholder {
  color: #bbb;
}

/* ─── 预览面板 ─── */
.preview-panel {
  background: var(--bg);
  align-items: center;
}

.phone-frame {
  flex: 1;
  width: 375px;
  max-width: 100%;
  background: var(--surface);
  border-radius: 0;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow);
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.phone-notch {
  height: 4px;
  background: var(--bg);
}

.phone-header {
  padding: 14px 16px 6px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.phone-meta {
  padding: 0 16px 12px;
  font-size: 12px;
  color: #999;
}

.phone-body {
  min-height: 200px;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: #ccc;
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 16px;
  color: #ddd;
}

.empty-state p {
  font-size: 13px;
  line-height: 2;
}

/* ─── 底部操作栏 ─── */
.action-bar {
  height: 56px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.action-left {
  display: flex;
  gap: 16px;
}

.input-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.input-inline input {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  width: 140px;
  outline: none;
}

.input-inline input:focus {
  border-color: var(--primary);
}

.action-right {
  display: flex;
  gap: 10px;
}

/* ─── 按钮 ─── */
.btn {
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

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

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

.btn-primary:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

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

/* ─── 弹窗 ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 20px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  font-size: 20px;
  color: #999;
  cursor: pointer;
  border-radius: 50%;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 16px 24px;
}

.modal-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-field span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-field input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
}

.form-field input:focus {
  border-color: var(--primary);
}

.modal-footer {
  padding: 12px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.publish-error {
  padding: 10px 14px;
  background: #fff5f5;
  border: 1px solid #fdd;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--error);
  line-height: 1.5;
}

.publish-success {
  padding: 10px 14px;
  background: #f0fff4;
  border: 1px solid #c6f6d5;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--success);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  background: #333;
  color: white;
  border-radius: 20px;
  font-size: 13px;
  z-index: 2000;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── 响应式：小屏幕 ─── */
@media (max-width: 768px) {
  .workspace {
    flex-direction: column;
  }
  .editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: 40vh;
  }
  .preview-panel {
    height: 40vh;
  }
  .phone-frame {
    width: 100%;
    margin: 0;
    border-radius: 0;
    border: none;
  }
  .action-bar {
    flex-direction: column;
    height: auto;
    padding: 10px 16px;
    gap: 10px;
  }
  .action-left, .action-right {
    width: 100%;
  }
  .action-right {
    justify-content: stretch;
  }
  .action-right .btn {
    flex: 1;
  }
}
