:root {
  --bg-main: #070a12;
  --bg-sidebar: #0d1322;
  --bg-panel: #0b101c;
  --bg-surface: #121a2d;
  --bg-surface-elevated: #18233c;
  --bg-input: #0f1626;
  --accent-primary: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --accent-cyan: #06b6d4;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: rgba(255, 255, 255, 0.07);
  --border-active: rgba(59, 130, 246, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --font-main: 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.5;
}

/* ========================================================
   全体レイアウト (Responsive: 3ペイン構成)
   ======================================================== */
.app-layout {
  display: flex;
  height: 100dvh;
  width: 100%;
  position: relative;
  background-color: var(--bg-main);
  overflow: hidden;
}

.pc-only {
  display: none;
}
.mobile-only {
  display: flex;
}

@media (min-width: 769px) {
  .pc-only {
    display: flex;
  }
  .mobile-only {
    display: none !important;
  }
}

/* ========================================================
   左サイドバー (会話履歴)
   ======================================================== */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  max-width: 85%;
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  padding-top: env(safe-area-inset-top, 0px);
}

.app-sidebar.open {
  transform: translateX(320px);
}

@media (min-width: 769px) {
  .drawer-backdrop {
    display: none !important;
  }

  .app-sidebar {
    position: static;
    transform: none !important;
    width: 280px;
    min-width: 280px;
    height: 100%;
    z-index: 10;
    box-shadow: 2px 0 16px rgba(0,0,0,0.25);
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.search-input-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

#search-convo-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-main);
}

#search-convo-input::placeholder {
  color: var(--text-muted);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.convo-section-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 8px 2px;
}

.convo-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conv-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.15s ease;
  text-align: left;
}

.conv-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.conv-item:active, .conv-item.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.conv-info {
  flex: 1;
  min-width: 0;
}

.conv-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item.active .conv-title {
  color: #60a5fa;
  font-weight: 600;
}

.conv-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sidebar-footer-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot-online {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-success);
}

/* ========================================================
   中央メインコンテンツ領域 (チャット)
   ======================================================== */
.main-content-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-main);
  position: relative;
  min-width: 0;
}

/* ヘッダー */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
  background: rgba(13, 17, 23, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
  flex-shrink: 0;
}

