* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f5f7fa; color: #1a1a2e; }

header { background: #1a1a2e; color: #fff; padding: 12px 24px; display: flex; align-items: center; gap: 10px; }
header h1 { font-size: 1.15rem; font-weight: 600; }
header .badge { background: #4e8cff; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; }

.container { max-width: 1400px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: 380px 1fr 1fr; gap: 16px; height: calc(100vh - 52px); }

.panel { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); display: flex; flex-direction: column; overflow: hidden; }
.panel-header { padding: 12px 16px; border-bottom: 1px solid #eee; font-weight: 600; font-size: 0.85rem; display: flex; justify-content: space-between; align-items: center; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* Upload */
.upload-zone { border: 2px dashed #d0d5dd; border-radius: 8px; padding: 24px; text-align: center; cursor: pointer; transition: .2s; margin-bottom: 12px; }
.upload-zone:hover, .upload-zone.dragover { border-color: #4e8cff; background: #f0f5ff; }
.upload-zone p { color: #888; font-size: 0.82rem; margin-top: 6px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 0.82rem; font-weight: 500; transition: .15s; }
.btn-primary { background: #4e8cff; color: #fff; }
.btn-primary:hover { background: #3a7be8; }
.btn-outline { background: transparent; border: 1px solid #d0d5dd; color: #555; }
.btn-outline:hover { background: #f0f0f0; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-sm { padding: 4px 10px; font-size: 0.76rem; }

.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 0.78rem; font-weight: 500; color: #555; margin-bottom: 4px; }
.form-group select, .form-group input { width: 100%; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 6px; font-size: 0.84rem; }

/* Paragraphs */
.para-item { padding: 8px 10px; border: 1px solid #eee; border-radius: 6px; margin-bottom: 6px; cursor: pointer; transition: .15s; font-size: 0.8rem; line-height: 1.45; }
.para-item:hover { border-color: #c0c8ff; }
.para-item.selected { border-color: #4e8cff; background: #f0f5ff; }
.para-item .para-idx { font-size: 0.7rem; color: #999; }
.para-item .para-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.para-item.h1 { border-left: 3px solid #e74c3c; }
.para-item.h2 { border-left: 3px solid #f39c12; }
.para-item.skip { opacity: 0.45; background: #fef9e7; cursor: not-allowed; border-left: 3px solid #e67e22; }
.para-item.streaming { border-color: #4e8cff; background: #f0f8ff; animation: pulse 1.5s ease-in-out infinite; }
.para-item.done { border-color: #27ae60; background: #f0fdf4; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-box { background: #fff; border-radius: 12px; padding: 28px; width: 380px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid #eee; }
.tab { flex: 1; padding: 8px; text-align: center; border: none; background: none; cursor: pointer; font-size: 0.9rem; color: #888; border-bottom: 2px solid transparent; }
.tab.active { color: #4e8cff; border-bottom-color: #4e8cff; font-weight: 600; }
.auth-error { color: #e74c3c; font-size: 0.78rem; margin-top: 8px; min-height: 20px; }

/* Stream */
#streamOutput .para-block { margin-bottom: 16px; padding: 10px; border-radius: 6px; background: #fff; border: 1px solid #e8e8e8; }
#streamOutput .para-block .para-label { font-size: 0.7rem; color: #4e8cff; margin-bottom: 4px; font-weight: 600; }
#streamOutput .para-block.streaming { border-left: 3px solid #4e8cff; }
#streamOutput .para-block.done { border-left: 3px solid #27ae60; }

/* Spinner */
.spinner { display: none; width: 18px; height: 18px; border: 2px solid #ddd; border-top-color: #4e8cff; border-radius: 50%; animation: spin .6s linear infinite; }
.spinner.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast { position: fixed; top: 20px; right: 20px; padding: 10px 18px; border-radius: 8px; color: #fff; font-size: 0.82rem; z-index: 999; opacity: 0; transform: translateY(-10px); transition: .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #27ae60; }
.toast.error { background: #e74c3c; }
.toast.info { background: #4e8cff; }

@media (max-width: 1100px) {
  .container { grid-template-columns: 1fr; height: auto; }
}
