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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #f0f7ff, #e3f2fd);;
  color: #333;
  line-height: 1.6;
  /* ✅ 关键：允许 body 高度随内容增长 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  padding: 0 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 顶部标题 */
.header {
  text-align: center;
  margin-bottom: 6px;
  padding: 20px;
}

.header h1 {
  font-size: 2.2rem;
  color: #3498db;
  margin-bottom: 8px;
}

.header p {
  font-size: 1rem;
  color: #95a5a6;
}

/* ✅ 核心布局：grid 两列，每列内部 flex 纵向撑满 */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0; /* ✅ 允许子元素收缩 */
}

.panel {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0; /* ✅ 防止 flex 子项溢出 */
}

.panel-header {
  background-color: #3498db;
  color: white;
  padding: 16px 20px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0; /* ✅ 不可收缩 */
}

.panel-title {
  font-size: 1.2rem;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn:hover {
  background: rgba(255,255,255,0.3);
}

.btn.danger {
  background: rgba(231, 76, 60, 0.8);
}

.btn.danger:hover {
  background: rgba(231, 76, 60, 1);
}

.panel-body {
  padding: 16px;
  flex: 1; /* ✅ 关键：撑满剩余空间 */
  display: flex;
  flex-direction: column;
  min-height: 0; /* ✅ 允许内部元素收缩 */
}

/* ✅ 左侧输入区域：flex 布局，error-message 固定高度，textarea 撑满余下 */
.input-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.error-message {
  color: #e74c3c;
  background-color: #fdf2f2;
  border: 1px solid #e74c3c;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.error-message::before {
  content: "⚠️";
  font-size: 1.2em;
}

/* ✅ 核心：textarea 撑满 input-area 剩余所有空间 */
#json-input {
  width: 100%;
  flex: 1; /* ✅ 占满剩余空间 */
  min-height: 0; /* ✅ 允许收缩（解决 flex 嵌套高度问题） */
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  resize: vertical;
  background-color: #fafafa;
  transition: border-color 0.2s;
}

#json-input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#json-input.error {
  border-color: #e74c3c;
  background-color: #fef8f8;
}

/* 右侧表格区域 */
.table-container {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

th {
  background-color: #f1f8ff;
  font-weight: 600;
  color: #2c3e50;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:hover td {
  background-color: #f8fbff;
}

.empty-state {
  text-align: center;
  color: #95a5a6;
  padding: 40px 20px;
}

.logo {
  font-size: 2.2rem;
  font-weight: 500;
  color: #3498db;
  margin-bottom: 0.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}

.home-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /*height: 24px;*/
  min-width: 28px;
  padding: 2px 8px;
  margin-top: -18px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #3498db;
  background: #d6eaf8;
  border-radius: 14px;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  user-select: none;
}

.home-badge:hover {
  background: #3498db;
  color: white;
}

.home-badge:focus {
  outline: 2px solid rgba(52, 152, 219, 0.4);
  outline-offset: 2px;
}

footer {
  text-align: center;
  margin-top: 20px;
  margin-bottom: 10px;
  color: #666;
  font-size: 0.9rem;
}

footer a,
footer a:visited,
footer a:hover,
footer a:active {
  color: #666;
  text-decoration: none;
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .header h1 {
    font-size: 2rem;
  }
}