:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --success: #10b981;
  --success-hover: #059669;
  --accent: #f59e0b;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
}

.topbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
  }
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }

h2 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.help-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* 輸入框提示字 (較淺的灰色) */
::placeholder {
  color: #a1a1aa; /* 較淺的灰色 */
  opacity: 1; /* 修正 Firefox 預設的透明度 */
  transition: color 0.2s ease;
}

/* 點擊輸入框時，提示字立即消失 */
input:focus::placeholder,
textarea:focus::placeholder {
  color: transparent;
}

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.required { color: #ef4444; }

input[type="text"],
input[type="url"],
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
  font-family: inherit;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-success {
  background-color: var(--success);
  color: white;
}
.btn-success:hover:not(:disabled) { background-color: var(--success-hover); }

.btn-magic {
  background-color: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}
.btn-magic:hover:not(:disabled) { background-color: #e2e8f0; }

.btn-navy {
  background-color: #0f172a;
  color: white;
}
.btn-navy:hover:not(:disabled) { background-color: #1e293b; }

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background-color: #f0f9ff; }

.full-width { width: 100%; }

/* 預覽區樣式 */
.preview-section {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.preview-card {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  background-color: #e2e8f0;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.preview-content {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  flex: 1;
  min-height: 400px;
  overflow-y: auto;
  padding: 1rem;
}

.empty-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* 卡片預覽元件 */
.ch-item {
  margin-bottom: 1rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.ch-header {
  background-color: #f1f5f9;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.ch-title-input {
  border: none;
  background: transparent;
  font-weight: 700;
  color: var(--text-main);
  width: 100%;
  font-size: 0.875rem;
}

.unit-list {
  list-style: none;
}

.unit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.unit-item:last-child { border-bottom: none; }

.unit-title-input {
  border: none;
  background: transparent;
  width: 100%;
  font-size: 0.875rem;
  color: var(--text-main);
}

.unit-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.practice-toggle {
  font-size: 0.75rem;
  cursor: pointer;
  user-select: none;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.practice-toggle.active {
  background-color: #fef3c7;
  color: #b45309;
  border-color: #f59e0b;
}

.del-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.2rem;
}

.add-unit-btn {
  width: 100%;
  padding: 0.5rem;
  background: #f8fafc;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.add-unit-btn:hover { background: #f1f5f9; }

.btn-outline-danger {
  background: transparent;
  border: 1px solid #ef4444;
  color: #ef4444;
}
.btn-outline-danger:hover {
  background: #fef2f2;
}
