/* 온라인 글자수세기 — 슬레이트 그레이 팔레트 (#475569) · 쓰기 도구 뉴트럴 톤 */

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

:root {
  --brand:       #475569;
  --brand-dark:  #1E293B;
  --brand-light: #E2E8F0;
  --brand-alt:   #64748B;
  --bg:          #F8FAFC;
  --surface:     #FFFFFF;
  --surface2:    #FAFAFA;
  --border:      #E5E7EB;
  --text:        #1A1A1A;
  --text-muted:  #6B7280;
  --accent:      #0F766E;
  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 4px 20px rgba(0,0,0,.06);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.05);
  font-family: "Noto Sans KR", "Inter", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; font-size: 16px; line-height: 1.6; }
button { cursor: pointer; border: none; font-family: inherit; background: none; }
a { text-decoration: none; color: inherit; }
input, select, textarea { font-family: inherit; }

.layout-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; padding: 16px 12px 40px; }
  .app-sidebar { display: none; }
}
@media (max-width: 520px) {
  .hero-title { font-size: 22px !important; }
  .hero-desc { font-size: 13px !important; }
}

.ad-container { display: block; width: 100%; text-align: center; }
.top-ad { background: #f9f9f9; padding: 8px 0; border-bottom: 1px solid var(--border); }
.middle-ad { margin: 16px 0; }
.bottom-ad { margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

.main-header {
  background: linear-gradient(135deg, #1E293B 0%, #475569 55%, #64748B 100%);
  padding: 18px 16px 30px;
  position: relative; overflow: hidden;
}
.main-header::before { content:''; position:absolute; top:-40px; right:-40px; width:180px; height:180px; border-radius:50%; background: rgba(255,255,255,.08); }
.main-header::after { content:''; position:absolute; bottom:-30px; left:20px; width:110px; height:110px; border-radius:50%; background: rgba(255,255,255,.06); }

.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 1;
}
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-icon {
  font-size: 30px; background: rgba(255,255,255,.2); border-radius: 12px;
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
}
.header-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.header-logo h1 a { color: #fff; }
.header-logo p { font-size: 12px; color: rgba(255,255,255,.85); margin-top: 2px; }

.btn-share {
  font-size: 13px; color: #fff;
  padding: 8px 14px; border-radius: 20px;
  background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.4);
  font-weight: 600; position: relative; z-index: 1;
}
.btn-share:hover { background: rgba(255,255,255,.3); }

.header-hero { max-width: 1100px; margin: 18px auto 0; position: relative; z-index: 1; }
.hero-title { font-size: 24px; font-weight: 900; color: #fff; letter-spacing: -.5px; }
.hero-desc { font-size: 14px; color: rgba(255,255,255,.9); margin-top: 6px; line-height: 1.55; }

.app-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px;
}
.app-card h2 { font-size: 17px; font-weight: 800; padding: 16px 20px 8px; color: #1F2937; }
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; background: var(--brand-light);
}
.card-header-icon { font-size: 18px; }
.card-header-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 22px 20px; }

/* ================================================================
   글자수세기 전용 UI
================================================================ */

/* 목표 글자수 바 */
.goal-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.goal-row label { font-size: 13px; font-weight: 700; color: #374151; flex-shrink: 0; }
.goal-row input {
  flex: 1; min-width: 100px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface);
}
.goal-row input:focus { outline: none; border-color: var(--brand); }
.progress-text { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.progress-text strong { color: var(--brand-dark); font-weight: 800; font-size: 14px; }
.progress-bar-container { width: 100%; height: 8px; background: var(--brand-light); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--brand-alt), var(--brand)); border-radius: 99px; transition: width .3s ease; }
.progress-bar.success { background: linear-gradient(90deg, #10B981, #059669); }

/* 툴바 */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; gap: 8px; }
.btn-tool {
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 700; color: #374151; transition: all .15s;
}
.btn-tool:hover { border-color: var(--brand-alt); background: var(--brand-light); }
.btn-tool.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-tool.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

/* 텍스트 입력 */
.text-input {
  width: 100%; min-height: 260px; padding: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; line-height: 1.7; font-family: inherit; resize: vertical;
  background: var(--surface); color: var(--text);
}
.text-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(71,85,105,.1); }

