@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ─── 変数 ─────────────────────────────────────── */
:root {
  --gold:       #C9A84C;
  --gold-light: #E8C96A;
  --gold-dim:   #8A6E2A;
  --gold-bg:    #fdf8ee;

  --black:      #111111;
  --black2:     #1A1A1A;
  --text:       #111111;
  --text-mid:   #555555;
  --text-dim:   #999999;

  --bg:         #FFFFFF;
  --bg2:        #F7F7F7;
  --bg3:        #F2F2F2;
  --border:     #E8E8E8;
  --border-mid: #D4D4D4;

  --red:        #CC3333;

  --font:  'Noto Sans JP', -apple-system, sans-serif;
  --mono:  'JetBrains Mono', 'Fira Code', monospace;
  --r:     4px;
}

/* ─── リセット ──────────────────────────────────── */
.htb-app *, .htb-app *::before, .htb-app *::after {
  box-sizing: border-box;
}

/* ─── アプリ全体 ────────────────────────────────── */
.htb-app {
  font-family: var(--font);
  background: var(--bg);
  padding: 24px 24px 40px;
  max-width: 1440px;
  margin: 0 auto;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── ヘッダーバー ──────────────────────────────── */
.htb-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ブランド */
.htb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.htb-brand-mark {
  width: 34px;
  height: 34px;
  background: var(--black);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: -.2px;
  border-radius: var(--r);
  flex-shrink: 0;
}
.htb-brand-name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--black);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.htb-brand-name em {
  color: var(--gold-dim);
  font-style: normal;
  font-weight: 400;
  margin: 0 2px;
}

/* モード切替 */
#htbModeArea {
  align-items: center;
  gap: 0;
}
/* JSがdisplay:flexをセット → flex-directionはrowをデフォルトに */

.htb-mode-btn {
  padding: 8px 16px;
  border: 1px solid var(--border-mid);
  background: var(--bg2);
  color: var(--text-mid);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
  border-radius: 0;
}
.htb-mode-btn:first-child {
  border-radius: var(--r) 0 0 var(--r);
}
.htb-mode-btn:last-child {
  border-radius: 0 var(--r) var(--r) 0;
  border-left: none;
}
.htb-mode-btn:hover {
  color: var(--black);
  background: var(--bg3);
}
.htb-mode-btn.active {
  background: var(--black);
  color: var(--gold);
  border-color: var(--black);
}
.htb-mode-sub {
  font-size: 9px;
  font-weight: 400;
  opacity: .65;
  letter-spacing: .03em;
}

/* クリアボタン */
.htb-btn-clear {
  margin-left: auto;
  padding: 7px 14px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all .15s;
}
.htb-btn-clear:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ─── ボディレイアウト ───────────────────────────── */
.htb-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* ─── 左カラム ──────────────────────────────────── */
.htb-left {
  width: 280px;
  min-width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─── カード共通 ────────────────────────────────── */
.htb-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  position: relative;
  overflow: hidden;
}
/* ゴールドのトップライン */
.htb-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gold);
}

.htb-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg2);
}

.htb-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-dim);
  flex-shrink: 0;
}

.htb-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.htb-card-body--code {
  padding: 0;
}

/* ─── 入力テキストエリア ─────────────────────────── */
#htbInput {
  width: 100%;
  min-height: 180px;
  padding: 12px 13px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.75;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg2);
  resize: vertical;
  color: var(--black);
  outline: none;
  transition: border-color .15s;
}
#htbInput:focus { border-color: var(--gold); }
#htbInput::placeholder { color: var(--text-dim); font-size: 11px; }

/* 解析ボタン */
.htb-btn-parse {
  width: 100%;
  padding: 12px 16px;
  background: var(--black);
  color: var(--gold);
  border: none;
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all .2s;
}
.htb-btn-parse:hover {
  background: var(--gold);
  color: var(--black);
}
.htb-btn-parse:active { opacity: .85; }
.htb-parse-arrow {
  font-size: 17px;
  line-height: 1;
}

/* ─── セクション＋パターンカード ────────────────── */
/* JSがdisplay:flexをセットする */
#htbSectionArea { flex-direction: column; }

.htb-nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
.htb-nav-list::-webkit-scrollbar { width: 3px; }
.htb-nav-list::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 2px;
}
.htb-nav-list--sm { max-height: 150px; }

.htb-nav-sep {
  padding-top: 14px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  margin-bottom: 6px;
}

