:root {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --accent-primary: #38bdf8;
  --accent-primary-hover: #0284c7;
  --accent-secondary: #818cf8;
  --bubble-ai-bg: #1e293b;
  --bubble-ai-border: #334155;
  --bubble-expert-bg: #1e1b4b;
  --bubble-expert-border: #4338ca;
  --badge-kind-bg: #0369a1;
  --badge-kind-text: #e0f2fe;
  --border-color: #334155;
  --font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Talk Mode Fixed-Height Layout (§5.0) */
body.talk-mode {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.talk-mode .app-header,
body.talk-mode .app-footer {
  flex-shrink: 0;
}

body.talk-mode .main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem 4rem 1.5rem;
  overflow: hidden;
}

body.talk-mode #view-talk.active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.talk-mode .view-header {
  flex-shrink: 0;
  margin-bottom: 1rem;
}

body.talk-mode .talk-layout-container {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 1.5rem;
  overflow: hidden;
}

body.talk-mode .chat-container-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow: hidden;
}

body.talk-mode #talk-chat-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.5rem;
  padding-bottom: 50%;
}

/* Side Panel on #/talk (§5.1) */
.side-panel {
  display: none;
  width: 320px;
  min-width: 280px;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  flex-shrink: 0;
  flex-direction: column;
  overflow-y: auto;
}

.side-panel.open {
  display: flex;
}

.side-panel-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.side-panel-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.side-panel-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.side-panel-item.visible {
  opacity: 1;
}

/* Header & Navigation */
.app-header {
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 500;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.4rem;
}

.logo-icon {
  color: var(--accent-primary);
}

.brand-tagline {
  font-size: 0.85rem;
  color: var(--text-sub);
  border-left: 1px solid var(--border-color);
  padding-left: 1rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links.nav-hidden {
  display: none !important;
}

.nav-item {
  color: var(--text-sub);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  border-bottom: 2px solid var(--accent-primary);
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem 1.5rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  margin-bottom: 1.5rem;
}

.view-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.view-desc {
  color: var(--text-sub);
  font-size: 0.95rem;
}

/* Chat Messages */
.chat-container-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  min-height: 400px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chat-bubble-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.chat-bubble-wrapper.ai {
  align-self: flex-start;
}

.chat-bubble-wrapper.expert {
  align-self: flex-end;
}

.speaker-label {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 0.25rem;
  padding: 0 0.5rem;
}

.chat-bubble-wrapper.expert .speaker-label {
  text-align: right;
}

.chat-bubble {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  line-height: 1.7;
  font-size: 1.05rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.chat-bubble-wrapper.ai .chat-bubble {
  background-color: var(--bubble-ai-bg);
  border: 1px solid var(--bubble-ai-border);
  color: var(--text-main);
  border-top-left-radius: 2px;
}

.chat-bubble-wrapper.expert .chat-bubble {
  background-color: var(--bubble-expert-bg);
  border: 1px solid var(--bubble-expert-border);
  color: var(--text-main);
  border-top-right-radius: 2px;
}

/* Expert Profile Card */
.expert-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
}

.expert-header-row h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.expert-age {
  font-size: 1.1rem;
  color: var(--text-sub);
  font-weight: normal;
}

.expert-intro {
  color: #cbd5e1;
  margin-bottom: 0.5rem;
}

.expert-digital {
  font-size: 0.9rem;
  color: var(--accent-primary);
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag-chip {
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
}

.tag-chip.interactive {
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.tag-chip.interactive:hover, .tag-chip.interactive.active {
  background: var(--accent-primary);
  color: #0f172a;
  font-weight: 600;
}

/* Notebook Table */
.notebook-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-title-row h3 {
  font-size: 1.3rem;
}

.table-wrapper {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.notebook-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.notebook-table th, .notebook-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.notebook-table th {
  background-color: rgba(15, 23, 42, 0.6);
  color: var(--text-sub);
  font-size: 0.9rem;
  font-weight: 600;
}

.notebook-table tr.notebook-item-row {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.col-title {
  width: 45%;
  font-weight: 500;
}

.meta-chips {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.chip-label {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-left: 0.4rem;
}

.chip-label:first-child {
  margin-left: 0;
}

.chip {
  background: #334155;
  color: #f1f5f9;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.chip-reward {
  background: rgba(129, 140, 248, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(129, 140, 248, 0.4);
}

.badge-kind {
  display: inline-block;
  background: var(--badge-kind-bg);
  color: var(--badge-kind-text);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.license-select {
  background-color: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  opacity: 1 !important;
  cursor: not-allowed;
}

.table-note {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 1.5rem;
}

.notebook-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: var(--accent-primary);
  color: #0f172a;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  color: #ffffff;
}

.btn-secondary {
  background: #334155;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: #475569;
}

.btn-large {
  padding: 0.8rem 1.8rem;
  font-size: 1.05rem;
}

.btn:disabled {
  opacity: 0.8 !important;
  cursor: not-allowed;
}

/* Search Screen */
.search-filter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.filter-label {
  font-weight: 600;
  white-space: nowrap;
}

.tags-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.experts-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.expert-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.expert-card-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent-primary);
}

.expert-card-item h3 {
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--text-sub);
  font-size: 1.1rem;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

/* Request Mock Screen */
.mock-header-banner {
  margin-bottom: 1rem;
}

.mock-badge {
  display: inline-block;
  background: #eab308;
  color: #0f172a;
  font-weight: 700;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.mock-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.mock-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
}

.mock-card-wide {
  grid-column: 1 / -1;
}

.mock-card-submit {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.mock-step-number {
  font-size: 0.8rem;
  color: var(--accent-primary);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.mock-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.3rem;
}

.mock-sub {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 1rem;
}

.mock-textarea {
  width: 100%;
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  opacity: 1 !important;
}

.mock-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mock-option-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #0f172a;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.mock-option-item.selected {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.05);
}

.mock-option-item input[type="radio"] {
  accent-color: var(--accent-primary);
  opacity: 1 !important;
}

.mock-guide-box {
  background: #0f172a;
  border: 1px dashed var(--accent-secondary);
  border-radius: 8px;
  padding: 1.25rem;
}

.guide-title {
  color: var(--accent-secondary);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.guide-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.guide-list li {
  font-size: 0.95rem;
}

.guide-note {
  font-size: 0.85rem;
  color: var(--text-sub);
}



/* Try Feature Screen */
.try-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.try-chat-card {
  min-height: 250px;
  max-height: 450px;
  overflow-y: auto;
}

.try-input-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.try-textarea {
  width: 100%;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

.try-actions-row {
  display: flex;
  gap: 1rem;
}

.try-status-msg {
  font-size: 0.9rem;
  color: var(--accent-primary);
}

.try-result-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
}

.try-fallback-banner {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid #eab308;
  border-radius: 8px;
  padding: 0.8rem 1.25rem;
  margin-bottom: 1.5rem;
  color: #fef08a;
  font-size: 0.95rem;
}

.try-reset-row {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

/* Footer */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 600;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-color);
  padding: 0.8rem 0;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}

.footer-disclaimer {
  color: var(--text-main);
  font-size: 16px;
  font-weight: 500;
}
