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

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --text: #1e293b;
  --text-sub: #64748b;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;
  --radius: 10px;

  --x-color: #000000;
  --ig-color: #e1306c;
  --note-color: #41b883;
  --fb-color: #1877f2;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 20px 16px 48px;
}

header {
  text-align: center;
  margin-bottom: 28px;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
}

header p {
  color: var(--text-sub);
  margin-top: 4px;
  font-size: 0.9rem;
}

main {
  max-width: 760px;
  margin: 0 auto;
}

/* テキストエリア */
.input-section {
  margin-bottom: 20px;
}

.textarea-wrapper {
  position: relative;
}

textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  background: var(--surface);
  color: var(--text);
}

textarea:focus {
  border-color: var(--primary);
}

.btn-clear {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-sub);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-clear:hover {
  background: #e2e8f0;
  color: var(--text);
}

/* カード */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-sub);
  margin-bottom: 16px;
}

/* 文字数グリッド */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

/* SNSリスト */
.sns-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sns-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sns-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sns-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.sns-icon-x    { background: var(--x-color); }
.sns-icon-ig   { background: var(--ig-color); }
.sns-icon-note { background: var(--note-color); }
.sns-icon-fb   { background: var(--fb-color); }

.sns-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.sns-limit {
  font-size: 0.78rem;
  color: var(--text-sub);
  margin-left: auto;
}

.sns-meter-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sns-meter {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.sns-meter-bar {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  background: var(--success);
  transition: width 0.2s ease, background 0.2s ease;
}

.sns-meter-bar.warn { background: var(--warning); }
.sns-meter-bar.over { background: var(--error); }

.sns-status {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 80px;
  text-align: right;
  color: var(--text-sub);
}

.sns-status.ok   { color: var(--success); }
.sns-status.over { color: var(--error); }

/* 読みやすさ */
.readability-content {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.score-badge {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  text-align: center;
  transition: background 0.3s;
}

.score-badge.good   { background: #d1fae5; color: var(--success); }
.score-badge.normal { background: #fef3c7; color: var(--warning); }
.score-badge.hard   { background: #fee2e2; color: var(--error); }

.readability-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* モバイル対応 */
@media (max-width: 560px) {
  header h1 { font-size: 1.4rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.2rem; }
  .card { padding: 16px; }
  .readability-content { flex-direction: column; align-items: center; }
  .sns-limit { display: none; }
}