@media (min-width: 769px) {
  .app-header {
    padding: 12px 24px;
    background: rgba(10, 14, 23, 0.6);
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-gradient {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.version-tag.pc-tag {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.3);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-indicator .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-indicator.online .dot {
  background-color: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success);
}

.status-indicator.working .dot {
  background-color: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: pulse-dot 1.2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

.status-indicator.online {
  color: var(--accent-success);
}

.status-indicator.working {
  color: #38bdf8;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  position: relative;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.icon-btn:active {
  transform: scale(0.95);
}

.artifact-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.artifact-toggle-btn:hover, .artifact-toggle-btn.active {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.badge-dot.hidden {
  display: none;
}

.sound-btn .icon-sound-off {
  display: block;
}
.sound-btn .icon-sound-on {
  display: none;
}
.sound-btn.active {
  color: #60a5fa;
}
.sound-btn.active .icon-sound-off {
  display: none;
}
.sound-btn.active .icon-sound-on {
  display: block;
}

/* チャットメッセージ表示エリア */
.chat-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 769px) {
  .chat-container {
    padding: 20px 32px;
  }
}

.chat-inner-wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.system-welcome {
  text-align: center;
  padding: 16px 12px;
  margin: 6px auto;
  background: rgba(26, 36, 61, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 90%;
}

@media (min-width: 769px) {
  .system-welcome {
    padding: 24px 20px;
    max-width: 580px;
  }
}

.welcome-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.system-welcome h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.system-welcome p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.messages-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* メッセージバブル */
.message-bubble {
  display: flex;
  flex-direction: column;
  max-width: 96%;
  animation: fadeIn 0.2s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-bubble.user {
  align-self: flex-end;
  max-width: 88%;
}

.message-bubble.user .bubble-body {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
  font-size: 0.9rem;
}

.message-bubble.assistant {
  align-self: flex-start;
  width: 100%;
}

.message-bubble.assistant .bubble-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 0.72rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.message-bubble.assistant .bubble-body {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px 16px 16px 16px;
  padding: 10px 12px;
  color: var(--text-primary);
  word-break: break-word;
}

.chat-main-text {
  font-size: 0.92rem;
  line-height: 1.6;
  word-break: break-word;
}

.bubble-body p {
  margin-bottom: 8px;
}
.bubble-body p:last-child {
  margin-bottom: 0;
}

.bubble-body code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #38bdf8;
  word-break: break-all;
}

.bubble-body pre {
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 10px;
  overflow-x: auto;
  max-width: 100%;
  margin: 8px 0;
}

.bubble-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.82em;
  word-break: normal;
}

/* Worked for ツール最小化チップ */
.action-step-wrapper {
  width: 100%;
  margin: 3px 0;
}

.worked-for-group {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: rgba(14, 20, 34, 0.6);
  overflow: hidden;
}

.worked-for-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: #94a3b8;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.15s ease;
  user-select: none;
}

.worked-for-summary:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

.summary-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.worked-icon {
  font-size: 0.8rem;
}

.worked-text {
  font-weight: 500;
  color: #cbd5e1;
}

.worked-duration {
  color: #60a5fa;
  font-weight: 600;
}

.worked-for-content {
  padding: 6px 8px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.tool-step-item {
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  background: #090d16;
  overflow: hidden;
  font-family: var(--font-mono);
}

.tool-step-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 0.73rem;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.tool-step-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}

.tool-step-header .badge-icon {
  font-size: 0.7rem;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  font-weight: 600;
  flex-shrink: 0;
}

.tool-step-header .badge-icon.edit-js {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.tool-step-header .badge-icon.edit-html {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
}

.tool-step-header .badge-icon.edit-css {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.tool-step-header .badge-icon.command {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.tool-step-header .step-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #cbd5e1;
}

.tool-step-header .step-title strong {
  color: #f1f5f9;
  font-weight: 500;
}

.tool-step-header .step-title code {
  font-family: var(--font-mono);
  color: #38bdf8;
  font-size: 0.9em;
}

.diff-stat {
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}

.diff-added {
  color: #4ade80;
}

.diff-deleted {
  color: #f87171;
}

.expand-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

details[open] > summary .expand-arrow {
  transform: rotate(90deg);
}

.tool-step-body {
  padding: 8px 10px;
  font-size: 0.7rem;
  background: #05070d;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  max-height: 240px;
  overflow-y: auto;
  color: #93c5fd;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--font-mono);
}

.tool-step-body pre {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  font-size: inherit;
  color: inherit;
}

/* リアルタイム実行中インジケーター */
.working-live-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(14, 28, 54, 0.85);
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.2);
  margin: 4px 0;
  animation: fadeIn 0.2s ease-out;
}

.working-live-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #93c5fd;
}

.spinner-icon {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.working-text {
  font-weight: 500;
  color: #f1f5f9;
}

.working-timer {
  color: #38bdf8;
  font-weight: 600;
  font-size: 0.76rem;
}

.btn-cancel-action {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-cancel-action:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ========================================================
   クイックアクションバー (余白スリム化)
   ======================================================== */
.quick-actions-container {
  padding: 4px 8px;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

@media (min-width: 769px) {
  .quick-actions-container {
    padding: 6px 24px;
    background: transparent;
  }
}

.quick-actions-inner {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.quick-actions-inner::-webkit-scrollbar {
  display: none;
}

.action-chip {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.action-chip:hover {
  background: var(--bg-surface-elevated);
  border-color: rgba(255, 255, 255, 0.15);
}

.action-chip.primary {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.action-chip.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* ========================================================
   入力フッター (スマホ下部余白の徹底スリム化)
   ======================================================== */
.app-footer {
  padding: 4px 8px calc(env(safe-area-inset-bottom, 0px) + 4px);
  background: rgba(13, 17, 23, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  z-index: 50;
  flex-shrink: 0;
}

@media (min-width: 769px) {
  .app-footer {
    padding: 10px 24px 14px;
    background: rgba(10, 14, 23, 0.85);
  }
}

.footer-inner {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-input-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3px 5px;
  transition: all 0.2s ease;
}

.chat-input-form:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.input-field-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

#chat-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.92rem;
  line-height: 1.35;
  padding: 6px 4px;
  resize: none;
  max-height: 120px;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

.input-pc-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 4px;
}

.voice-btn, .send-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.voice-btn {
  color: var(--text-secondary);
}

.voice-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.voice-btn.recording {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.2);
  animation: pulse 1.5s infinite;
}

.send-btn {
  background: var(--accent-gradient);
  color: #ffffff;
}

.send-btn:hover {
  opacity: 0.92;
}

/* ========================================================
   アーティファクト (Plan / Walkthrough) プレビューパネル
   ======================================================== */
.artifact-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.artifact-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.artifact-panel {
  position: fixed;
  bottom: -100%;
  left: 0;
  width: 100%;
  height: 88vh;
  max-height: 88vh;
  background: #0d121f;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.artifact-panel.open {
  bottom: 0;
}

.sheet-drag-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  margin: 8px auto 2px;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .artifact-backdrop {
    display: none !important;
  }

  .sheet-drag-handle {
    display: none !important;
  }

  .artifact-panel {
    position: static;
    bottom: auto;
    left: auto;
    width: 0;
    min-width: 0;
    max-width: 50%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--border-color);
    background: var(--bg-panel);
    opacity: 0;
    pointer-events: none;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    box-shadow: none;
  }

  .artifact-panel.open {
    width: 480px;
    min-width: 420px;
    opacity: 1;
    pointer-events: auto;
  }
}

.artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #0d121f;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.artifact-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.artifact-tabs::-webkit-scrollbar {
  display: none;
}

.artifact-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.artifact-tab-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.artifact-tab-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
  font-weight: 600;
}

.btn-close-artifact {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-close-artifact:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.92);
}

.artifact-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px;
  background: #080c16;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 769px) {
  .artifact-body {
    padding: 20px 24px;
  }
}

