* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Yu Gothic", "Hiragino Sans", "Meiryo", sans-serif;
}

body {
  margin: 0;
  background: #f3f4f6;
  color: #111827;
}

#app {
  height: 100vh;
  overflow: hidden;
}

.root {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Top Menu Styles */
.top-menu {
  max-width: 930px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-menu-header {
  flex-shrink: 0;
  padding-bottom: 20px;
}

.top-menu h1 {
  text-align: center;
  color: #111827;
  margin-bottom: 40px;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 400px;
  margin: 0 auto;
}

.btn {
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.btn.primary {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

.btn.primary:hover {
  background: #1565c0;
  border-color: #1565c0;
}

.project-list-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.project-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 0 4px;
  flex-shrink: 0;
}

.project-list-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.project-list {
  margin-top: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #ffffff;
  transition: all 0.15s ease;
  gap: 16px;
}

.project-item:hover {
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
}

.project-item-content {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.project-item-content > div:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.project-item-actions .btn-icon {
  padding: 6px 10px;
  font-size: 16px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
}

.project-item-actions .btn-icon:hover {
  background: #fee;
  border-color: #fca5a5;
}

/* Top Bar */
.topbar {
  display: grid;
  grid-template-columns: 1.2fr 2.2fr 1.6fr;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(to right, #ffffff, #f9fafb);
  column-gap: 16px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  position: relative;
  z-index: 10;
}

.topbar-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #111827;
}

.topbar-title::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1976d2, #3b82f6);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.15);
}

.menu-area {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-area .meter {
  padding: 4px 12px;
  background: #f3f4ff;
  border-radius: 999px;
  color: #374151;
}

.menu-area .meter strong {
  font-weight: 600;
  color: #111827;
}

.menu-area input[type="number"] {
  width: 80px;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  outline: none;
}

.menu-area .btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.mode-switch {
  text-align: right;
  font-size: 13px;
  display: flex;
  justify-content: flex-end;
  gap: 0;
  color: #4b5563;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 3px;
}

.mode-switch label {
  padding: 6px 16px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-weight: 500;
  position: relative;
}

.mode-switch label:hover {
  color: #111827;
}

.mode-switch input[type="radio"] {
  display: none;
}

.mode-switch input[type="radio"]:checked + span {
  color: #1976d2;
}

.mode-switch label:has(input[type="radio"]:checked) {
  background: #ffffff;
  color: #1976d2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Submode Switch (for view type: comment/read) */
.submode-switch {
  display: flex;
  gap: 4px;
  font-size: 13px;
  color: #6b7280;
}

.submode-switch label {
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-weight: 500;
  position: relative;
  border-bottom: 2px solid transparent;
}

.submode-switch label:hover {
  color: #111827;
}

.submode-switch input[type="radio"] {
  display: none;
}

.submode-switch input[type="radio"]:checked + span {
  color: #1976d2;
}

.submode-switch label:has(input[type="radio"]:checked) {
  color: #1976d2;
  border-bottom-color: #1976d2;
}

/* Main Content */
.app-main {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 8px 10px 10px;
  gap: 8px;
}

/* Outline Panel */
.outline-panel {
  background: transparent;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 0 0 auto;
}

.outline-header {
  padding: 8px 10px;
  margin: 0 4px 4px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  color: #111827;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15,23,42,0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outline-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.outline-header-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.outline-search-row {
  display: flex;
  gap: 8px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.search-icon {
  font-size: 14px;
  color: #6b7280;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: #111827;
}

.search-box input::placeholder {
  color: #9ca3af;
}

.outline-filter-row {
  display: flex;
  gap: 8px;
}

.btn-filter {
  padding: 6px 12px;
  font-size: 12px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
}

.btn-filter:hover {
  background: #e5e7eb;
  color: #111827;
}

.btn-filter.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.character-filter-dropdown {
  position: relative;
}

.character-filter-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 150px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}

.character-filter-option {
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  color: #374151;
}

.character-filter-option:hover {
  background: #f3f4f6;
}

.character-filter-option:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.character-filter-option:last-child {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.outline-filter-tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.outline-filter-tab {
  padding: 4px 10px;
  font-size: 11px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #6b7280;
  font-weight: 500;
}

.outline-filter-tab:hover {
  background: #e5e7eb;
  color: #374151;
}

.outline-filter-tab.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.outline-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  font-size: 12px;
}

.outline-scene {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  margin: 6px 4px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(17,24,39,0.04);
  transition: all 0.15s ease;
}

.outline-scene:hover {
  box-shadow: 0 4px 10px rgba(15,23,42,0.08);
  border-color: #c7d2fe;
}

.outline-scene.disabled {
  opacity: 0.5;
  background: #f3f4f6;
}

.outline-scene-header {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  background: #eff6ff;
  border-radius: 12px 12px 0 0;
}

.outline-scene-header.selected {
  background: linear-gradient(to right, #e0f2fe, #e5e7ff);
  border-bottom: 1px solid #c7d2fe;
}

.outline-scene-header .scene-arrow {
  margin-right: 4px;
  font-size: 10px;
  color: #6b7280;
  cursor: pointer;
}

.outline-scene-header .scene-label {
  flex: 1 1 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  min-width: 0;
  font-weight: 500;
  color: #111827;
}

.scene-outline-preview {
  font-size: 11px;
  color: #9ca3af;
  font-weight: normal;
}

.outline-scene-header .scene-duration {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 11px;
  color: #6b7280;
  font-weight: normal;
  white-space: nowrap;
}

.outline-scene-header .scene-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: 12px;
}

.outline-scene-header .btn-icon {
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 12px;
}

.outline-block-list {
  padding: 4px 8px 8px 8px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 0 0 12px 12px;
}


.outline-block-row {
  display: flex;
  align-items: center;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  gap: 4px;
  transition: background-color 0.12s ease;
}

.outline-block-row:hover {
  background: #f3f4ff;
}

.outline-block-row.selected {
  background: #e0f2fe;
}

.outline-block-row.disabled {
  opacity: 0.5;
  background: #f3f4f6;
}

.outline-block-row .block-handle {
  width: 12px;
  font-size: 11px;
  color: #9ca3af;
  cursor: grab;
}

.outline-block-row .block-label {
  flex: 0 0 auto;
  white-space: nowrap;
  margin-right: 4px;
  font-weight: 500;
  color: #4b5563;
}

.outline-block-preview {
  flex: 1 1 auto;
  font-size: 11px;
  color: #6b7280;
  border-bottom: 1px dashed #e5e7eb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 1px;
}

.outline-block-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.outline-block-actions .btn-icon {
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 14px;
}

/* Divider */
.divider-vertical {
  width: 4px;
  cursor: col-resize;
  background: linear-gradient(to bottom, #e5e7eb, #cbd5f5);
  border-radius: 999px;
  flex: 0 0 auto;
  align-self: stretch;
  margin: 4px 0;
}

.divider-horizontal {
  flex: 0 0 auto;
  height: 4px;
  background: linear-gradient(to right, #e5e7eb, #cbd5f5);
  cursor: row-resize;
  border-radius: 999px;
  margin: 2px 0;
}

/* Right Column */
.right-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 6px;
}

/* Script Area */
.script-wrapper {
  flex: 0 0 55%;
  min-height: 120px;
  display: flex;
  background: transparent;
}

.script-area {
  flex: 1;
  position: relative;
  padding: 3px 12px 6px 12px;
  background: radial-gradient(circle at top left, #e0f2fe, #e5e7eb);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(15,23,42,0.12);
}

.script-pages-container {
  flex: 1;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  direction: rtl;
  display: flex;
  outline: none;
}

.script-pages-strip {
  display: flex;
  flex-direction: row-reverse;
  align-items: stretch;
  justify-content: flex-start;
  padding: 4px 40px;
  gap: 32px;
  min-width: max-content;
  direction: ltr;
}

.script-pages-strip.single {
  justify-content: center;
}

.script-page {
  flex: 0 0 auto;
  min-width: 817px;
  scroll-snap-align: center;
  display: flex;
  justify-content: center;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}

.script-page-inner {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 25px rgba(15,23,42,0.12);
  width: 817px;
  height: 554px;
  padding: 26px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  overflow: hidden;
  border-radius: 14px;
}

.script-page-inner::before {
  content: "";
  position: absolute;
  top: 24px;
  bottom: 24px;
  left: 50%;
  width: 47em;
  font-size: 16px;
  transform: translateX(-50%);
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  pointer-events: none;
}

.script-page-index {
  position: absolute;
  left: 24px;
  top: 10px;
  font-size: 11px;
  color: #9ca3af;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-info-area {
  position: absolute;
  top: 10px;
  right: 24px;
  font-size: 11px;
  color: #9ca3af;
}

.block-num {
  position: absolute;
  top: 86px;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11px;
  background: rgba(243,244,246,0.95);
  color: #4b5563;
  border: 1px solid rgba(209,213,219,0.9);
  backdrop-filter: blur(4px);
  transition: all 0.15s ease;
}

.block-num:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  box-shadow: 0 2px 4px rgba(15,23,42,0.2);
}

.block-num.selected {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
  box-shadow: 0 3px 6px rgba(25,118,210,0.5);
}

.cut-num {
  position: absolute;
  top: 58px;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 10px;
  background: rgba(255,193,7,0.95);
  color: #4b5563;
  border: 1px solid rgba(255,193,7,0.9);
}

.cut-num:hover {
  background: rgba(255,193,7,1);
}

.cut-num.selected {
  background: #ff9800;
  color: #fff;
}

.cut-divider {
  position: absolute;
  top: 24px;
  bottom: 26px;
  width: 1px;
  border-left: 1px dashed #ff9800;
  pointer-events: none;
}

.block-divider {
  position: absolute;
  top: 24px;
  bottom: 26px;
  width: 2px;
  border-left: 2px solid #1976d2;
  pointer-events: none;
}

.cut-info {
  position: absolute;
  top: 29px;
  font-size: 10px;
  color: #6b7280;
  background: rgba(255,255,255,0.9);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
}

.script-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: "游明朝体", "Yu Mincho", "Hiragino Mincho ProN", "MS Mincho", serif;
  font-size: 16px;
  line-height: 2.1;
  white-space: pre-wrap;
  width: 14em;
  height: 30.2em;
  overflow: visible;
  margin: 19px 0 0 auto;
  color: #111827;
}

.page-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.9);
  background: rgba(255,255,255,0.95);
  box-shadow: 0 4px 10px rgba(15,23,42,0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  z-index: 5;
  transition: all 0.15s ease;
  backdrop-filter: blur(4px);
  color: #111827;
}

.page-nav-btn.left {
  left: 12px;
}

.page-nav-btn.right {
  right: 12px;
}

.page-nav-btn:hover {
  background: #e5f2ff;
  transform: translateY(-50%) translateY(-1px);
  box-shadow: 0 6px 14px rgba(15,23,42,0.45);
}

/* Scene Navigation Controls */
.scene-nav-controls {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(148,163,184,0.9);
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: 0 4px 10px rgba(15,23,42,0.35);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.scene-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(148,163,184,0.5);
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #111827;
  transition: all 0.15s ease;
}

.scene-nav-btn:hover:not(:disabled) {
  background: #e5f2ff;
  border-color: #3b82f6;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15,23,42,0.2);
}

.scene-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.scene-nav-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #111827;
  font-weight: 500;
}

.scene-nav-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.scene-nav-dropdown-trigger {
  min-width: 80px;
  height: 28px;
  border: 1px solid rgba(148,163,184,0.5);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  background: #ffffff;
  padding: 0 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.scene-nav-dropdown-trigger:hover {
  border-color: #3b82f6;
  background: #f8fafc;
}

.scene-nav-dropdown-trigger:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.scene-nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  min-width: 300px;
  max-width: 500px;
  max-height: 400px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgba(148,163,184,0.5);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15,23,42,0.15);
  z-index: 100;
  display: none;
}

.scene-nav-dropdown-menu.open {
  display: block;
}

.scene-dropdown-item {
  padding: 10px 16px;
  font-size: 13px;
  color: #111827;
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid #f1f5f9;
}

.scene-dropdown-item:last-child {
  border-bottom: none;
}

.scene-dropdown-item:hover {
  background: #f8fafc;
}

.scene-dropdown-item.selected {
  background: #eff6ff;
  color: #3b82f6;
  font-weight: 600;
}

/* Edit Area */
.edit-area {
  flex: 1 1 auto;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15,23,42,0.08);
}

/* 編集エリア：左右分割レイアウト */
.edit-body-horizontal {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.edit-left {
  flex: 0 0 300px;
  padding: 12px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  background: #f9fafb;
  border-right: 1px solid #e5e7eb;
}

.edit-left-content {
  flex: 0 0 auto;
}

.edit-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
  background: #ffffff;
}

.edit-right-header {
  font-size: 11px;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-right textarea {
  flex: 1;
  width: 100%;
  font-size: 13px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  outline: none;
  resize: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
}

.edit-right textarea:focus {
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25,118,210,0.15);
  background: #ffffff;
}

.edit-header {
  padding: 8px 14px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 13px;
  flex: 0 0 auto;
  background: #f9fafb;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-new-comment {
  padding: 5px 10px;
  background: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-new-comment:hover {
  background: #2563eb;
}

.edit-body {
  flex: 1 1 auto;
  padding: 10px 14px 12px 14px;
  overflow-y: auto;
  font-size: 12px;
}

.form-row {
  margin-bottom: 10px;
}

.edit-left .form-row:last-of-type {
  margin-bottom: 0;
}

.form-row label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #111827;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row textarea,
.form-row select {
  width: 100%;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  outline: none;
  transition: all 0.15s ease;
}

.form-row input[type="text"]:focus,
.form-row input[type="number"]:focus,
.form-row textarea:focus,
.form-row select:focus {
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25,118,210,0.15);
  background: #ffffff;
}

.form-row textarea {
  resize: vertical;
  min-height: 110px;
}

.form-inline-buttons {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
}

.btn-toggle {
  border-radius: 999px;
  background: #f3f4f6;
  border-color: #e5e7eb;
  padding: 7px 10px;
  font-size: 11px;
  white-space: nowrap;
}

.btn-toggle.active {
  background: #1976d2;
  color: #fff;
  border-color: #1976d2;
}

.edit-add-buttons {
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.edit-add-buttons .btn {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  flex: 1;
}

.version-control {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  align-items: center;
}

.version-control select {
  flex: 1;
}

.version-control .btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

/* Disabled button styles */
.btn-icon:disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Cut Area */
.cut-area {
  flex: 1 1 auto;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15,23,42,0.08);
}

.cut-header {
  padding: 8px 14px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 13px;
  flex: 0 0 auto;
  background: #f9fafb;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cut-body {
  flex: 1 1 auto;
  padding: 10px 14px 12px 14px;
  overflow-y: auto;
  font-size: 12px;
}

.cut-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.cut-option-group {
  margin-bottom: 16px;
}

.cut-option-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 500;
  color: #4b5563;
}

