:root {
  --bg:         #0f0f0f;
  --bg2:        #1a1a1a;
  --bg3:        #141414;
  --border:     rgba(0, 212, 255, 0.2);
  --accent:     #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.1);
  --accent-dark:#00a8cc;
  --accent-glow:rgba(0, 212, 255, 0.4);
  --text:       #e0e0e0;
  --text-dim:   #888;
  --red:        #f85149;
  --font-sans:  'Inter', 'Noto Sans JP', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  --radius:     6px;
}

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

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== LOGIN ===== */
#login-view {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 0 40px rgba(0,212,255,0.05);
}

.login-title {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 4px;
  text-shadow: 0 0 20px var(--accent-glow);
}

.login-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 28px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  margin-top: 8px;
  letter-spacing: 0.05em;
}

.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 0 16px var(--accent-glow);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error-msg {
  color: var(--red);
  font-size: 12px;
  margin-top: 12px;
  text-align: center;
  min-height: 18px;
}

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  gap: 0;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 max(24px, calc((100% - 840px) / 2));
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.04em;
}

.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== TAB PANES ===== */
.tab-pane {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.tab-pane.active { display: flex; }

/* ===== FILE PICKER ===== */
.file-picker {
  padding: 14px max(24px, calc((100% - 840px) / 2));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.file-picker-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.file-picker-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}

.file-btn:hover  { border-color: var(--accent); background: var(--accent-dim); }
.file-btn.active { border-color: var(--accent); background: var(--accent-dim); }

.file-btn-label {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
}

.file-btn-desc {
  font-size: 10px;
  color: var(--text-dim);
}

/* ===== CONTENT CARD (現在の内容) ===== */
.content-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-self: flex-start;
  width: 100%;
  overflow: hidden;
}

.content-card-header {
  padding: 8px 16px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

.content-card-body {
  padding: 14px 16px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
  line-height: 1.6;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.content-card-body::-webkit-scrollbar { width: 4px; }
.content-card-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.site-system-msg {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  padding: 4px 0;
  align-self: flex-start;
}

/* ===== MAIN VIEW ===== */
#main-view {
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100vh;
}

body.logged-in {
  align-items: stretch;
  justify-content: flex-start;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(24px, calc((100% - 840px) / 2));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-shadow: 0 0 12px var(--accent-glow);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-user {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-logout:hover { border-color: var(--accent); color: var(--accent); }

.btn-clear {
  background: none;
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-clear:hover { border-color: var(--red); color: var(--red); }

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px max(24px, calc((100% - 840px) / 2));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 75%;
}

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.ai   { align-self: flex-start; align-items: flex-start; }

.msg-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.6;
  font-size: 14px;
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: #000;
  font-weight: 500;
  border-bottom-right-radius: 2px;
}

.msg.ai .msg-bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.msg-typing {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.3em;
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

/* ===== PREVIEW CARD ===== */
.preview-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  align-self: flex-start;
  box-shadow: 0 0 20px rgba(0,212,255,0.05);
}

.preview-header {
  padding: 9px 16px;
  background: var(--accent-dim);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.1em;
}

.preview-title-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.preview-title-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.preview-title-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

/* アクションバーをボディの上に配置して常に見えるようにする */
.preview-actions {
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

.status-toggle {
  display: flex;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 11px;
}

.status-toggle label {
  padding: 5px 12px;
  cursor: pointer;
  color: var(--text-dim);
  transition: background 0.12s, color 0.12s;
}

.status-toggle input[type=radio] { display: none; }
.status-toggle input[type=radio]:checked + label {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

.btn-publish {
  margin-left: auto;
  padding: 6px 18px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-publish:hover {
  background: var(--accent-dark);
  box-shadow: 0 0 12px var(--accent-glow);
}
.btn-publish:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.preview-body {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.8;
  max-height: 260px;
  overflow-y: auto;
}

.preview-body::-webkit-scrollbar { width: 4px; }
.preview-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.preview-body h2 { font-size: 13px; font-weight: 700; margin: 12px 0 6px; color: var(--accent); }
.preview-body p  { margin-bottom: 8px; }
.preview-body ul { padding-left: 18px; margin-bottom: 8px; }
.preview-body li { margin-bottom: 4px; }

/* ===== RESULT ===== */
.result-area {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.result-item {
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 2px 0;
}

.result-item.ok   { color: var(--accent); }
.result-item.fail { color: var(--red); }
.result-item a    { color: var(--accent); text-decoration: underline; }

/* ===== INPUT BAR ===== */
.input-bar {
  padding: 14px max(24px, calc((100% - 840px) / 2));
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.input-bar textarea {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-bar textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.input-bar textarea::placeholder { color: var(--text-dim); }

.btn-send {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-send:hover   { background: var(--accent-dark); box-shadow: 0 0 14px var(--accent-glow); }
.btn-send:active  { transform: scale(0.93); }
.btn-send:disabled { background: #333; color: #555; cursor: not-allowed; box-shadow: none; }

/* ===== WELCOME ===== */
.welcome-msg {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 2.2;
}

.welcome-msg strong {
  color: var(--accent);
  font-family: var(--font-mono);
}