.artifact-markdown {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  width: 100%;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.artifact-markdown * {
  max-width: 100%;
}

.artifact-markdown h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  color: #f8fafc;
}

.artifact-markdown h2 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 6px;
  color: #93c5fd;
}

.artifact-markdown h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 12px;
  margin-bottom: 4px;
  color: #cbd5e1;
}

.artifact-markdown ul, .artifact-markdown ol {
  padding-left: 18px;
  margin-bottom: 12px;
}

.artifact-markdown li {
  margin-bottom: 4px;
}

.artifact-markdown pre {
  background: #05070d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 10px;
  overflow-x: auto;
  max-width: 100%;
  margin: 8px 0;
}

.artifact-markdown pre code {
  background: transparent;
  padding: 0;
  font-size: 0.82em;
  word-break: normal;
  white-space: pre;
}

.artifact-markdown code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #38bdf8;
  word-break: break-all;
}

.artifact-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  display: block;
  overflow-x: auto;
}

.artifact-markdown th, .artifact-markdown td {
  border: 1px solid var(--border-color);
  padding: 5px 8px;
  font-size: 0.8rem;
}

.artifact-markdown th {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
}

.artifact-markdown blockquote {
  border-left: 3px solid var(--accent-primary);
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.08);
  margin: 10px 0;
  border-radius: 0 6px 6px 0;
}

.artifact-empty {
  text-align: center;
  padding: 50px 16px;
  color: var(--text-muted);
}

.artifact-empty .empty-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 10px;
  opacity: 0.6;
}

.artifact-footer {
  padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 8px);
  background: #0d121f;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.artifact-footer.hidden {
  display: none;
}

.proceed-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

.proceed-btn:active {
  transform: scale(0.98);
}

/* PIN認証モーダル */
.auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(16px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal.hidden {
  display: none;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.auth-icon {
  font-size: 2.2rem;
  margin-bottom: 10px;
}

.auth-card h2 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.auth-card p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

#pin-input {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.15rem;
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 12px;
  outline: none;
}

#pin-input:focus {
  border-color: var(--accent-primary);
}

.submit-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.error-msg {
  color: var(--accent-danger);
  font-size: 0.75rem;
  margin-top: 8px;
  min-height: 16px;
}