.cut-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cut-option-input {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.cut-option-input input {
  flex: 1;
}

/* Project Create/Edit */
.project-form {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.project-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e5e7eb;
}

.project-tab {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  transition: all 0.15s ease;
  margin-bottom: -2px;
}

.project-tab.active {
  color: #1976d2;
  border-bottom-color: #1976d2;
}

/* Character tab container */
.character-tab-container {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  height: calc(100vh - 300px);
  min-height: 400px;
}

.character-sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  background: #f9fafb;
  overflow: hidden;
}

.character-sidebar-header {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.character-sidebar-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
}

.character-sidebar-item {
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  transition: all 0.15s ease;
}

.character-sidebar-item:hover {
  background: #e5e7eb;
  color: #111827;
}

.character-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  background: #ffffff;
}

.character-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  padding-top: 48px;
  margin-bottom: 12px;
  background: #ffffff;
  scroll-margin-top: 20px;
  position: relative;
}

.character-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
}

.character-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.character-fields .form-row {
  margin-bottom: 0;
}

.character-fields .form-row.full-width {
  grid-column: 1 / -1;
}

/* Dialog */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 25px rgba(15,23,42,0.2);
}

.dialog-header {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #111827;
}

.dialog-body {
  margin-bottom: 24px;
  color: #4b5563;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Help Text */
.help-text {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

/* Character Dropdown */
.character-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  margin-top: 4px;
}

.character-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
  transition: background 0.15s ease;
}

