*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #1e293b;
  background: linear-gradient(160deg, #f0f4ff 0%, #e8eeff 50%, #f5f7ff 100%);
  min-height: 100vh;
}

.wrap {
  max-width: 1680px;
  margin: 0 auto;
  padding: 24px;
}

/* ========== Header ========== */
.header {
  margin-bottom: 24px;
  padding: 20px 28px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(30, 41, 59, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 500;
  color: #6366f1;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.logo h1 {
  margin: 0 0 4px 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: #1e293b;
  letter-spacing: -0.02em;
}

.header .desc {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-icon {
  font-size: 12px;
  opacity: 0.9;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  background: linear-gradient(135deg, #5558e3 0%, #4338ca 100%);
}

.btn-ghost {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.btn-ghost:hover {
  background: #e2e8f0;
  color: #334155;
}

/* ========== Editor Row ========== */
.editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-height: 520px;
}

@media (max-width: 960px) {
  .editor-row {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

/* ========== Panels ========== */
.panel {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 24px rgba(30, 41, 59, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.editor-panel {
  min-height: 480px;
}

/* ========== Tabs ========== */
.panel-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 14px 0;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.panel-tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: #64748b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.panel-tabs .tab:hover {
  background: #f1f5f9;
  color: #475569;
}

.panel-tabs .tab.active {
  background: #fff;
  color: #1e293b;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid #e2e8f0;
  border-bottom-color: #fff;
  margin-bottom: -1px;
}

.tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tab-dot.html { background: #e34c26; }
.tab-dot.css { background: #264de4; }
.tab-dot.js { background: #f7df1e; }

/* ========== Code Area ========== */
.panel-content {
  flex: 1;
  position: relative;
  min-height: 340px;
  padding: 16px;
  background: #fff;
}

.code-block {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px;
}

.code-block.active {
  display: block;
}

.code-input {
  width: 100%;
  height: 100%;
  min-height: 300px;
  padding: 16px;
  font-family: "JetBrains Mono", "Consolas", "Monaco", monospace;
  font-size: 13px;
  line-height: 1.65;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.code-input::placeholder {
  color: #94a3b8;
}

.code-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ========== Preview Panel ========== */
.preview-panel {
  min-height: 480px;
}

.panel-head {
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.panel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.panel-icon {
  font-size: 14px;
  color: #6366f1;
  animation: spin 4s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.preview-frame {
  flex: 1;
  width: 100%;
  min-height: 380px;
  border: none;
  background: #fff;
  display: block;
}

/* ========== 工具说明 ========== */
.tool-intro {
  margin-top: 24px;
  padding: 24px 28px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(30, 41, 59, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.tool-intro-title {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e293b;
}

.tool-intro-body {
  font-size: 14px;
  color: #475569;
  line-height: 1.7;
}

.tool-intro-body p {
  margin: 0 0 12px 0;
}

.tool-intro-body p:last-of-type {
  margin-bottom: 0;
}

.tool-intro-body ul {
  margin: 0 0 12px 0;
  padding-left: 1.4em;
}

.tool-intro-body li {
  margin-bottom: 6px;
}

.tool-intro-body code {
  padding: 2px 6px;
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 12px;
  background: #f1f5f9;
  border-radius: 6px;
  color: #475569;
}

/* ========== 相关工具 ========== */
.related-tools {
  margin-top: 24px;
  padding: 24px 28px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(30, 41, 59, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.related-tools-title {
  margin: 0 0 20px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e293b;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.related-tool-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #334155;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.related-tool-card:hover {
  background: #f1f5f9;
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
}

.related-tool-icon {
  font-size: 20px;
  color: #6366f1;
  line-height: 1;
}

.related-tool-name {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}

.related-tool-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

/* ========== 运行提示 Toast ========== */
.run-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 14px;
  font-weight: 500;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.run-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
