:root {
  --bg-dark: #0a0a0a;
  --panel-bg: #141414;
  --input-bg: #252525;
  --accent-gold: #e2c585;
  --accent-gold-hover: #f0d58f;
  --text-main: #ffffff;
  --text-gray: #888888;
  --border-color: #333333;

  --font-serif: "Songti SC", "SimSun", "Times New Roman", serif;
  --font-sans: "DengXian", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Consolas", "Monaco", monospace;
}

:root {
  --bg-page: #0a0a0a;
  --bg-card: #181818;
  --bg-input: #252525;
  --text-main: #ffffff;
  --text-sub: #666666;
  --accent-gold: #e0c38c;
  --radius-lg: 16px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 允许页面纵向滚动，避免内容被裁切 */
html,
body {
  width: 100%;
  min-height: 100%;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #111111;
}

::-webkit-scrollbar-thumb {
  background: #444444;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #666666;
}

/* --- 1. 顶部导航 --- */
header {
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  background: rgba(10, 10, 10, 0.9);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
}

.header-left .back-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 14px;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.header-center {
  text-align: center;
  margin-top: 15px;
  margin-bottom: 15px;
}

.logo-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #fff;
  margin-left: 160px;
}

.logo-subtitle {
  font-family: var(--font-sans);
  font-size: 10px;
  color: #fff;
  letter-spacing: 1px;
  margin-top: 2px;
  margin-left: 160px;
}

.header-right nav ul {
  display: flex;
  list-style: none;
  gap: 20px;
}

.nav-item {
  text-decoration: none;
  color: var(--text-gray);
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.nav-item.active {
  background-color: var(--accent-gold);
  color: #1a1a1a;
  font-weight: bold;
}

.nav-item:hover:not(.active) {
  color: #fff;
}

/* ================= Hero Section ================= */
.hero-section {
  text-align: center;
  padding: 60px 20px 40px;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.main-title {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--accent-gold);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.description {
  font-family: var(--font-sans);
  font-size: 16px;
  color: #fff;
  letter-spacing: 0.5px;
}

/* --- 3. 工作区布局 --- */
.workspace {
  flex: 1;
  display: flex;
  padding: 0 60px 40px 60px;
  gap: 40px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* 左侧画布容器 */
.preview-container {
  flex: 2;
  background: var(--panel-bg);
  border-radius: 12px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* 背景网格装饰 */
.grid-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

canvas {
  z-index: 1;
  max-width: 90%;
  max-height: 90%;
  image-rendering: pixelated;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* --- 右侧侧边栏 --- */
.sidebar {
  flex: 1;
  min-width: 320px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: center;
}

/* 通用卡片样式 */
.control-card {
  background-color: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid #222;
}

.control-card h3 {
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 5px;
  color: #eee;
}

.control-card .desc {
  font-size: 17px;
  color: var(--text-sub);
  margin-bottom: 15px;
}

/* 输入框样式 */
.input-wrapper input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid #333;
  color: #fff;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border 0.3s;
}

.input-wrapper input:focus {
  border-color: var(--text-sub);
}

/* 二进制展示框 */
.code-display {
  background-color: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--accent-gold);
  line-height: 1.6;
  height: 60px;
  overflow: hidden;
  word-break: break-all;
  opacity: 0.8;
}

/* 纹样按钮网格 */
.pattern-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.pat-btn {
  background-color: var(--bg-card);
  border: 1px solid #222;
  color: var(--accent-gold);
  padding: 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.pat-btn:hover {
  background-color: #222;
}

.pat-btn.active {
  background-color: #2a2a2a;
  border-color: #444;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5) inset;
  color: #fff;
}

/* 颜色滑块 */
.color-section h3 {
  font-size: 14px;
  margin-bottom: 15px;
  padding-left: 5px;
}

.slider-wrapper {
  padding: 0 5px;
}

input[type=range] {
  width: 100%;
  appearance: none;
  background: transparent;
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: #333;
  border-radius: 2px;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--accent-gold);
  margin-top: -6px;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(224, 195, 140, 0.4);
}

/* 底部按钮 */
.action-group {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn-main {
  flex: 1;
  background-color: var(--accent-gold);
  color: #000;
  border: none;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-main:hover {
  opacity: 0.9;
}

.btn-icon {
  width: 48px;
  background-color: var(--bg-card);
  border: 1px solid #333;
  color: #888;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: #fff;
  border-color: #555;
}

/* --- 响应式适配 --- */
@media (max-width: 768px) {
  body {
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  header {
    height: auto;
    flex-direction: column;
    padding: 15px 15px 10px 15px;
    gap: 15px;
    position: relative;
  }

  .header-left {
    position: absolute;
    left: 15px;
    top: 20px;
  }

  .header-center {
    margin: 0;
  }

  .logo-title,
  .logo-subtitle {
    margin-left: 0;
    text-align: center;
  }

  .header-right {
    width: 100%;
    overflow-x: auto;
  }

  .header-right nav ul {
    justify-content: center;
    gap: 8px;
  }

  .nav-item {
    font-size: 12px;
    padding: 6px 10px;
    white-space: nowrap;
  }

  .hero-section {
    padding: 30px 15px 20px;
  }

  .main-title {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .workspace {
    flex-direction: column;
    padding: 0 15px 40px 15px;
    gap: 20px;
  }

  .preview-container {
    width: 100%;
    height: 350px;
    flex: none;
  }

  canvas {
    max-width: 95%;
    max-height: 95%;
  }

  .sidebar {
    width: 100%;
    max-width: 100%;
    min-width: 100%;
    flex: none;
    gap: 15px;
  }

  .pattern-section {
    gap: 10px;
  }

  .pat-btn {
    padding: 12px;
  }
}