/* 段落ボタン（JS生成: .htb-sec-btn） */
.htb-sec-btn {
  width: 100%;
  padding: 9px 12px 9px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text-mid);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: all .12s;
}
.htb-sec-btn:hover {
  border-left-color: var(--gold);
  color: var(--black);
  background: var(--gold-bg);
}
.htb-sec-btn.active {
  border-left-color: var(--black);
  border-color: var(--border);
  border-left-color: var(--black);
  color: var(--black);
  background: var(--bg2);
  font-weight: 700;
}

/* パターンボタン（JS生成: .htb-pat-btn） */
.htb-pat-btn {
  width: 100%;
  padding: 8px 12px 8px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text-mid);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: all .12s;
}
.htb-pat-btn:hover {
  border-left-color: var(--gold);
  color: var(--black);
  background: var(--gold-bg);
}
.htb-pat-btn.active {
  border-left-color: var(--gold);
  border-color: var(--border);
  border-left-color: var(--gold);
  color: var(--gold-dim);
  background: var(--gold-bg);
  font-weight: 700;
}

/* ─── 右エリア ──────────────────────────────────── */
.htb-right-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* 上段：CSS + コード横並び */
.htb-top-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.htb-css-box  { width: 250px; min-width: 200px; flex-shrink: 0; }
.htb-code-box { flex: 1; min-width: 0; }

/* コピーボタン共通 */
.htb-btn-copy {
  margin-left: auto;
  padding: 4px 12px;
  background: transparent;
  color: var(--gold-dim);
  border: 1px solid var(--gold);
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.htb-btn-copy:hover {
  background: var(--gold);
  color: var(--black);
}
.htb-btn-copy--dark {
  background: var(--black);
  color: var(--gold);
  border-color: var(--black);
  margin-left: 6px;
}
.htb-btn-copy--dark:hover {
  background: var(--gold-dim);
  border-color: var(--gold-dim);
  color: var(--bg);
}

/* リアルタイムバッジ */
.htb-realtime-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: .1em;
  flex-shrink: 0;
}

/* セクションタブ（JS生成: .htb-output-tab） */
.htb-output-tabs {
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
/* JSがdisplay:flexをセット */

.htb-output-tab {
  padding: 3px 11px;
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.htb-output-tab:hover {
  border-color: var(--gold);
  color: var(--gold-dim);
}
.htb-output-tab.active {
  background: var(--black);
  color: var(--gold);
  border-color: var(--black);
}

/* 出力テキストエリア */
#htbOutput,
#htbCSSOutput {
  width: 100%;
  padding: 13px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.85;
  border: none;
  outline: none;
  resize: vertical;
  color: var(--black);
  display: block;
}
#htbOutput    { min-height: 220px; background: var(--bg2); }
#htbCSSOutput { min-height: 180px; background: #F8FFF6; }
#htbOutput::placeholder,
#htbCSSOutput::placeholder { color: var(--text-dim); font-size: 11px; }

/* プレビュー */
.htb-preview-vp {
  height: 500px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #FFFFFF;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
.htb-preview-vp::-webkit-scrollbar { width: 4px; }
.htb-preview-vp::-webkit-scrollbar-thumb { background: var(--border-mid); }

.htb-preview-content {
  box-sizing: border-box;
  transition: max-width .25s;
}
.htb-device-desktop { max-width: 100%; }
.htb-device-tablet  {
  max-width: 768px;
  margin: 0 auto;
  border-left: 1px dashed var(--border);
  border-right: 1px dashed var(--border);
}
.htb-device-mobile  {
  max-width: 375px;
  margin: 0 auto;
  border-left: 1px dashed var(--border);
  border-right: 1px dashed var(--border);
}
.htb-preview-empty {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 200px 20px 20px;
}

/* デバイスボタン */
.htb-device-group {
  display: flex;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.htb-dev-btn {
  padding: 5px 12px;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-mid);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all .12s;
}
.htb-dev-btn:last-child { border-right: none; }
.htb-dev-btn:hover { color: var(--black); background: var(--bg2); }
.htb-dev-btn.active {
  background: var(--black);
  color: var(--gold);
}

/* プレビュー内コンテンツ */
.htb-preview-content h1,
.htb-preview-content h2,
.htb-preview-content h3 { margin: 10px 0 6px; line-height: 1.4; }
.htb-preview-content p   { font-size: 13px; line-height: 1.8; margin: 6px 0; }
.htb-preview-content img { max-width: 100%; height: auto; display: block; margin: 8px auto; }

/* ─── レスポンシブ ───────────────────────────────── */
@media (max-width: 960px) {
  .htb-body     { flex-wrap: wrap; }
  .htb-left     { width: 100%; min-width: 0; }
  .htb-top-row  { flex-wrap: wrap; }
  .htb-css-box  { width: 100%; }
}