.character-dropdown-item:hover {
  background: #f3f4f6;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Auth Styles */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.auth-box {
  background: #ffffff;
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-title {
  font-size: 48px;
  font-weight: 700;
  text-align: center;
  color: #667eea;
  margin: 0 0 8px 0;
  letter-spacing: 2px;
}

.auth-subtitle {
  font-size: 14px;
  color: #6b7280;
  text-align: center;
  margin: 0 0 32px 0;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: #f3f4f6;
  border-radius: 10px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background: #ffffff;
  color: #667eea;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.auth-form {
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-error {
  padding: 12px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
  font-size: 13px;
  margin-bottom: 16px;
}

.btn-primary {
  background: #667eea;
  color: #ffffff;
  border: none;
  font-weight: 600;
}

.btn-primary:hover {
  background: #5568d3;
}

.btn-secondary {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
  font-weight: 500;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-block {
  width: 100%;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-block:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-links {
  text-align: center;
  margin-top: 16px;
}

.auth-links a {
  color: #667eea;
  text-decoration: none;
  font-size: 13px;
}

.auth-links a:hover {
  text-decoration: underline;
}

.auth-demo {
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
}

.auth-demo p {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 16px;
  line-height: 1.6;
}

/* Comment Area Styles */
.comment-edit-area {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.comment-input-header {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 12px;
}

.comment-input-header span {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  color: #4b5563;
}

.comment-author-input-inline {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
}

.comment-content-input {
  flex: 0 0 auto;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  resize: none;
  height: 80px;
  min-height: 80px;
  max-height: 80px;
  margin-bottom: 8px;
  line-height: 1.5;
}

.comment-response-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  margin-bottom: 8px;
  background: #f0f9ff;
  border-color: #3b82f6;
}

.comment-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-item {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
  background: #f9fafb;
  cursor: pointer;
  transition: all 0.2s;
}

.comment-item:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.comment-item.selected {
  background: #dbeafe;
  border-color: #3b82f6;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 600;
  font-size: 12px;
  color: #111827;
}

.comment-date {
  font-size: 11px;
  color: #6b7280;
}

.comment-content {
  font-size: 12px;
  color: #374151;
  line-height: 1.6;
  white-space: pre-wrap;
}

.comment-response {
  margin-top: 8px;
  padding: 8px 12px;
  background: #f0f9ff;
  border-left: 3px solid #3b82f6;
  border-radius: 4px;
  font-size: 12px;
  color: #1e40af;
  line-height: 1.6;
  white-space: pre-wrap;
}

.comment-response strong {
  font-weight: 600;
  margin-right: 4px;
}

/* Comment Status Tabs */
.comment-status-tabs {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.status-tab {
  padding: 6px 14px;
  background: #f3f4f6;
  border: none;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 0;
}

.status-tab:first-child {
  border-radius: 6px 0 0 6px;
}

.status-tab:last-child {
  border-radius: 0 6px 6px 0;
}

.status-tab:hover {
  background: #e5e7eb;
  color: #374151;
}

.status-tab.active {
  background: #f59e0b;
  color: #ffffff;
}

.tab-count {
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.8;
}

/* Comment Status Labels */
.comment-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  min-width: 64px;
  text-align: center;
  display: inline-block;
}

.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.status-in-progress {
  background: #dbeafe;
  color: #1e40af;
}

.status-resolved {
  background: #d1fae5;
  color: #065f46;
}

/* コメント数バッジ */
.comment-badges {
  margin-left: 4px;
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
}

.comment-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  min-width: 18px;
  text-align: center;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.badge-in-progress {
  background: #dbeafe;
  color: #1e40af;
}

.badge-resolved {
  background: #d1fae5;
  color: #065f46;
}

/* ===============================================
   モバイル対応（既存レイアウトの調整）
   =============================================== */

/* モバイルデバイスでの基本調整 */
/* タッチデバイス用のスタイル（モバイル・タブレット） */
@media (hover: none) and (pointer: coarse) {
  body {
    font-size: 12px;
  }
  
  /* ルートレイアウト */
  .root {
    font-size: 12px;
  }
  
  /* トップバーの調整 */
  .topbar {
    padding: 8px 12px;
    min-height: 44px;
    display: flex;
    align-items: center;
    position: relative;
  }
  
  .topbar h1 {
    font-size: 15px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    flex: 1;
    padding-right: 90px;
  }
  
  /* プロジェクトアイコンのサイズを縮小 */
  .topbar h1::before {
    width: 28px;
    height: 28px;
    margin-right: 8px;
  }
  
  /* モバイルではtopbar-left, topbar-rightを非表示 */
  .topbar-left,
  .topbar-right {
    display: none !important;
  }
  
  /* トップバーにKAKUロゴを右端に配置 */
  .topbar::after {
    content: 'KAKU';
    font-size: 18px;
    font-weight: 900;
    color: #1f2937;
    letter-spacing: 0.05em;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  }
  
  /* モバイルで不要な要素を非表示 */
  .menu-area {
    display: none !important;
  }
  
  .submode-switch {
    display: none !important;
  }
  
  /* メインエリアを全画面表示 */
  .app-main {
    flex-direction: column;
    height: calc(100vh - 44px);
    overflow: hidden;
  }
  
  /* アウトラインパネルを非表示 */
  .outline-panel {
    display: none !important;
  }
  
  
  /* 縦の区切り線を非表示 */
  .divider-vertical {
    display: none !important;
  }
  
  /* 右カラムを全画面に */
  .right-column {
    width: 100% !important;
    height: 100% !important;
    flex: 1 !important;
  }
  
  /* 脚本エリアを全画面で大きく表示（閲覧サブモードと同様） */
  .script-wrapper {
    width: 100% !important;
    height: calc(100vh - 44px) !important;
    flex: 1 1 auto !important;
  }
  
  .script-area {
    height: 100% !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  
  .script-header {
    display: none !important;
  }
  
  .script-pages-container {
    padding: 0 !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
    justify-content: flex-start !important;
    background: #ffffff !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    direction: rtl !important;
  }
  
  .script-pages-strip {
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 0 !important;
    height: 100% !important;
  }
  
  /* ページのサイズはJavaScriptで動的に設定される */
  .script-page {
    margin: 0;
    padding: 0;
    flex-shrink: 0 !important;
    scroll-snap-align: start !important;
    direction: ltr !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #ffffff !important;
  }
  
  .script-page-inner {
    /* サイズとtransformはJavaScriptで動的に設定される */
  }
  
  /* ページ番号を表示（モバイルでも見やすく） */
  .script-page-index {
    font-size: 14px !important;
    display: block !important;
    left: 16px !important;
    top: 16px !important;
  }
  
  /* ブロック番号をモバイルでも表示（タッチしやすいサイズに調整） */
  .block-num {
    /* position: absolute は維持（基本スタイルから継承） */
    font-size: 13px !important;
    padding: 4px 8px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    /* モバイルではクリック無効なのでカーソルをデフォルトに */
    cursor: default !important;
    /* スワイプを阻害しないように touch-action は指定しない */
  }
  
  /* 横の区切り線を非表示 */
  .divider-horizontal {
    display: none !important;
  }
  
  /* 編集エリア・コメントエリアの調整 */
  .edit-area,
  .comment-area {
    display: none !important;
  }
  
  /* ページナビゲーションコントロールを非表示 */
  .page-nav,
  .page-nav-btn,
  .scene-nav-controls,
  .script-page-controls {
    display: none !important;
  }
  
  /* ボタンの調整 */
  .btn {
    padding: 6px 12px;
    font-size: 11px;
    min-height: 36px;
  }
  
  .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  
  /* モード切り替えボタン */
  .mode-switch,
  .submode-switch {
    font-size: 11px;
  }
  
  .mode-switch label span,
  .submode-switch label span {
    padding: 5px 10px;
    font-size: 11px;
  }
  
  /* 脚本テキストをモバイル画面に合わせて表示 */
  .script-text {
    writing-mode: vertical-rl !important;
    text-orientation: mixed !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 18px !important;
    line-height: 2.0 !important;
    overflow: visible !important;
    display: block !important;
    visibility: visible !important;
    box-sizing: border-box !important;
  }
}

/* タッチデバイス向けの調整 */
@media (hover: none) and (pointer: coarse) {
  /* タッチターゲットを大きく */
  .btn,
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  .outline-block-row {
    padding: 10px 8px;
  }
  
  /* ホバー効果を無効化 */
  .outline-block-row:hover {
    background: transparent;
  }
  
  .outline-block-row.selected {
    background: #eff6ff;
  }
}


/* ============================================
   モバイル対応スタイル（PC版には影響しない）
   ============================================ */

/* モバイルではトップバーをコンパクトに */
@media (max-width: 768px) {
  .topbar {
    padding: 6px 8px;
    min-height: 44px;
  }
  
  .topbar-title {
    font-size: 14px;
  }
  
  .btn-icon {
    min-width: 40px;
    min-height: 40px;
  }
}