/* 히스토리 칩 */
.history-quick-access { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.history-chip {
  padding: 6px 12px; border-radius: 99px;
  background: var(--brand-light); color: var(--brand-dark);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
  max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-chip:hover { background: var(--brand); color: #fff; }

/* 통계 그리드 (6 카드) */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-top: 16px;
}
@media (max-width: 520px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--brand-light); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 10px; text-align: center; transition: all .15s;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.stat-card h3 { font-size: 12px; font-weight: 700; color: var(--brand-dark); margin-bottom: 6px; }
.stat-card .stat-value {
  font-size: 22px; font-weight: 900; color: var(--brand-dark); letter-spacing: -.5px;
  font-family: "Inter", "Noto Sans KR", sans-serif;
}
.stat-card .stat-unit { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.stat-card.primary-stat { background: linear-gradient(135deg, #CBD5E1 0%, #E2E8F0 100%); border-color: var(--brand-alt); }
.stat-card.primary-stat .stat-value { color: var(--brand-dark); font-size: 26px; }
.stat-card.secondary-stat { background: #F1F5F9; }
.stat-card.tertiary-stat { background: #F8FAFC; }

/* 검색 영역 */
.search-wrapper {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 14px 16px; background: var(--brand-light); border-radius: var(--radius-sm);
  margin-top: 14px;
}
.search-wrapper label { font-size: 13px; font-weight: 700; color: var(--brand-dark); flex-shrink: 0; }
.search-wrapper input {
  flex: 1; min-width: 120px; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #fff;
}
.search-wrapper input:focus { outline: none; border-color: var(--brand); }
.search-result { font-size: 13px; color: #374151; flex-shrink: 0; }
.search-result strong { color: var(--accent); font-weight: 800; font-size: 15px; }

/* 정보 / 안내 카드 */
.info-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.info-card h2 { font-size: 17px; font-weight: 800; margin-bottom: 14px; color: #1F2937; }

.section-desc { font-size: 13px; color: var(--text-muted); margin: -4px 0 14px; padding: 0 20px; line-height: 1.6; }
.card-body .section-desc { padding: 0; }
.app-card > .section-desc, section.app-card > .section-desc { padding: 0 20px; }

/* FAQ */
.faq-item { border-bottom: 1px solid var(--border); padding: 12px 20px; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
  font-size: 14px; font-weight: 700; color: #1F2937;
  cursor: pointer; list-style: none; padding: 4px 0;
  position: relative; padding-right: 24px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; position: absolute; right: 4px; top: 4px;
  color: var(--brand); font-size: 18px; font-weight: 700;
  transition: transform .2s;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { font-size: 13px; color: #4B5563; line-height: 1.75; margin-top: 8px; padding-right: 20px; }
.faq-item strong { color: var(--brand-dark); }

/* 랜덤 예시 */
#random-examples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 20px; }
#random-examples::before { content: '🔥 자주 찾는 글자수 관련 키워드'; grid-column: 1 / -1; font-size: 15px; font-weight: 800; color: #1F2937; margin-bottom: 4px; }
@media (max-width: 520px) { #random-examples { grid-template-columns: 1fr; } }
.example-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: #FAFAFA; border: 1px solid var(--border);
  transition: all .15s;
}
.example-link:hover { background: var(--brand-light); border-color: var(--brand-alt); }
.ex-icon { font-size: 16px; flex-shrink: 0; }
.ex-text { flex: 1; min-width: 0; }
.ex-title { display: block; font-size: 13px; font-weight: 700; color: #1F2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-sub { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* 기준표 */
.table-scroll { margin: 0 20px 16px; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.bracket-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.bracket-table thead th { background: var(--brand-light); color: var(--brand-dark); font-weight: 800; padding: 10px 8px; text-align: center; border-bottom: 2px solid var(--brand); font-size: 12px; line-height: 1.4; }
.bracket-table tbody td { padding: 12px 10px; text-align: center; border-bottom: 1px solid var(--border); color: #374151; word-break: keep-all; }
.bracket-table tbody tr:last-child td { border-bottom: none; }
.bracket-table tbody tr:nth-child(even) { background: #F8FAFC; }
.bracket-table td.amt { font-weight: 800; color: var(--brand-dark); font-size: 14px; }
.bracket-table .muted { font-size: 11px; color: var(--text-muted); font-weight: 400; display: block; margin-top: 2px; }
.bracket-note { margin: 0 20px 20px; padding: 12px 14px; background: var(--brand-light); border-left: 4px solid var(--brand); border-radius: 8px; font-size: 12.5px; color: var(--brand-dark); line-height: 1.7; }

@media (max-width: 600px) {
  .table-scroll { border: none; background: transparent; }
  .bracket-table, .bracket-table tbody, .bracket-table tr, .bracket-table td { display: block; width: 100%; }
  .bracket-table thead { display: none; }
  .bracket-table tbody tr { background: #fff !important; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
  .bracket-table tbody tr:last-child { margin-bottom: 0; }
  .bracket-table tbody td { text-align: left; border: none; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
  .bracket-table tbody td:first-child { border-bottom: 1px dashed var(--border); padding-bottom: 8px; margin-bottom: 4px; }
  .bracket-table tbody td:not(:first-child)::before { content: attr(data-label); font-size: 11.5px; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
  .bracket-table tbody td.amt { color: var(--brand-dark); font-size: 14px; }
}

/* 시나리오 */
.scenario-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 20px 20px; }
.scenario-item { background: #F8FAFC; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.scenario-q { font-size: 13px; color: var(--brand-dark); margin-bottom: 6px; line-height: 1.5; word-break: keep-all; }
.scenario-a { font-size: 12.5px; color: #374151; line-height: 1.65; word-break: keep-all; }
@media (max-width: 720px) { .scenario-grid { grid-template-columns: 1fr; } }

/* 관련 링크 */
.related-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 20px 20px; }
.related-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--border); border-radius: 10px; transition: all .15s; min-width: 0; }
.related-link:hover { background: var(--brand-light); border-color: var(--brand); transform: translateY(-1px); }
.rel-emoji { font-size: 24px; flex-shrink: 0; }
.rel-body { flex: 1; min-width: 0; }
.rel-title { font-size: 13px; font-weight: 700; color: #1F2937; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rel-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { .related-grid { grid-template-columns: 1fr; } }

/* Sidebar */
.app-sidebar {
  position: sticky; top: 24px; max-height: calc(100vh - 48px);
  overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.app-sidebar::-webkit-scrollbar { display: none; }
.sidebar-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid var(--brand); color: var(--text); }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a { display: flex; align-items: flex-start; text-decoration: none; color: var(--text); padding: 7px 8px; border-radius: 8px; transition: background .15s; }
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { flex: 1; min-width: 0; }
.link-title { display: block; font-size: 13px; font-weight: 600; color: var(--brand-dark); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-footer {
  border-top: 1px solid var(--border); padding: 20px;
  text-align: center; font-size: 12px; color: var(--text-muted);
}

.share-toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1A1F36; color: #fff;
  padding: 12px 22px; border-radius: 99px;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  opacity: 0; transition: opacity .2s, transform .2s;
  z-index: 9999; box-shadow: 0 4px 20px rgba(0,0,0,.25); pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
