:root {
  --card-bg: var(--surface);
  --card-border: var(--border);
  --card-shadow: var(--shadow);
}

.count-panel {
  max-width: 1200px;
  margin: 0 auto;
}

.calc-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 25px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}


.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-top: 20px;
  margin-bottom: 20px;
  border-top: 1px dashed var(--border);
}

.toolbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.input-area {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: transparent;
  border: none;
}

#source-text {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1.6;
  color: var(--text);
  resize: none;
  overflow: hidden;
  min-height: 180px;
  outline: none;
  font-family: inherit;
  text-align: center; /* Generally centering input text can look odd for long text, but cleaner for short. Let's keep specific alignment optional or default left. Reverting text-align center assumption. */
  text-align: left;
  border-radius: 0;
}

#source-text:focus {
  outline: none;
  box-shadow: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  padding: 20px;
  background: var(--surface-2);
  border-radius: 16px;
  border: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 4px;
  background: transparent;
  border-radius: 12px;
  transition: background-color 0.2s;
  text-align: center;
}

.stat-card:hover {
  background: var(--surface);
  transform: translateY(-2px);
}

.stat-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.8;
  white-space: nowrap;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* Make reading time value slightly smaller if needed */
#stat-reading {
  font-size: 1.3rem;
}

.recommend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

.recommend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.section-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.limit-list {
  display: flex;
  flex-direction: column;
  gap: 0; 
}

.limit-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}

.limit-item:last-child {
  border-bottom: none;
}

.limit-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: var(--surface);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.25rem;
  flex-shrink: 0;
  overflow: hidden;
}

.limit-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.limit-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.limit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.limit-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.limit-text {
  font-size: 0.85rem;
  font-family: var(--font-mono, monospace);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.limit-value {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
}


.progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

/* Add custom colors logic if JS doesn't handle it yet, 
   but usually JS sets style="background: ..." or class. 
   Assuming JS handles width. */

.limit-item.is-over .progress-bar {
  background: #ff6b6b; /* Red */
}
.limit-item.is-warn .progress-bar {
  background: #fcc419; /* Yellow */
}
.limit-item.is-good .progress-bar {
  background: #51cf66; /* Green */
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(106, 167, 255, 0.7), rgba(122, 245, 198, 0.7));
  width: 0%;
}


.status-text.is-error {
  color: #ff7a7a;
}

@media (max-width: 720px) {
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  /* ✨ Fix recommend-grid overflow on mobile */
  .recommend-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .limit-list {
    overflow-x: auto;
  }
}

/* Social Icons Dark Mode Support */
.social-icon-x { content: url('../img/social/x_w.svg'); }
.social-icon-tiktok { content: url('../img/social/tiktok_w.svg'); }
.social-icon-threads { content: url('../img/social/threads_w.svg'); }

html[data-theme='light'] .social-icon-x { content: url('../img/social/x.svg'); }
html[data-theme='light'] .social-icon-tiktok { content: url('../img/social/tiktok.svg'); }
html[data-theme='light'] .social-icon-threads { content: url('../img/social/threads.svg'); }
